Parcourir la source

First Step to apdapt for six tubes. No Calendar Set.

Vladimir Shilov il y a 4 ans
Parent
commit
7326ed3634
3 fichiers modifiés avec 25 ajouts et 38 suppressions
  1. 0 3
      inc/event-system.h
  2. 8 6
      src/event-system.c
  3. 17 29
      src/main.c

+ 0 - 3
inc/event-system.h

@@ -35,9 +35,6 @@ void dotOn(void);
 void dotOff(void);
 void showTime(void);
 void showWDM(void);
-void showWDay(void);
-void showMDay(void);
-void showMonth(void);
 void showYear(void);
 
 #ifdef USE_BRIGHT_CONTROL

+ 8 - 6
src/event-system.c

@@ -63,14 +63,16 @@ const table_state_t stateTable[] PROGMEM = {
   {stSetMM,    evBTN3Pressed, stNoChange, setMMInc,     setTimeShow},
   {stSetMM,    evBTN2Pressed, stNoChange, setMMDec,     setTimeShow},
   /* set calendar */
-  {stShowWDay, evBTN3Pressed, stNoChange, incWDay,  showWDay},
-  {stShowMDay, evBTN3Pressed, stNoChange, incMDay,  showMDay},
-  {stShowMon,  evBTN3Pressed, stNoChange, incMonth, showMonth},
+  /*
+  {stShowWDay, evBTN3Pressed, stNoChange, incWDay,  showWDM},
+  {stShowMDay, evBTN3Pressed, stNoChange, incMDay,  showWDM},
+  {stShowMon,  evBTN3Pressed, stNoChange, incMonth, showWDM},
   {stShowYear, evBTN3Pressed, stNoChange, incYear,  showYear},
-  {stShowWDay, evBTN2Pressed, stNoChange, decWDay,  showWDay},
-  {stShowMDay, evBTN2Pressed, stNoChange, decMDay,  showMDay},
-  {stShowMon,  evBTN2Pressed, stNoChange, decMonth, showMonth},
+  {stShowWDay, evBTN2Pressed, stNoChange, decWDay,  showWDM},
+  {stShowMDay, evBTN2Pressed, stNoChange, decMDay,  showWDM},
+  {stShowMon,  evBTN2Pressed, stNoChange, decMonth, showWDM},
   {stShowYear, evBTN2Pressed, stNoChange, decYear,  showYear},
+  */
   #ifdef USE_BRIGHT_CONTROL
   /* set bright */
   {stShowBright, evBTN3Pressed, stNoChange, incBright, showBright},

+ 17 - 29
src/main.c

@@ -81,7 +81,9 @@ static void valIncrease(uint8_t * val, uint8_t max);
 static void valDecrease(uint8_t * val, uint8_t max);
 static void blink(void);
 static void setSummerWinterTime(void);
+#ifdef LAMP_TEST
 static void lampTest(void);
+#endif // LAMP_TEST
 #ifdef USE_UART
 void usart_putc (char send);
 void usart_puts (const char *send);
@@ -114,10 +116,12 @@ void main(void) {
 
   /* Initialize Scheduler */
   RTOS_Init();
-  tdelay_ms(5000);
+  tdelay_ms(2000);
 
+#ifdef LAMP_TEST
   lampTest();
   tdelay_ms(5000);
+#endif // LAMP_TEST
 
   /* Initialize I2C Bus and RTC */
   I2C_Init();
@@ -329,6 +333,7 @@ void showTime(void) {
 
 void showWDM(void) {
   DISP_WDT = DISP_WDT_TIME;
+
   Digit[0] = RTC.WD & 0x0F;
   Digit[1] = DIGIT_BLANK;
   Digit[2] = RTC.Day >> 4;
@@ -337,36 +342,9 @@ void showWDM(void) {
   Digit[5] = RTC.Mon & 0x0F;
 }
 
-void showWDay(void) {
-  DISP_WDT = DISP_WDT_TIME;
-  Digit[0] = DIGIT_BLANK;
-  Digit[1] = DIGIT_BLANK;
-  Digit[2] = RTC.WD & 0x0F;
-  Digit[3] = DIGIT_BLANK;
-  Digit[4] = DIGIT_BLANK;
-  Digit[5] = DIGIT_BLANK;
-}
-
-void showMDay(void) {
-  DISP_WDT = DISP_WDT_TIME;
-  Digit[0] = RTC.Day >> 4;
-  Digit[1] = RTC.Day & 0x0F;
-  Digit[2] = DIGIT_BLANK;
-  Digit[3] = DIGIT_BLANK;
-  Digit[4] = DIGIT_BLANK;
-  Digit[5] = DIGIT_BLANK;
-}
-
-void showMonth(void) {
-  DISP_WDT = DISP_WDT_TIME;
-  Digit[0] = DIGIT_BLANK;
-  Digit[1] = DIGIT_BLANK;
-  Digit[2] = RTC.Mon >> 4;
-  Digit[3] = RTC.Mon & 0x0F;
-}
-
 void showYear(void) {
   DISP_WDT = DISP_WDT_TIME;
+
   Digit[0] = DIGIT_BLANK;
   Digit[1] = DIGIT_BLANK;
   Digit[2] = 0x02;
@@ -395,11 +373,17 @@ void decWDay(void) {
 
 void incMDay(void) {
   valIncrease(&RTC.Day, 31);
+  if (RTC.Day == 0) {
+    RTC.Day = 1;
+  }
   Flag.saveCal = 1;
 }
 
 void decMDay(void) {
   valDecrease(&RTC.Day, 31);
+  if (RTC.Day == 0) {
+    RTC.Day = 0x31;
+  }
   Flag.saveCal = 1;
 }
 
@@ -483,6 +467,8 @@ void setTimeShow(void) {
   Digit[1] = setRTC.Hr & 0x0F;
   Digit[2] = setRTC.Min >> 4;
   Digit[3] = setRTC.Min & 0x0F;
+  Digit[4] = 0x0;
+  Digit[5] = 0x0;
 }
 
 void setTimeBegin(void) {
@@ -583,6 +569,7 @@ void usart_puts (const char *send) {
 }
 #endif // USE_UART
 
+#ifdef LAMP_TEST
 /**
  * Lamp Test
  */
@@ -640,6 +627,7 @@ static void lampTest(void)
 
   }
 }
+#endif // LAMP_TEST
 
 /**
  *  П р е р ы в а н и я