Kaynağa Gözat

Fix Timer show, etc.

Vladimir N. Shilov 2 yıl önce
ebeveyn
işleme
19d38a816a
1 değiştirilmiş dosya ile 24 ekleme ve 20 silme
  1. 24 20
      src/main.c

+ 24 - 20
src/main.c

@@ -24,8 +24,8 @@
 #define INA_SCAN_PERIOS_US    62500
 #define INA_AVG_FACTOR        16
 
-#define CHRGR_PAUSE1_S        60
-#define CHRGR_PAUSE2_S        60
+#define CHRGR_PAUSE1_S        300
+#define CHRGR_PAUSE2_S        300
 
 #define INA_ALL_VALUSE        EVENT_MASK(0)
 #define INA_BUS_VALUES        EVENT_MASK(1)
@@ -312,7 +312,7 @@ int main(void) {
   chThdCreateStatic(waInaThread, sizeof(waInaThread), NORMALPRIO, InaThread, NULL);
   //chVTSetContinuous(&ina_vt, TIME_MS2I(INA_SCAN_PERIOS_MS), ina_Process, NULL);
 
-  gwinPrintf(GW1, "Try to init INA3221....\n");
+  gwinPrintf(GW1, "Try to init INA3221...\n");
   ina3221.i2c_addr = INA3221_ADDR40_GND;
   ina3221.i2cd = &I2CD1;
   ina3221.shuntRes[INA3221_CH1] = charger_Channels[INA3221_CH1].shunt;
@@ -454,22 +454,21 @@ int main(void) {
         Timer.mm = 0;
         Timer.ss = 0;
         gwinPrintf(GW1, "Begin process: Charge_1\n");
-        // power relay on
-        palClearLine(LINE_RELAY1);
+
+        palClearLine(LINE_RELAY1);  // power relay on
         gdispFillStringBox(1, 213, 318, 29, "Charge 1", font2, Red, Silver, gJustifyCenter);
         break;
 
       case Pause1:
         oldState = Pause1;
-        // power relay off
-        palSetLine(LINE_RELAY1);
+
+        palSetLine(LINE_RELAY1);  // power relay off
 
         tmp0 = CHRGR_PAUSE1_S / 60;
         Timer.ss = CHRGR_PAUSE1_S % 60;
         Timer.hh = tmp0 / 60;
         Timer.mm = tmp0 % 60;
 
-        gwinPrintf(GW1, "Pause after Charge_1\n");
         tmp0 = (Capacity_I + 1800) / 3600;
         tmp1 = tmp0 / 1000;
         tmp2 = (tmp0 % 1000) / 10;
@@ -478,6 +477,9 @@ int main(void) {
         tmp1 = tmp0 / 1000;
         tmp2 = (tmp0 % 1000) / 10;
         gwinPrintf(GW1, "/%2u.%02u\n", tmp1, tmp2);
+
+        gwinPrintf(GW1, "Pause after Charge_1\n");
+
         gdispFillStringBox(1, 213, 318, 29, "Pause 1", font2, Red, Silver, gJustifyCenter);
         chVTSet(&mode_vt, TIME_S2I(CHRGR_PAUSE1_S), mode_vt_cb, (void *)Decharge);
         break;
@@ -490,15 +492,15 @@ int main(void) {
         Timer.mm = 0;
         Timer.ss = 0;
         gwinPrintf(GW1, "Begin process: Decharge\n");
-        // load relay on
-        palClearLine(LINE_RELAY2);
+        
+        palClearLine(LINE_RELAY2);  // load relay on
         gdispFillStringBox(1, 213, 318, 29, "Decharge", font2, Red, Silver, gJustifyCenter);
         break;
 
       case Pause2:
         oldState = Pause2;
-        // load relay off
-        palSetLine(LINE_RELAY2);
+
+        palSetLine(LINE_RELAY2);  // load relay off
 
         dech_Capacity_I = Capacity_I;
         dech_Capacity_P = Capacity_P;
@@ -509,7 +511,6 @@ int main(void) {
         Timer.hh = tmp0 / 60;
         Timer.mm = tmp0 % 60;
 
-        gwinPrintf(GW1, "Pause after Decharge\n");
         tmp0 = (Capacity_I + 1800) / 3600;
         tmp1 = tmp0 / 1000;
         tmp2 = (tmp0 % 1000) / 10;
@@ -518,7 +519,10 @@ int main(void) {
         tmp1 = tmp0 / 1000;
         tmp2 = (tmp0 % 1000) / 10;
         gwinPrintf(GW1, "/%2u.%02u\n", tmp1, tmp2);
+
+        gwinPrintf(GW1, "Pause after Decharge\n");
         gdispFillStringBox(1, 213, 318, 29, "Pause 2", font2, Red, Silver, gJustifyCenter);
+
         chVTSet(&mode_vt, TIME_S2I(CHRGR_PAUSE2_S), mode_vt_cb, (void *)Charge2);
         break;
 
@@ -530,8 +534,8 @@ int main(void) {
         Timer.ss = 0;
         oldState = Charge2;
         gwinPrintf(GW1, "Begin process: Charge_2\n");
-        // power relay on
-        palClearLine(LINE_RELAY1);
+
+        palClearLine(LINE_RELAY1);  // power relay on
         gdispFillStringBox(1, 213, 318, 29, "Charge 2", font2, Red, Silver, gJustifyCenter);
         break;
       
@@ -548,6 +552,10 @@ int main(void) {
           ch_Capacity_I = Capacity_I;
           ch_Capacity_P = Capacity_P;
           chTimer = Timer;
+          Timer.hh = 0;
+          Timer.mm = 0;
+          Timer.ss = 0;
+
           tmp0 = (Capacity_I + 1800) / 3600;
           tmp1 = tmp0 / 1000;
           tmp2 = (tmp0 % 1000) / 10;
@@ -567,11 +575,7 @@ int main(void) {
     }
 
     if (events & TIME_CHANGE) {
-      if (charger_State != Stop) {
-        chsnprintf(buf, 12, "T:%02u:%02u:%02u", Timer.hh, Timer.mm, Timer.ss);
-      } else {
-        chsnprintf(buf, 12, "T:00:00:00");
-      }
+      chsnprintf(buf, 12, "T:%02u:%02u:%02u", Timer.hh, Timer.mm, Timer.ss);
       gdispFillStringBox(160, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
     }
   }