|
@@ -24,6 +24,7 @@
|
|
#include "gfx.h"
|
|
#include "gfx.h"
|
|
#include "buttons.h"
|
|
#include "buttons.h"
|
|
#include "INA3221.h"
|
|
#include "INA3221.h"
|
|
|
|
+#include "graph.h"
|
|
|
|
|
|
#define INA_SCAN_PERIOS_US 62500
|
|
#define INA_SCAN_PERIOS_US 62500
|
|
#define INA_AVG_FACTOR 16
|
|
#define INA_AVG_FACTOR 16
|
|
@@ -237,7 +238,7 @@ static THD_FUNCTION(ChrgThread, arg) {
|
|
/*
|
|
/*
|
|
* Green LED blinker thread, times are in milliseconds.
|
|
* Green LED blinker thread, times are in milliseconds.
|
|
*/
|
|
*/
|
|
-static THD_WORKING_AREA(waLedThread, 256);
|
|
|
|
|
|
+static THD_WORKING_AREA(waLedThread, 128);
|
|
static THD_FUNCTION(LedThread, arg) {
|
|
static THD_FUNCTION(LedThread, arg) {
|
|
(void)arg;
|
|
(void)arg;
|
|
chRegSetThreadName("blinker");
|
|
chRegSetThreadName("blinker");
|
|
@@ -296,6 +297,7 @@ int main(void) {
|
|
*/
|
|
*/
|
|
gfxInit();
|
|
gfxInit();
|
|
prepare_Screen();
|
|
prepare_Screen();
|
|
|
|
+ graph_Init();
|
|
|
|
|
|
/*
|
|
/*
|
|
* Activates the I2C driver 1.
|
|
* Activates the I2C driver 1.
|
|
@@ -399,6 +401,7 @@ int main(void) {
|
|
events = chEvtWaitAny(ALL_EVENTS);
|
|
events = chEvtWaitAny(ALL_EVENTS);
|
|
|
|
|
|
if (events & INA_ALL_VALUSE) {
|
|
if (events & INA_ALL_VALUSE) {
|
|
|
|
+ /*
|
|
tmp1 = Voltage / 1000;
|
|
tmp1 = Voltage / 1000;
|
|
tmp2 = Voltage % 1000;
|
|
tmp2 = Voltage % 1000;
|
|
chsnprintf(buf, 11, "U:%2d.%03uV", tmp1, tmp2);
|
|
chsnprintf(buf, 11, "U:%2d.%03uV", tmp1, tmp2);
|
|
@@ -417,14 +420,18 @@ int main(void) {
|
|
tmp0 = (Capacity_I + 1800) / 3600;
|
|
tmp0 = (Capacity_I + 1800) / 3600;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
- chsnprintf(buf, 13, "CI:%2d.%03uAh", tmp1, tmp2);
|
|
|
|
|
|
+ tmp2 /= 100;
|
|
|
|
+ chsnprintf(buf, 13, "CI:%2d.%1uAH", tmp1, tmp2);
|
|
gdispFillStringBox(160, 153, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
gdispFillStringBox(160, 153, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
|
|
tmp0 = (Capacity_P + 1800) / 3600;
|
|
tmp0 = (Capacity_P + 1800) / 3600;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp1 = tmp0 / 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
tmp2 = tmp0 % 1000;
|
|
- chsnprintf(buf, 13, "CP:%2d.%03uWh", tmp1, tmp2);
|
|
|
|
|
|
+ tmp2 /= 100;
|
|
|
|
+ chsnprintf(buf, 13, "CP:%2d.%1uWH", tmp1, tmp2);
|
|
gdispFillStringBox(160, 183, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
gdispFillStringBox(160, 183, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
+ */
|
|
|
|
+ graph_Draw(Voltage, Current);
|
|
|
|
|
|
/* Check charge/decharge conditions */
|
|
/* Check charge/decharge conditions */
|
|
switch (charger_State) {
|
|
switch (charger_State) {
|
|
@@ -465,10 +472,12 @@ int main(void) {
|
|
}
|
|
}
|
|
|
|
|
|
if (events & INA_BUS_VALUES) {
|
|
if (events & INA_BUS_VALUES) {
|
|
|
|
+ /*
|
|
tmp1 = Voltage / 1000;
|
|
tmp1 = Voltage / 1000;
|
|
tmp2 = Voltage % 1000;
|
|
tmp2 = Voltage % 1000;
|
|
chsnprintf(buf, 11, "U:%2d.%03uV", tmp1, tmp2);
|
|
chsnprintf(buf, 11, "U:%2d.%03uV", tmp1, tmp2);
|
|
gdispFillStringBox(1, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
gdispFillStringBox(1, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
+ */
|
|
/* here should control processes time ? */
|
|
/* here should control processes time ? */
|
|
}
|
|
}
|
|
|
|
|
|
@@ -478,7 +487,7 @@ int main(void) {
|
|
if (Profile[charger_Profile].VoltageDechMin_mv > Voltage) {
|
|
if (Profile[charger_Profile].VoltageDechMin_mv > Voltage) {
|
|
gwinPrintf(GW1, "No Battery detected / Low voltage...\n");
|
|
gwinPrintf(GW1, "No Battery detected / Low voltage...\n");
|
|
charger_State = Stop;
|
|
charger_State = Stop;
|
|
- gdispFillStringBox(1, 213, 318, 29, "Stop", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Stop", font2, Red, Silver, gJustifyCenter);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
oldState = Charge1;
|
|
oldState = Charge1;
|
|
@@ -490,7 +499,7 @@ int main(void) {
|
|
gwinPrintf(GW1, "Begin process: Charge_1\n");
|
|
gwinPrintf(GW1, "Begin process: Charge_1\n");
|
|
|
|
|
|
palClearLine(LINE_RELAY1); // power relay on
|
|
palClearLine(LINE_RELAY1); // power relay on
|
|
- gdispFillStringBox(1, 213, 318, 29, "Charge 1", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Charge 1", font2, Red, Silver, gJustifyCenter);
|
|
break;
|
|
break;
|
|
|
|
|
|
case Pause1:
|
|
case Pause1:
|
|
@@ -514,7 +523,7 @@ int main(void) {
|
|
|
|
|
|
gwinPrintf(GW1, "Pause after Charge_1\n");
|
|
gwinPrintf(GW1, "Pause after Charge_1\n");
|
|
|
|
|
|
- gdispFillStringBox(1, 213, 318, 29, "Pause 1", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Pause 1", font2, Red, Silver, gJustifyCenter);
|
|
chVTSet(&mode_vt, TIME_S2I(CHRGR_PAUSE1_S), mode_vt_cb, (void *)Decharge);
|
|
chVTSet(&mode_vt, TIME_S2I(CHRGR_PAUSE1_S), mode_vt_cb, (void *)Decharge);
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -528,7 +537,7 @@ int main(void) {
|
|
gwinPrintf(GW1, "Begin process: Decharge\n");
|
|
gwinPrintf(GW1, "Begin process: Decharge\n");
|
|
|
|
|
|
palClearLine(LINE_RELAY2); // load relay on
|
|
palClearLine(LINE_RELAY2); // load relay on
|
|
- gdispFillStringBox(1, 213, 318, 29, "Decharge", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Decharge", font2, Red, Silver, gJustifyCenter);
|
|
break;
|
|
break;
|
|
|
|
|
|
case Pause2:
|
|
case Pause2:
|
|
@@ -555,7 +564,7 @@ int main(void) {
|
|
gwinPrintf(GW1, "/%2u.%02u\n", tmp1, tmp2);
|
|
gwinPrintf(GW1, "/%2u.%02u\n", tmp1, tmp2);
|
|
|
|
|
|
gwinPrintf(GW1, "Pause after Decharge\n");
|
|
gwinPrintf(GW1, "Pause after Decharge\n");
|
|
- gdispFillStringBox(1, 213, 318, 29, "Pause 2", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Pause 2", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
chVTSet(&mode_vt, TIME_S2I(CHRGR_PAUSE2_S), mode_vt_cb, (void *)Charge2);
|
|
chVTSet(&mode_vt, TIME_S2I(CHRGR_PAUSE2_S), mode_vt_cb, (void *)Charge2);
|
|
break;
|
|
break;
|
|
@@ -570,7 +579,7 @@ int main(void) {
|
|
gwinPrintf(GW1, "Begin process: Charge_2\n");
|
|
gwinPrintf(GW1, "Begin process: Charge_2\n");
|
|
|
|
|
|
palClearLine(LINE_RELAY1); // power relay on
|
|
palClearLine(LINE_RELAY1); // power relay on
|
|
- gdispFillStringBox(1, 213, 318, 29, "Charge 2", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Charge 2", font2, Red, Silver, gJustifyCenter);
|
|
break;
|
|
break;
|
|
|
|
|
|
case Error:
|
|
case Error:
|
|
@@ -578,7 +587,8 @@ int main(void) {
|
|
// power and load relay off
|
|
// power and load relay off
|
|
palSetLine(LINE_RELAY1);
|
|
palSetLine(LINE_RELAY1);
|
|
palSetLine(LINE_RELAY2);
|
|
palSetLine(LINE_RELAY2);
|
|
- gdispFillStringBox(1, 213, 318, 29, "Error", font2, Silver, Red, gJustifyCenter);
|
|
|
|
|
|
+ gwinPrintf(GW1, "ERROR\n");
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Error", font2, Silver, Red, gJustifyCenter);
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -603,14 +613,15 @@ int main(void) {
|
|
// power and load relay off
|
|
// power and load relay off
|
|
palSetLine(LINE_RELAY1);
|
|
palSetLine(LINE_RELAY1);
|
|
palSetLine(LINE_RELAY2);
|
|
palSetLine(LINE_RELAY2);
|
|
- gdispFillStringBox(1, 213, 318, 29, "Stop", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|
|
+ gwinPrintf(GW1, "STOP\n");
|
|
|
|
+ //gdispFillStringBox(1, 213, 318, 29, "Stop", font2, Red, Silver, gJustifyCenter);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (events & TIME_CHANGE) {
|
|
if (events & TIME_CHANGE) {
|
|
- chsnprintf(buf, 12, "T:%02u:%02u:%02u", Timer.hh, Timer.mm, Timer.ss);
|
|
|
|
- gdispFillStringBox(160, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
|
|
|
|
+ //chsnprintf(buf, 12, "T:%02u:%02u:%02u", Timer.hh, Timer.mm, Timer.ss);
|
|
|
|
+ //gdispFillStringBox(160, 123, 158, 29, buf, font2, Red, Gray, gJustifyLeft);
|
|
}
|
|
}
|
|
|
|
|
|
if (events & INSERTED_EVENT) {
|
|
if (events & INSERTED_EVENT) {
|
|
@@ -639,15 +650,15 @@ static void prepare_Screen(void) {
|
|
gdispDrawBox(0, 0, width-1, height-1, Green); // all screen
|
|
gdispDrawBox(0, 0, width-1, height-1, Green); // all screen
|
|
gdispDrawLine(0, 122, width-1, 122, Green); // h line
|
|
gdispDrawLine(0, 122, width-1, 122, Green); // h line
|
|
gdispDrawLine(79, 0, 79, 122, Green); // v line, text | console
|
|
gdispDrawLine(79, 0, 79, 122, Green); // v line, text | console
|
|
- gdispFillArea(1, 1, 78, 121, Blue); // text area
|
|
|
|
|
|
+ gdispFillArea(1, 1, 78, 121, Blue); // menu area
|
|
|
|
|
|
- /* print text to top-left area */
|
|
|
|
|
|
+ /* print menu to top-left area */
|
|
show_MenuItem(MenuItem_1);
|
|
show_MenuItem(MenuItem_1);
|
|
show_MenuItem(MenuItem_2);
|
|
show_MenuItem(MenuItem_2);
|
|
show_MenuItem(MenuItem_3);
|
|
show_MenuItem(MenuItem_3);
|
|
show_MenuItem(MenuItem_4);
|
|
show_MenuItem(MenuItem_4);
|
|
|
|
|
|
- /* clear bootom area */
|
|
|
|
|
|
+ /* clear bootom area. 1,123-319,239 - measure area. 1,213-310,239 - status line */
|
|
gdispFillStringBox(1, 123, 318, 115, " ", font2, Red, Gray, gJustifyLeft);
|
|
gdispFillStringBox(1, 123, 318, 115, " ", font2, Red, Gray, gJustifyLeft);
|
|
gdispFillStringBox(1, 213, 318, 29, "Stop", font2, Red, Silver, gJustifyCenter);
|
|
gdispFillStringBox(1, 213, 318, 29, "Stop", font2, Red, Silver, gJustifyCenter);
|
|
|
|
|