Procházet zdrojové kódy

Added FadeIn for oher IN-15 symbols.

Vladimir N. Shilov před 2 roky
rodič
revize
94f6afd212
4 změnil soubory, kde provedl 167 přidání a 27 odebrání
  1. 7 0
      Inc/board.h
  2. 4 0
      Inc/clock.h
  3. 12 9
      Src/board.c
  4. 144 18
      Src/clock.c

+ 7 - 0
Inc/board.h

@@ -26,6 +26,13 @@ typedef enum {
   Lvl_On = 7
 } brigh_level_t;
 
+typedef enum {
+  sym_Pressure  = 0x1,
+  sym_Plus      = 0x2,
+  sym_Minus     = 0x4,
+  sym_Percent   = 0x8
+} in15_pin_t;
+
 typedef struct {
     uint8_t r;
     uint8_t g;

+ 4 - 0
Inc/clock.h

@@ -7,6 +7,10 @@
 #include "main.h"
 
 /* macro */
+#define FADE_START      0
+#define FADE_STOP       15
+#define FADE_STEP       1
+
 /* Display timeout, sec */
 #define DISP_WDT_TIME   10
 

+ 12 - 9
Src/board.c

@@ -32,7 +32,7 @@ const uint8_t cie[8] = { 0, 5, 14, 33, 64, 109, 172, 255 };
 /* private typedef */
 
 /* private functions */
-static void _show_digits(const tube4_t dig);
+static void _show_digits(const uint32_t digits);
 static void GPIO_Init(void);
 static void DMA_Init(void);
 static void I2C1_Init(void);
@@ -108,31 +108,34 @@ void Board_Init(void)
 void showDigits(tube4_t dig)
 {
   static uint32_t old_dig = 0;
-  uint8_t st = 0, ov = 0;
+  uint8_t st = 0, ov = FADE_START;
 
   if (old_dig == dig.u32) {
-    _show_digits(dig);
+    _show_digits(dig.u32);
   } else {
-    while (ov < 15) {
+    while (ov < FADE_STOP) {
       if (st == 0) {
         // new tube value
         st = 1;
-        _show_digits(dig);
-        ov ++;
+        _show_digits(dig.u32);
+        ov += FADE_STEP;
         tdelay_ms(ov);
       } else {
         // old tube value
         st = 0;
-        _show_digits((tube4_t)old_dig);
-        tdelay_ms(15 - ov);
+        _show_digits(old_dig);
+        tdelay_ms(FADE_STOP - ov);
       }
     } // End of while
     old_dig = dig.u32;
   } // End of if-else
 }
 
-static void _show_digits(tube4_t dig)
+static void _show_digits(const uint32_t digits)
 {
+  tube4_t dig;
+  dig.u32 = digits;
+
   /* Clear buffer */
   tubesBuffer[0] = 0;
   tubesBuffer[1] = 0;

+ 144 - 18
Src/clock.c

@@ -11,9 +11,14 @@ static btn_t Button[BTN_NUM] = {
 static volatile uint8_t dispWDT = 0;
 
 /* function prototypes */
-static void Color_RGB(const uint8_t r, const uint8_t g, const uint8_t b);
+//static void Color_RGB(const uint8_t r, const uint8_t g, const uint8_t b);
 static void MinusFadeIn(void);
 static void MinusFadeOut(void);
+static void PlusFadeIn(void);
+static void PercentFadeIn(void);
+static void PressureFadeIn(void);
+//static void IN15_FadeIn(in15_pin_t pin);
+//static void IN15_FadeOut(in15_pin_t pin);
 
 /* funcions */
 /**
@@ -108,49 +113,161 @@ void in15P(void) {
 
 /** 'Faded' funcions */
 static void MinusFadeIn(void) {
-  static uint8_t on = 0;
-  static uint8_t off = 20;
+  static uint8_t on = FADE_START;
+  static uint8_t off = FADE_STOP;
   static uint8_t st = 0;
 
   if (st == 0) {
     st = 1;
     IN15_Minus;
-    on += 2;
-    if (on < 20) {
+    on += FADE_STEP;
+    if (on < FADE_STOP) {
       RTOS_SetTask(MinusFadeIn, on, 0);
     } else {
-      on = 0; off = 20; st = 0;
+      on = FADE_START; off = FADE_STOP; st = 0;
     }
   } else {
     st = 0;
     IN15_OFF;
-    off -= 2;
+    off -= FADE_STEP;
     RTOS_SetTask(MinusFadeIn, off, 0);
   }
 }
 
 static void MinusFadeOut(void) {
-  static uint8_t off = 0;
-  static uint8_t on = 20;
+  static uint8_t off = FADE_START;
+  static uint8_t on = FADE_STOP;
   static uint8_t st = 0;
 
   if (st == 0) {
     st = 1;
     IN15_OFF;
-    off += 2;
-    if (off < 20) {
+    off += FADE_STEP;
+    if (off < FADE_STOP) {
       RTOS_SetTask(MinusFadeOut, off, 0);
     } else {
-      off = 0; on = 20; st = 0;
+      off = FADE_START; on = FADE_STOP; st = 0;
     }
   } else {
     st = 0;
     IN15_Minus;
-    on -= 2;
+    on -= FADE_STEP;
     RTOS_SetTask(MinusFadeOut, on, 0);
   }
 }
 
+static void PlusFadeIn(void) {
+  static uint8_t on = FADE_START;
+  static uint8_t off = FADE_STOP;
+  static uint8_t st = 0;
+
+  if (st == 0) {
+    st = 1;
+    IN15_Plus;
+    on += FADE_STEP;
+    if (on < FADE_STOP) {
+      RTOS_SetTask(PlusFadeIn, on, 0);
+    } else {
+      on = FADE_START; off = FADE_STOP; st = 0;
+    }
+  } else {
+    st = 0;
+    IN15_OFF;
+    off -= FADE_STEP;
+    RTOS_SetTask(PlusFadeIn, off, 0);
+  }
+}
+
+static void PercentFadeIn(void) {
+  static uint8_t on = FADE_START;
+  static uint8_t off = FADE_STOP;
+  static uint8_t st = 0;
+
+  if (st == 0) {
+    st = 1;
+    IN15_Percent;
+    on += FADE_STEP;
+    if (on < FADE_STOP) {
+      RTOS_SetTask(PercentFadeIn, on, 0);
+    } else {
+      on = FADE_START; off = FADE_STOP; st = 0;
+    }
+  } else {
+    st = 0;
+    IN15_OFF;
+    off -= FADE_STEP;
+    RTOS_SetTask(PercentFadeIn, off, 0);
+  }
+}
+
+static void PressureFadeIn(void) {
+  static uint8_t on = FADE_START;
+  static uint8_t off = FADE_STOP;
+  static uint8_t st = 0;
+
+  if (st == 0) {
+    st = 1;
+    IN15_P;
+    on += FADE_STEP;
+    if (on < FADE_STOP) {
+      RTOS_SetTask(PressureFadeIn, on, 0);
+    } else {
+      on = FADE_START; off = FADE_STOP; st = 0;
+    }
+  } else {
+    st = 0;
+    IN15_OFF;
+    off -= FADE_STEP;
+    RTOS_SetTask(PressureFadeIn, off, 0);
+  }
+}
+
+#ifdef NEW_SHED
+static void IN15_FadeIn(in15_pin_t pin) {
+  static uint8_t on = FADE_START;
+  static uint8_t off = FADE_STOP;
+  static uint8_t st = 0;
+
+  if (st == 0) {
+    st = 1;
+    GPIOA->BSRR = pin;
+    on += FADE_STEP;
+    if (on < FADE_STOP) {
+      RTOS_SetTask(IN15_FadeIn, on, 0);
+    } else {
+      on = FADE_START; off = FADE_STOP; st = 0;
+    }
+  } else {
+    st = 0;
+    IN15_OFF;
+    off -= FADE_STEP;
+    RTOS_SetTask(IN15_FadeIn, off, 0);
+  }
+}
+
+static void IN15_FadeOut(in15_pin_t pin) {
+  static uint8_t off = FADE_START;
+  static uint8_t on = FADE_STOP;
+  static uint8_t st = 0;
+
+  if (st == 0) {
+    st = 1;
+    IN15_OFF;
+    off += FADE_STEP;
+    if (off < FADE_STOP) {
+      RTOS_SetTask(IN15_FadeOut, off, 0);
+    } else {
+      off = FADE_START; on = FADE_STOP; st = 0;
+    }
+  } else {
+    st = 0;
+    GPIOA->BSRR = pin;
+    on -= FADE_STEP;
+    RTOS_SetTask(IN15_FadeOut, on, 0);
+  }
+}
+#endif /* NewShed */
+
 /**
   * Show info on tubes.
   */
@@ -237,7 +354,9 @@ void showYear(void) {
 
 void showHumidity(void) {
   dispWDT = DISP_WDT_TIME;
-  in15Percent();
+  //in15Percent();
+  //IN15_FadeIn(sym_Percent);
+  PercentFadeIn();
 
   tube4_t buf;
   buf.s8.tA = Humidity / 10;
@@ -249,7 +368,9 @@ void showHumidity(void) {
 
 void showTemperature(void) {
   dispWDT = DISP_WDT_TIME;
-  in15Plus();
+  //in15Plus();
+  //IN15_FadeIn(sym_Plus);
+  PlusFadeIn();
 
   tube4_t buf;
   buf.s8.tA = 0xf;
@@ -261,7 +382,9 @@ void showTemperature(void) {
 
 void showPressure(void) {
   dispWDT = DISP_WDT_TIME;
-  in15P();
+  //in15P();
+  //IN15_FadeIn(sym_Pressure);
+  PressureFadeIn();
 
   tube4_t buf;
   int tmp;
@@ -277,16 +400,19 @@ void showPressure(void) {
 void showSensorData(void) {
   ES_SetState(stShowSensorData);
   RTOS_DeleteTask(MinusFadeOut);
-  HSV2LED(1, 255, cie[Lvl_Mdl]); // Nixie color
+  //HSV2LED(1, 255, cie[Lvl_Mdl]); // Nixie color
 
+  HSV2LED(0, 255, cie[Lvl_Mdl]); // RED
   showTemperature();
   tdelay_ms(3000);
 
+  HSV2LED(40, 255, cie[Lvl_Mdl]); // BLUE
   showHumidity();
   tdelay_ms(3000);
 
+  HSV2LED(20, 255, cie[Lvl_Mdl]); // GREEN
   showPressure();
-  tdelay_ms(2500);
+  tdelay_ms(2700);
 
   ES_SetState(stShowTime);
 //  showTime();