diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 3707caeef8277b..e3e7d3fd664a8d 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -847,7 +847,6 @@ static void bb_ui_draw_measures_left(UIState *s, int bb_x, int bb_y, int bb_w ) */ //add battery temperature - /* if (true) { char val_str[16]; char uom_str[6]; @@ -858,7 +857,7 @@ static void bb_ui_draw_measures_left(UIState *s, int bb_x, int bb_y, int bb_w ) val_color = nvgRGBA(255, 188, 3, 200); } - snprintf(val_str, sizeof(val_str), "%2.0f°C", s->scene.pa0); + snprintf(val_str, sizeof(val_str), "%2d°C", s->scene.pa0); snprintf(uom_str, sizeof(uom_str), ""); bb_h +=bb_ui_draw_measure(s, val_str, uom_str, "BAT TEMP", bb_rx, bb_ry, bb_uom_dx, @@ -866,7 +865,6 @@ static void bb_ui_draw_measures_left(UIState *s, int bb_x, int bb_y, int bb_w ) value_fontSize, label_fontSize, uom_fontSize ); bb_ry = bb_y + bb_h; } - */ //add grey panda GPS accuracy /*if (true) { @@ -913,8 +911,9 @@ static void bb_ui_draw_measures_left(UIState *s, int bb_x, int bb_y, int bb_w ) val_color, lab_color, uom_color, value_fontSize, label_fontSize, uom_fontSize ); bb_ry = bb_y + bb_h; + } - + */ //finally draw the frame bb_h += 20; @@ -923,7 +922,6 @@ static void bb_ui_draw_measures_left(UIState *s, int bb_x, int bb_y, int bb_w ) nvgStrokeColor(s->vg, nvgRGBA(255,255,255,80)); nvgStrokeWidth(s->vg, 6); nvgStroke(s->vg); - */ } diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 086f3b46145db9..f91ea363932b14 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -112,7 +112,6 @@ static void ui_init(UIState *s) { s->uilayout_sock = SubSocket::create(s->ctx, "uiLayoutState"); s->livecalibration_sock = SubSocket::create(s->ctx, "liveCalibration"); s->radarstate_sock = SubSocket::create(s->ctx, "radarState"); - //s->thermal_sock = SubSocket::create(s->ctx, "thermal"); s->carstate_sock = SubSocket::create(s->ctx, "carState"); assert(s->model_sock != NULL); @@ -120,7 +119,6 @@ static void ui_init(UIState *s) { assert(s->uilayout_sock != NULL); assert(s->livecalibration_sock != NULL); assert(s->radarstate_sock != NULL); - //assert(s->thermal_sock != NULL); assert(s->carstate_sock != NULL); s->poller = Poller::create({ @@ -129,21 +127,9 @@ static void ui_init(UIState *s) { s->uilayout_sock, s->livecalibration_sock, s->radarstate_sock, - s->carstate_sock + s->carstate_sock }); - /* - s->poller = Poller::create({ - s->model_sock, - s->controlsstate_sock, - s->uilayout_sock, - s->livecalibration_sock, - s->radarstate_sock, - s->thermal_sock, - s->carstate_sock - }); - */ - #ifdef SHOW_SPEEDLIMIT s->map_data_sock = SubSocket::create(s->ctx, "liveMapData"); @@ -444,13 +430,6 @@ void handle_message(UIState *s, Message * msg) { s->scene.speedlimitahead_valid = datad.speedLimitAheadValid; s->scene.speedlimitaheaddistance = datad.speedLimitAheadDistance; s->scene.speedlimit_valid = datad.speedLimitValid; - // getting thermal related data for dev ui - //} else if (eventd.which == cereal_Event_thermal) { - // struct cereal_ThermalData datad; - // cereal_read_ThermalData(&datad, eventd.thermal); - - // s->scene.pa0 = datad.pa0; - // s->scene.freeSpace = datad.freeSpace; } else if (eventd.which == cereal_Event_carState) { struct cereal_CarState datad; cereal_read_CarState(&datad, eventd.carState); @@ -863,6 +842,8 @@ int main(int argc, char* argv[]) { set_volume(MIN_VOLUME); s->volume_timeout = 5 * UI_FREQ; + // dev ui, update every 5 seconds + s->bat_temp_timeout = 5 * UI_FREQ; int draws = 0; while (!do_exit) { bool should_swap = false; @@ -976,6 +957,22 @@ int main(int argc, char* argv[]) { s->controls_seen = false; } + // dev ui, update battery/temp values every 5 secs + if (s->awake && s->vision_connected) { + if (s->bat_temp_timeout > 0) { + s->bat_temp_timeout--; + } else { + // update temp + int temp = open("/sys/devices/virtual/thermal/thermal_zone25/temp", O_RDONLY); + if (temp >= 0) { + char temp_buf[2]; + read(temp, temp_buf, 2); + s->scene.pa0 = atoi(temp_buf); + } + s->bat_temp_timeout = 5 * UI_FREQ; + } + } + read_param_bool_timeout(&s->is_metric, "IsMetric", &s->is_metric_timeout); read_param_bool_timeout(&s->longitudinal_control, "LongitudinalControl", &s->longitudinal_control_timeout); read_param_bool_timeout(&s->limit_set_speed, "LimitSetSpeed", &s->limit_set_speed_timeout); diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index 956b2040b638db..b1bdb6cbee022f 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -139,7 +139,7 @@ typedef struct UIScene { // dev ui float angleSteersDes; - float pa0; + int pa0; float freeSpace; } UIScene; @@ -234,6 +234,8 @@ typedef struct UIState { int is_metric_timeout; int longitudinal_control_timeout; int limit_set_speed_timeout; + // for dev ui + int bat_temp_timeout; bool controls_seen;