فهرست منبع

Added Date set-up.

Vladimir N. Shilov 2 سال پیش
والد
کامیت
e9c9d0f4bb
5فایلهای تغییر یافته به همراه125 افزوده شده و 103 حذف شده
  1. 5 7
      Inc/event-system.h
  2. 2 4
      Inc/list_event.h
  3. 7 1
      ReadMe.txt
  4. 85 56
      Src/clock.c
  5. 26 35
      Src/event-system.c

+ 5 - 7
Inc/event-system.h

@@ -37,8 +37,6 @@ void in15P(void);
 void showTime(void);
 void showMMSS(void);
 void showWD(void);
-void showDay(void);
-void showMonth(void);
 void showDayMon(void);
 void showYear(void);
 
@@ -59,13 +57,13 @@ void setTimeEnd(void);
 
 void setDateBegin(void);
 void setDateEnd(void);
-void setWShow(void);
-void setDMShow(void);
-void setYearShow(void);
-void setWDayBegin(void);
-void setMDayBegin(void);
+void setWDBegin(void);
+void setMDBegin(void);
 void setMonthBegin(void);
 void setYearBegin(void);
+void setWDShow(void);
+void setDMShow(void);
+void setYearShow(void);
 void setIncWDay(void);
 void setIncMDay(void);
 void setIncMonth(void);

+ 2 - 4
Inc/list_event.h

