Преглед на файлове

Improve Blinker, Set Time, Set Date.

Vladimir N. Shilov преди 2 години
родител
ревизия
37d80dfe57
променени са 5 файла, в които са добавени 44 реда и са изтрити 30 реда
  1. 2 2
      Inc/board.h
  2. 24 2
      Src/board.c
  3. 2 21
      Src/clock.c
  4. 0 3
      Src/event-system.c
  5. 16 2
      Src/stm32g0xx_it.c

+ 2 - 2
Inc/board.h

@@ -97,9 +97,9 @@ typedef union {
 #define PWM_LED_INIT_VAL    127
 #define PWM_LED_MAX_VAL     TIM3_ARR
 
-#define TIM14_PSC            (24000 - 1)
+#define TIM14_PSC            (12000 - 1)
 #define TIM14_ARR            (1000 - 1)
-#define TIM14_PULSE_VAL       750
+#define TIM14_PULSE_VAL      500
 
 #define TIM16_PSC            (24 - 1)
 #define TIM16_ARR            (1000 - 1)

+ 24 - 2
Src/board.c

@@ -616,8 +616,30 @@ void Blink_Stop(void)
 {
   /* disable timer */
   TIM14->CR1 &= ~(TIM_CR1_CEN);
-  /* On all tubes */
-  TUBE_ALL_ON;
+
+  /* enable channels */
+  if (Flag.Blink_1 != 0) {
+    TUBE_A_ON;
+  }
+  if (Flag.Blink_2 != 0) {
+    TUBE_B_ON;
+  }
+  if (Flag.Blink_3 != 0) {
+    TUBE_C_ON;
+  }
+  if (Flag.Blink_4 != 0) {
+    TUBE_D_ON;
+  }
+  if (Flag.Blink_5 != 0) {
+    TUBE_E_ON;
+  }
+
+	/* clear flags */
+	Flag.Blink_1 = 0;
+	Flag.Blink_2 = 0;
+	Flag.Blink_3 = 0;
+	Flag.Blink_4 = 0;
+	Flag.Blink_5 = 0;
 }
 
 /**

+ 2 - 21
Src/clock.c

@@ -106,11 +106,6 @@ void new_Second(void) {
   if (dispWDT != 0) {
     dispWDT--;
     if (dispWDT == 0) {
-			Flag.Blink_1 = 0;
-			Flag.Blink_2 = 0;
-			Flag.Blink_3 = 0;
-			Flag.Blink_4 = 0;
-			Flag.Blink_5 = 0;
 			Blink_Stop();
       ES_PlaceEvent(evDisplayWDT);
     }
@@ -518,7 +513,7 @@ void setTimeShow(void) {
 }
 
 void setTimeBegin(void) {
-	dispWDT = DISP_WDT_TIME;
+	RTOS_DeleteTask(MinusFadeOut);
   in15Minus();
   HSV2LED(COLOUR_NIXIE, 255, BrightLevel);
   RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
@@ -526,7 +521,6 @@ void setTimeBegin(void) {
 }
 
 void setHHBegin(void) {
-	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 1;
   Flag.Blink_2 = 1;
   Flag.Blink_4 = 0;
@@ -544,7 +538,6 @@ void setHHDec(void) {
 }
 
 void setMMBegin(void) {
-	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 0;
   Flag.Blink_2 = 0;
   Flag.Blink_4 = 1;
@@ -568,18 +561,14 @@ void setTimeEnd(void) {
   setClock.Sec = 0;
   RTC_WriteTime(&setClock);
 
-  Flag.Blink_1 = 0;
-  Flag.Blink_2 = 0;
-  Flag.Blink_4 = 0;
-  Flag.Blink_5 = 0;
   Blink_Stop();
 
   RTC_ReadAll(&Clock);
 }
 
 void setDateBegin(void) {
-	dispWDT = DISP_WDT_TIME;
   IN15_OFF;
+  HSV2LED(COLOUR_NIXIE, 255, BrightLevel);
   RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
   RTC_ReadAll(&setClock);
 }
@@ -590,17 +579,12 @@ void setDateEnd(void) {
   
   RTC_WriteCalendar(&setClock);
 
-  Flag.Blink_1 = 0;
-  Flag.Blink_2 = 0;
-  Flag.Blink_4 = 0;
-  Flag.Blink_5 = 0;
   Blink_Stop();
 
   RTC_ReadAll(&Clock);
 }
 
 void setWDBegin(void) {
-	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 0;
   Flag.Blink_2 = 1;
   Flag.Blink_4 = 0;
@@ -643,7 +627,6 @@ void setYearShow(void) {
 }
 
 void setMDBegin(void) {
-	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 1;
   Flag.Blink_2 = 1;
   Flag.Blink_4 = 0;
@@ -653,7 +636,6 @@ void setMDBegin(void) {
 }
 
 void setMonthBegin(void) {
-	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 0;
   Flag.Blink_2 = 0;
   Flag.Blink_4 = 1;
@@ -663,7 +645,6 @@ void setMonthBegin(void) {
 }
 
 void setYearBegin(void) {
-	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 0;
   Flag.Blink_2 = 0;
   Flag.Blink_4 = 1;

+ 0 - 3
Src/event-system.c

@@ -70,9 +70,6 @@ const table_state_t stateTable[] = {
   {stSetMM,    evBTN2Pressed, stNoChange, setMMInc,     setTimeShow},
   {stSetMM,    evBTN3Pressed, stNoChange, setMMDec,     setTimeShow},
 
-  {stSetHH,    evNewSecond,   stNoChange, setTimeShow,  NULL},
-  {stSetMM,    evNewSecond,   stNoChange, setTimeShow,  NULL},
-
   {stSetHH,    evDisplayWDT,  stShowTime, showTime,     NULL},
   {stSetMM,    evDisplayWDT,  stShowTime, showTime,     NULL},
 

+ 16 - 2
Src/stm32g0xx_it.c

@@ -160,8 +160,22 @@ void TIM14_IRQHandler(void)
     /* Update interrupt flag */
     TIM14->SR &= ~TIM_SR_UIF;
 
-    /* enable all channels */
-    TUBE_ALL_ON;
+    /* enable channels */
+    if (Flag.Blink_1 != 0) {
+      TUBE_A_ON;
+    }
+    if (Flag.Blink_2 != 0) {
+      TUBE_B_ON;
+    }
+    if (Flag.Blink_3 != 0) {
+      TUBE_C_ON;
+    }
+    if (Flag.Blink_4 != 0) {
+      TUBE_D_ON;
+    }
+    if (Flag.Blink_5 != 0) {
+      TUBE_E_ON;
+    }
   }
   if ((TIM14->SR & TIM_SR_CC1IF) != 0) {
     /* Capture/Compare Interrupt flag */