Compare commits

..

No commits in common. "aef366e593a7e8047a23398479759c5a9bae0d96" and "f8957a4cf9d6f6da6ddb5f9e96e633fa4dafebe4" have entirely different histories.

View File

@ -105,9 +105,13 @@ void win_init_str(StStr *st) {
}; };
void get_fake_data(Tel *t) { void get_fake_data(Tel *t) {
t->speed.data = t->speed.ldata + rand() % (t->speed.hdata - t->speed.ldata + 1);
t->power.data = t->power.ldata + rand() % (t->power.hdata - t->power.ldata + 1);
t->bat.data = t->bat.ldata + rand() % (t->bat.hdata - t->bat.ldata + 1);
t->rpm.data = t->rpm.ldata + rand() % (t->rpm.hdata - t->rpm.ldata + 1); t->rpm.data = t->rpm.ldata + rand() % (t->rpm.hdata - t->rpm.ldata + 1);
t->tens.data = t->tens.ldata + ((float)rand() / (float)RAND_MAX) * (float)(t->tens.hdata - t->tens.ldata); t->tens.data = t->tens.ldata + ((float)rand() / (float)RAND_MAX) * (float)(t->tens.hdata - t->tens.ldata);
t->amp.data = t->amp.ldata + ((float)rand() / (float)RAND_MAX) * (float)(t->amp.hdata - t->amp.ldata); t->amp.data = t->amp.ldata + ((float)rand() / (float)RAND_MAX) * (float)(t->amp.hdata - t->amp.ldata);
t->eff.data = t->eff.ldata + ((float)rand() / (float)RAND_MAX) * (float)(t->eff.hdata - t->eff.ldata);
} }
void read_can(Tel *t, int soc) { void read_can(Tel *t, int soc) {
@ -570,13 +574,13 @@ int main(int argc, char **argv) {
int y6r = y - (y2 + 2* y6); int y6r = y - (y2 + 2* y6);
Tel tel; Tel tel;
tel.speed = (StInt){0 , 0 , 51 , 3, 1, y2 , x3 , 0 , 0 , NULL, "speed (km/h)" }; tel.speed = (StInt){0 , 0 , 200 , 3, 1, y2 , x3 , 0 , 0 , NULL, "speed (km/h)" };
tel.rpm = (StInt){0 , 0 , 3000 , 4, 1, y2 , x3 , 0 , x3 , NULL, "rpm (tr/min)" }; tel.rpm = (StInt){0 , 0 , 6000 , 4, 1, y2 , x3 , 0 , x3 , NULL, "rpm (tr/min)" };
tel.power = (StInt){0 , 0 , 1300 , 4, 1, 2*y6 , 2*x3, y2 , 0 , NULL, "power (W)" }; tel.power = (StInt){0 , 0 , 1300 , 4, 1, 2*y6 , 2*x3, y2 , 0 , NULL, "power (W)" };
tel.bat = (StInt){0 , 0 , 100 , 3, 0, y4 , x3r , 0 , x-x3r , NULL, "batteries (%)" }; tel.bat = (StInt){0 , 0 , 100 , 3, 0, y4 , x3r , 0 , x-x3r , NULL, "batteries (%)" };
tel.eff = (StFlt){0.0f, 0.0f , 100.0f, 5, 1, y4r , x3r , y4 , x-x3r , NULL, "efficiency (Wh/Km)" }; tel.eff = (StFlt){0.0f, 0.0f, 300.0f, 5, 1, y4r , x3r , y4 , x-x3r , NULL, "efficiency (Wh/Km)" };
tel.tens = (StFlt){0.0f, 36.0f, 55.0f , 4, 1, y2r4 , x3r , y2 , x-x3r , NULL, "tension (V)" }; tel.tens = (StFlt){0.0f, 0.0f, 55.0f , 4, 1, y2r4 , x3r , y2 , x-x3r , NULL, "tension (V)" };
tel.amp = (StFlt){0.0f, 0.0f , 30.0f , 4, 1, y2r4r, x3r , y-y2r4r, x-x3r , NULL, "intensity (A)" }; tel.amp = (StFlt){0.0f, 0.0f, 55.0f , 4, 1, y2r4r, x3r , y-y2r4r, x-x3r , NULL, "intensity (A)" };
tel.message = (StStr){0 , 0 , y6r , 2*x3, y-y6r , 0 , NULL, "warnings" }; tel.message = (StStr){0 , 0 , y6r , 2*x3, y-y6r , 0 , NULL, "warnings" };
win_init_int(&tel.speed); win_init_int(&tel.speed);
@ -607,10 +611,11 @@ int main(int argc, char **argv) {
} else { } else {
if (use_can) read_can(&tel, soc); if (use_can) read_can(&tel, soc);
if (use_uart) read_uart(&tel, uart_fd, &uart_parser); if (use_uart) read_uart(&tel, uart_fd, &uart_parser);
calc_data(&tel, &bat_state, now);
} }
break; break;
} }
calc_data(&tel, &bat_state, now);
now = now_ms(); now = now_ms();
if (now - t100 >= 100 * delay) { if (now - t100 >= 100 * delay) {
win_int(&tel.speed, use_color); win_int(&tel.speed, use_color);