@@ -24,8 +24,6 @@ typedef enum {
   stShowTime,
   stShowMMSS,
   stShowWDay,
-  stShowMDay,
-  stShowMon,
   stShowDM,
   stShowYear,
   stShowHumidity,
@@ -35,8 +33,8 @@ typedef enum {
   stShowBright,
   stSetHH,
   stSetMM,
-  stSetWDay,
-  stSetMDay,
+  stSetWD,
+  stSetMD,
   stSetMon,
   stSetYear,
   /* end */

+ 7 - 1
ReadMe.txt

@@ -79,7 +79,7 @@ pulse mode? тогда будет синхронизация со сменой 
 этапе инициализации. Отдебажить gcc (пока) нет возможности (лень заниматься).
 В любом случае - очень странно...
 
-Из хорошего - VSCode очень даже приятен. Segger тоже ничего, но горячме 
+Из хорошего - VSCode очень даже приятен. Segger тоже ничего, но горячие 
 влавиши совсем свои.
 C::B скорее всего придётся хоронить - "плюсов" у него не осталось, поиск по 
 коду сломался или хз.
@@ -92,3 +92,9 @@ C::B скорее всего придётся хоронить - "плюсов"
 ан нет - работает только с уровнем оптимизации "s", 2 и 3 - нет.
 Ждём отладчик...
 Segger убрал, в хардфаулт падает только он.
+---
+03.02.2022
+
+Вчерашняя версия опять перестала работать под GCC...
+
+Есть мысль повесить опрос кнопок на 16 или 17-ый таймер.

+ 85 - 56
Src/clock.c

@@ -324,30 +324,6 @@ void showWD(void) {
   showDigits(buf);
 }
 
-void showDay(void) {
-  dispWDT = DISP_WDT_TIME;
-  IN15_OFF;
-
-  tube4_t buf;
-  buf.s8.tA = Clock.Day >> 4;
-  buf.s8.tB = Clock.Day & 0xf;
-  buf.s8.tD = 0xf;
-  buf.s8.tE = 0xf;
-  showDigits(buf);
-}
-
-void showMonth(void) {
-  dispWDT = DISP_WDT_TIME;
-  IN15_OFF;
-
-  tube4_t buf;
-  buf.s8.tA = 0xf;
-  buf.s8.tB = 0xf;
-  buf.s8.tD = Clock.Mon >> 4;
-  buf.s8.tE = Clock.Mon & 0xf;
-  showDigits(buf);
-}
-
 void showDayMon(void) {
   dispWDT = DISP_WDT_TIME;
   IN15_OFF;
@@ -404,6 +380,7 @@ void showTemperature(void) {
 
 void showPressure(void) {
   dispWDT = DISP_WDT_TIME;
+  HSV2LED(20, 255, cie[Lvl_Mdl]); // GREEN
   //in15P();
   symToFade = sym_Pressure;
   IN15_FadeIn();
@@ -432,7 +409,6 @@ void showSensorData(void) {
   showHumidity();
   tdelay_ms(3000);
 
-  HSV2LED(20, 255, cie[Lvl_Mdl]); // GREEN
   showPressure();
   tdelay_ms(2700);
 
@@ -441,11 +417,7 @@ void showSensorData(void) {
 }
 
 void setTimeShow(void) {
-	dispWDT =  DISP_WDT_TIME;
-
-  in15Minus();
-
-  HSV2LED(1, 255, cie[Lvl_2]);
+	dispWDT = DISP_WDT_TIME;
 
   tube4_t buf;
   buf.s8.tA = setClock.Hr >> 4;
@@ -456,13 +428,15 @@ void setTimeShow(void) {
 }
 
 void setTimeBegin(void) {
-	dispWDT =  DISP_WDT_TIME;
+	dispWDT = DISP_WDT_TIME;
+  in15Minus();
+  HSV2LED(1, 255, cie[Lvl_2]);
   RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
   RTC_ReadAll(&setClock);
 }
 
 void setHHBegin(void) {
-	dispWDT =  DISP_WDT_TIME;
+	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 1;
   Flag.Blink_2 = 1;
   Flag.Blink_4 = 0;
@@ -472,17 +446,15 @@ void setHHBegin(void) {
 }
 
 void setHHInc(void) {
-	dispWDT =  DISP_WDT_TIME;
   valIncrease(&setClock.Hr, 23);
 }
 
 void setHHDec(void) {
-	dispWDT =  DISP_WDT_TIME;
   valDecrease(&setClock.Hr, 23);
 }
 
 void setMMBegin(void) {
-	dispWDT =  DISP_WDT_TIME;
+	dispWDT = DISP_WDT_TIME;
   Flag.Blink_1 = 0;
   Flag.Blink_2 = 0;
   Flag.Blink_4 = 1;
@@ -492,16 +464,15 @@ void setMMBegin(void) {
 }
 
 void setMMInc(void) {
-	dispWDT =  DISP_WDT_TIME;
   valIncrease(&setClock.Min, 59);
 }
 
 void setMMDec(void) {
-	dispWDT =  DISP_WDT_TIME;
   valDecrease(&setClock.Min, 59);
 }
 
 void setTimeEnd(void) {
+	dispWDT = 0;
   RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
 
   setClock.Sec = 0;
@@ -517,74 +488,132 @@ void setTimeEnd(void) {
 }
 
 void setDateBegin(void) {
-
+	dispWDT = DISP_WDT_TIME;
+  IN15_OFF;
+  RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
+  RTC_ReadAll(&setClock);
 }
 
 void setDateEnd(void) {
+	dispWDT =  0;
+  RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
+  
+  RTC_WriteCalendar(&setClock);
 
-}
+  Flag.Blink_1 = 0;
+  Flag.Blink_2 = 0;
+  Flag.Blink_4 = 0;
+  Flag.Blink_5 = 0;
+  Blink_Stop();
 
-void setWShow(void) {
+  RTC_ReadAll(&Clock);
+}
 
+void setWDBegin(void) {
+	dispWDT = DISP_WDT_TIME;
+  Flag.Blink_1 = 0;
+  Flag.Blink_2 = 1;
+  Flag.Blink_4 = 0;
+  Flag.Blink_5 = 0;
+  Blink_Start();
+  setWDShow();
 }
 
-void setDMShow(void) {
+void setWDShow(void) {
+	dispWDT = DISP_WDT_TIME;
 
+  tube4_t buf;
+  buf.s8.tA = 0xf;
+  buf.s8.tB = setClock.WD & 0xf;
+  buf.s8.tD = 0xf;
+  buf.s8.tE = 0xf;
+  showDigits(buf);
 }
 
-void setYearShow(void) {
+void setDMShow(void) {
+	dispWDT = DISP_WDT_TIME;
 
+  tube4_t buf;
+  buf.s8.tA = setClock.Day >> 4;
+  buf.s8.tB = setClock.Day & 0xf;
+  buf.s8.tD = setClock.Mon >> 4;
+  buf.s8.tE = setClock.Mon & 0xf;
+  showDigits(buf);
 }
 
-void setWDayBegin(void) {
+void setYearShow(void) {
+	dispWDT = DISP_WDT_TIME;
 
+  tube4_t buf;
+  buf.s8.tA = 2;
+  buf.s8.tB = 0;
+  buf.s8.tD = setClock.Year >> 4;
+  buf.s8.tE = setClock.Year & 0xf;
+  showDigits(buf);
 }
 
-void setMDayBegin(void) {
-
+void setMDBegin(void) {
+	dispWDT = DISP_WDT_TIME;
+  Flag.Blink_1 = 1;
+  Flag.Blink_2 = 1;
+  Flag.Blink_4 = 0;
+  Flag.Blink_5 = 0;
+  Blink_Start();
+  setDMShow();
 }
 
 void setMonthBegin(void) {
-
+	dispWDT = DISP_WDT_TIME;
+  Flag.Blink_1 = 0;
+  Flag.Blink_2 = 0;
+  Flag.Blink_4 = 1;
+  Flag.Blink_5 = 1;
+  Blink_Start();
+  setDMShow();
 }
 
 void setYearBegin(void) {
-
+	dispWDT = DISP_WDT_TIME;
+  Flag.Blink_1 = 0;
+  Flag.Blink_2 = 0;
+  Flag.Blink_4 = 1;
+  Flag.Blink_5 = 1;
+  Blink_Start();
+  setYearShow();
 }
 
 void setIncWDay(void) {
-
+  valIncrease(&setClock.WD, 7);
 }
 
 void setIncMDay(void) {
-
+  valIncrease(&setClock.Day, 31);
 }
 
 void setIncMonth(void) {
-
+  valIncrease(&setClock.Mon, 12);
 }
 
 void setIncYear(void) {
-
+  valIncrease(&setClock.Year, 99);
 }
 
 void setDecWDay(void) {
-
+  valDecrease(&setClock.WD, 7);
 }
 
 void setDecMDay(void) {
-
+  valDecrease(&setClock.Day, 31);
 }
 
 void setDecMonth(void) {
-
+  valDecrease(&setClock.Mon, 12);
 }
 
 void setDecYear(void) {
-
+  valDecrease(&setClock.Year, 99);
 }
 
-
 /**
   * @brief  Increase BCD value.
   * @param  : val, max

+ 26 - 35
Src/event-system.c

@@ -44,8 +44,6 @@ const table_state_t stateTable[] = {
   /* display wdt */
   {stShowWDay,        evDisplayWDT, stShowTime, showTime, NULL},
   {stShowDM,          evDisplayWDT, stShowTime, showTime, NULL},
-  {stShowMDay,        evDisplayWDT, stShowTime, showTime, NULL},
-  {stShowMon,         evDisplayWDT, stShowTime, showTime, NULL},
   {stShowYear,        evDisplayWDT, stShowTime, showTime, NULL},
   //{stShowBright,      evDisplayWDT, stShowTime, showTime, NULL},
   {stShowHumidity,    evDisplayWDT, stShowTime, showTime, NULL},
@@ -57,8 +55,6 @@ const table_state_t stateTable[] = {
   {stShowMMSS, evNewSecond,  stNoChange, showMMSS,   NULL},
   {stShowWDay, evRefreshCal, stNoChange, showWD,     NULL},
   {stShowDM,   evRefreshCal, stNoChange, showDayMon, NULL},
-  {stShowMDay, evRefreshCal, stNoChange, showDay,    NULL},
-  {stShowMon,  evRefreshCal, stNoChange, showMonth,  NULL},
   {stShowYear, evRefreshCal, stNoChange, showYear,   NULL},
 //  {stShowYear,   evBTN1Pressed, stShowBright, showBright, NULL},
   {stShowBright, evBTN1Pressed, stShowTime,   showTime,   NULL},
@@ -81,40 +77,35 @@ const table_state_t stateTable[] = {
   {stSetMM,    evDisplayWDT,  stShowTime, showTime,     NULL},
 
   /* set calendar */
-/*
-  {stShowWDM, evBTN1Holded,  stSetWDay,  setDateBegin,  setWDayBegin},
-  {stSetWDay, evBTN1Holded,  stShowWDM,  setDateEnd,    showWDM},
-  {stSetMDay, evBTN1Holded,  stShowWDM,  setDateEnd,    showWDM},
-  {stSetMon,  evBTN1Holded,  stShowWDM,  setDateEnd,    showWDM},
-  {stSetWDay, evBTN1Pressed, stSetMDay,  setMDayBegin,  NULL},
-  {stSetMDay, evBTN1Pressed, stSetMon,   setMonthBegin, NULL},
-  {stSetMon,  evBTN1Pressed, stSetWDay,  setWDayBegin,  NULL},
-  {stSetWDay, evBTN2Pressed, stNoChange, setDecWDay,    setWDMShow},
-  {stSetWDay, evBTN3Pressed, stNoChange, setIncWDay,    setWDMShow},
-  {stSetMDay, evBTN2Pressed, stNoChange, setDecMDay,    setWDMShow},
-  {stSetMDay, evBTN3Pressed, stNoChange, setIncMDay,    setWDMShow},
-  {stSetMon,  evBTN2Pressed, stNoChange, setDecMonth,   setWDMShow},
-  {stSetMon,  evBTN3Pressed, stNoChange, setIncMonth,   setWDMShow},
-
-  {stShowYear, evBTN1Holded,  stSetYear,  setDateBegin, setYearBegin},
-  {stSetYear,  evBTN1Holded,  stShowYear, setDateEnd,   showYear},
-  {stSetYear,  evBTN2Pressed, stNoChange, setDecYear,   setYearShow},
-  {stSetYear,  evBTN3Pressed, stNoChange, setIncYear,   setYearShow},
-
-  {stSetWDay, evDisplayWDT, stShowTime, showTime, NULL},
-  {stSetMDay, evDisplayWDT, stShowTime, showTime, NULL},
+  // begin
+  {stShowWDay, evBTN1Holded, stSetWD,   setDateBegin, setWDBegin},
+  {stShowDM,   evBTN1Holded, stSetMD,   setDateBegin, setMDBegin},
+  {stShowYear, evBTN1Holded, stSetYear, setDateBegin, setYearBegin},
+  // end
+  {stSetWD,   evBTN1Holded, stShowWDay, setDateEnd, showWD},
+  {stSetMD,   evBTN1Holded, stShowDM,   setDateEnd, showDayMon},
+  {stSetMon,  evBTN1Holded, stShowDM,   setDateEnd, showDayMon},
+  {stSetYear, evBTN1Holded, stShowYear, setDateEnd, showYear},
+  // next
+  {stSetWD,   evBTN1Pressed, stSetMD,   setMDBegin,    NULL},
+  {stSetMD,   evBTN1Pressed, stSetMon,  setMonthBegin, NULL},
+  {stSetMon,  evBTN1Pressed, stSetYear, setYearBegin,  NULL},
+  {stSetYear, evBTN1Pressed, stSetWD,   setWDBegin,    NULL},
+  // change
+  {stSetWD,   evBTN2Pressed, stNoChange, setDecWDay,  setWDShow},
+  {stSetWD,   evBTN3Pressed, stNoChange, setIncWDay,  setWDShow},
+  {stSetMD,   evBTN2Pressed, stNoChange, setDecMDay,  setDMShow},
+  {stSetMD,   evBTN3Pressed, stNoChange, setIncMDay,  setDMShow},
+  {stSetMon,  evBTN2Pressed, stNoChange, setDecMonth, setDMShow},
+  {stSetMon,  evBTN3Pressed, stNoChange, setIncMonth, setDMShow},
+  {stSetYear, evBTN2Pressed, stNoChange, setDecYear,  setYearShow},
+  {stSetYear, evBTN3Pressed, stNoChange, setIncYear,  setYearShow},
+  // WDT
+  {stSetWD,   evDisplayWDT, stShowTime, showTime, NULL},
+  {stSetMD,   evDisplayWDT, stShowTime, showTime, NULL},
   {stSetMon,  evDisplayWDT, stShowTime, showTime, NULL},
   {stSetYear, evDisplayWDT, stShowTime, showTime, NULL},
 
-  {stShowWDay, evBTN3Pressed, stNoChange, incWDay,  showWDM},
-  {stShowMDay, evBTN3Pressed, stNoChange, incMDay,  showWDM},
-  {stShowMon,  evBTN3Pressed, stNoChange, incMonth, showWDM},
-  {stShowYear, evBTN3Pressed, stNoChange, incYear,  showYear},
-  {stShowWDay, evBTN2Pressed, stNoChange, decWDay,  showWDM},
-  {stShowMDay, evBTN2Pressed, stNoChange, decMDay,  showWDM},
-  {stShowMon,  evBTN2Pressed, stNoChange, decMonth, showWDM},
-  {stShowYear, evBTN2Pressed, stNoChange, decYear,  showYear},
-*/
   /* set bright */
 //  {stShowBright, evBTN3Pressed, stNoChange, incBright, showBright},
 //  {stShowBright, evBTN2Pressed, stNoChange, decBright, showBright},