Browse Source

Unify bright control.

Vladimir N. Shilov 3 years ago
parent
commit
2cf0a70107
3 changed files with 47 additions and 33 deletions
  1. 43 31
      Inc/board.h
  2. 2 0
      Src/board.c
  3. 2 2
      Src/clock.c

+ 43 - 31
Inc/board.h

@@ -7,6 +7,48 @@
 #include "main.h"
 #include "gpio.h"
 
+/* Type Defs */
+typedef enum {
+  Tube_A = 3,
+  Tube_B = 2,
+  Tube_D = 1,
+  Tube_E = 0
+} tube_pos_t;
+
+typedef enum {
+  Lvl_Off = 0,
+  Lvl_Min = 1,
+  Lvl_2 = 2,
+  Lvl_3 = 3,
+  Lvl_Mdl = 4,
+  Lvl_5 = 5,
+  Lvl_Max = 6,
+  Lvl_On = 7
+} brigh_level_t;
+
+typedef struct {
+    uint8_t r;
+    uint8_t g;
+    uint8_t b;
+} RGB_t;
+
+typedef struct {
+    uint8_t h;
+    uint8_t s;
+    uint8_t v;
+} HSV_t;
+
+typedef union {
+  uint32_t u32;  /* element specifier for accessing whole u32 */
+  uint8_t ar[4]; /* element specifier for accessing as array  */
+  struct {
+    uint8_t tE;  /* element specifier for accessing Tube_E(4) */
+    uint8_t tD;  /* element specifier for accessing Tube_D(3) */
+    uint8_t tB;  /* element specifier for accessing Tube_B(2) */
+    uint8_t tA;  /* element specifier for accessing Tube_A(1) */
+  } s8;         /* element spec. for acc. struct with tubes  */
+} tube4_t;
+
 /* Exported macros */
 #define LATCH_DOWN      GPIOC->BRR = 0x40
 #define LATCH_UP        GPIOC->BSRR = 0x40
@@ -124,37 +166,7 @@
 #define BTNS_STATE          (BTNS1_STATE | BTNS2_STATE)
 
 /* Variables */
-
-/* Type Defs */
-typedef enum {
-  Tube_A = 3,
-  Tube_B = 2,
-  Tube_D = 1,
-  Tube_E = 0
-} tube_pos_t;
-
-typedef struct {
-    uint8_t r;
-    uint8_t g;
-    uint8_t b;
-} RGB_t;
-
-typedef struct {
-    uint8_t h;
-    uint8_t s;
-    uint8_t v;
-} HSV_t;
-
-typedef union {
-  uint32_t u32;  /* element specifier for accessing whole u32 */
-  uint8_t ar[4]; /* element specifier for accessing as array  */
-  struct {
-    uint8_t tE;  /* element specifier for accessing Tube_E(4) */
-    uint8_t tD;  /* element specifier for accessing Tube_D(3) */
-    uint8_t tB;  /* element specifier for accessing Tube_B(2) */
-    uint8_t tA;  /* element specifier for accessing Tube_A(1) */
-  } s8;         /* element spec. for acc. struct with tubes  */
-} tube4_t;
+extern const uint8_t cie[];
 
 /* Exported funcions */
 void SystemClock_Config(void);

+ 2 - 0
Src/board.c

@@ -26,6 +26,8 @@ static const uint16_t nixieCathodeMap[4][10] = {
 };
 //static const uint8_t nixieCathodeMask[4][2] = {{0x00, 0x3f}, {0xc0, 0x0f}, {0xf0, 0x03}, {0xc0, 0x00}};
 static uint8_t tubesBuffer[SPI_BUFFER_SIZE] = {0};
+//convert linear bright level to logariphmic
+const uint8_t cie[8] = { 0, 5, 14, 33, 64, 109, 172, 255 };
 
 /* private typedef */
 

+ 2 - 2
Src/clock.c

@@ -159,7 +159,7 @@ void showTime(void) {
   RTOS_SetTask(MinusFadeOut, 500, 0);
 
   uint8_t hue = bcd2bin(Clock.Sec);
-  HSV2LED(hue, 255, 63);
+  HSV2LED(hue, 255, cie[Lvl_Mdl]);
 
   tube4_t buf;
 /*
@@ -277,7 +277,7 @@ void showPressure(void) {
 void showSensorData(void) {
   ES_SetState(stShowSensorData);
   RTOS_DeleteTask(MinusFadeOut);
-  Color_RGB(0xFF, 0x12, 0x0); // Nixie color. FF1200 or FF7E00 or FFBF00
+  HSV2LED(4, 255, cie[Lvl_Mdl]); // Nixie color
 
   showTemperature();
   tdelay_ms(3000);