From 97be6b3a0edf0034b1e202d9234f31b3383e03f0 Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Sun, 11 Jun 2017 15:12:50 -0700 Subject: [PATCH 1/9] Update UI to make speed text more readable in all conditions as requested by community --- selfdrive/ui/ui.c | 53 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 63459de4a4..3084299aa8 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -677,13 +677,37 @@ static void ui_draw_vision(UIState *s) { // draw speed char speed_str[16]; - nvgFontSize(s->vg, 128.0f); + float defaultfontsize = 128.0f; + float labelfontsize = 65.0f; + + /****************************************** + * Add background rect so it's easier to see in + * light background scenes + ******************************************/ + // Left side - ACC max speed + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, -15, 0, 535, 175, 30); + nvgFillColor(s->vg, nvgRGBA(10, 10, 10, 180)); + nvgFill(s->vg); + /******************************************/ + if (scene->engaged) { nvgFillColor(s->vg, nvgRGBA(255, 128, 0, 192)); + + // Add label + nvgFontSize(s->vg, labelfontsize); + nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); + nvgText(s->vg, 42, 175-30, "ACC: engaged", NULL); } else { - nvgFillColor(s->vg, nvgRGBA(64, 64, 64, 192)); + nvgFillColor(s->vg, nvgRGBA(195, 195, 195, 192)); + + // Add label + nvgFontSize(s->vg, labelfontsize); + nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); + nvgText(s->vg, 42, 175-30, "ACC: disabled", NULL); } + nvgFontSize(s->vg, defaultfontsize); if (scene->v_cruise != 255 && scene->v_cruise != 0) { if (s->is_metric) { snprintf(speed_str, sizeof(speed_str), "%3d KPH", @@ -694,9 +718,27 @@ static void ui_draw_vision(UIState *s) { (int)(scene->v_cruise * 0.621371 + 0.5)); } nvgTextAlign(s->vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BASELINE); - nvgText(s->vg, 500, 150, speed_str, NULL); + nvgText(s->vg, 500, 95, speed_str, NULL); } + /****************************************** + * Add background rect so it's easier to see in + * light background scenes + ******************************************/ + // Right side - Actual speed + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, 1920 - 500, 0, 1920, 175, 20); + nvgFillColor(s->vg, nvgRGBA(10, 10, 10, 180)); + nvgFill(s->vg); + + // Add label + nvgFontSize(s->vg, labelfontsize); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 192)); + nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); + nvgText(s->vg, 1920 - 475, 175-30, "Current Speed", NULL); + /******************************************/ + + nvgFontSize(s->vg, defaultfontsize); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 192)); if (s->is_metric) { snprintf(speed_str, sizeof(speed_str), "%3d KPH", @@ -706,7 +748,8 @@ static void ui_draw_vision(UIState *s) { (int)(scene->v_ego * 2.237 + 0.5)); } nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); - nvgText(s->vg, 1920 - 500, 150, speed_str, NULL); + //nvgText(s->vg, 1920 - 500, 150, speed_str, NULL); + nvgText(s->vg, 1920 - 500, 95, speed_str, NULL); /*nvgFontSize(s->vg, 64.0f); nvgTextAlign(s->vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BASELINE); @@ -729,7 +772,7 @@ static void ui_draw_vision(UIState *s) { nvgFillColor(s->vg, nvgRGBA(10, 10, 10, 220)); nvgFill(s->vg); - nvgFontSize(s->vg, 200.0f); + nvgFontSize(s->vg, 200.0f); nvgFillColor(s->vg, nvgRGBA(255, 0, 0, 255)); nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); nvgTextBox(s->vg, 100 + 50, 200 + 50, 1700 - 50, scene->alert_text1, From 2250eac58f004e5b6a301441d745e864d02059bd Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Sun, 11 Jun 2017 15:16:46 -0700 Subject: [PATCH 2/9] Remove commented line --- selfdrive/ui/ui.c | 1 - 1 file changed, 1 deletion(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 3084299aa8..839faccd06 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -748,7 +748,6 @@ static void ui_draw_vision(UIState *s) { (int)(scene->v_ego * 2.237 + 0.5)); } nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); - //nvgText(s->vg, 1920 - 500, 150, speed_str, NULL); nvgText(s->vg, 1920 - 500, 95, speed_str, NULL); /*nvgFontSize(s->vg, 64.0f); From 32fa49e09358c628a20e1b642d7a14fae2762d09 Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Sun, 11 Jun 2017 15:18:39 -0700 Subject: [PATCH 3/9] Clean up code --- selfdrive/ui/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 839faccd06..cfba4aae41 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -771,7 +771,7 @@ static void ui_draw_vision(UIState *s) { nvgFillColor(s->vg, nvgRGBA(10, 10, 10, 220)); nvgFill(s->vg); - nvgFontSize(s->vg, 200.0f); + nvgFontSize(s->vg, 200.0f); nvgFillColor(s->vg, nvgRGBA(255, 0, 0, 255)); nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); nvgTextBox(s->vg, 100 + 50, 200 + 50, 1700 - 50, scene->alert_text1, From ff7672339c797eae71e48a904e75a3110fe5e296 Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Mon, 12 Jun 2017 08:19:47 -0700 Subject: [PATCH 4/9] Add background to radar text. Code cleanup. --- selfdrive/ui/ui.c | 86 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 25 deletions(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index cfba4aae41..1fdbb71457 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -607,6 +607,34 @@ static void draw_frame(UIState *s) { glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, &frame_indicies[0]); } +/* + * Draw a rect at specific position with specific dimensions + */ +static void ui_draw_rounded_rect( + NVGcontext* c, + int x, + int y, + int width, + int height, + int radius, + NVGcolor color +) { + + int bottom_x = x + width; + int bottom_y = y + height; + + nvgBeginPath(c); + + // Position the rect + nvgRoundedRect(c, x, y, bottom_x, bottom_y, radius); + + // Color the rect + nvgFillColor(c, nvgRGBA(10, 10, 10, 150)); + + // Draw the rect + nvgFill(c); +} + // Draw all world space objects. static void ui_draw_world(UIState *s) { const UIScene *scene = &s->scene; @@ -614,6 +642,24 @@ static void ui_draw_world(UIState *s) { return; } + /****************************************** + * Add background rect so it's easier to see in + * light background scenes + ******************************************/ + // Draw background around speed text + + // Left side + ui_draw_rounded_rect(s->vg, -15, 0, 570, 180, 20, nvgRGBA(10,10,10,170)); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); + nvgStroke(s->vg); + + // Right side + ui_draw_rounded_rect(s->vg, 1920-530, 0, 150, 180, 20, nvgRGBA(10,10,10,170)); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); + nvgStroke(s->vg); + + /******************************************/ + draw_steering(s, scene->v_ego, scene->angle_steers); // draw paths @@ -630,6 +676,17 @@ static void ui_draw_world(UIState *s) { if (scene->lead_status) { char radar_str[16]; + + /****************************************** + * Add background rect so it's easier to see in + * light background scenes + ******************************************/ + // Draw background for radar text + ui_draw_rounded_rect(s->vg, 580, 0, 195, 180, 20, nvgRGBA(10,10,10,170)); + nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); + nvgStroke(s->vg); + /******************************************/ + if (s->is_metric) { int lead_v_rel = (int)(3.6 * scene->lead_v_rel); snprintf(radar_str, sizeof(radar_str), "%3d m %+d kph", @@ -642,7 +699,7 @@ static void ui_draw_world(UIState *s) { nvgFontSize(s->vg, 96.0f); nvgFillColor(s->vg, nvgRGBA(128, 128, 0, 192)); nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); - nvgText(s->vg, 1920 / 2, 150, radar_str, NULL); + nvgText(s->vg, 1920 / 2 - 20, 40, radar_str, NULL); // 2.7 m fudge factor draw_cross(s, scene->lead_d_rel + 2.7, scene->lead_y_rel, 15, @@ -680,31 +737,20 @@ static void ui_draw_vision(UIState *s) { float defaultfontsize = 128.0f; float labelfontsize = 65.0f; - /****************************************** - * Add background rect so it's easier to see in - * light background scenes - ******************************************/ - // Left side - ACC max speed - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, -15, 0, 535, 175, 30); - nvgFillColor(s->vg, nvgRGBA(10, 10, 10, 180)); - nvgFill(s->vg); - /******************************************/ - if (scene->engaged) { nvgFillColor(s->vg, nvgRGBA(255, 128, 0, 192)); // Add label nvgFontSize(s->vg, labelfontsize); nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); - nvgText(s->vg, 42, 175-30, "ACC: engaged", NULL); + nvgText(s->vg, 20, 175-30, "OpenPilot: On", NULL); } else { nvgFillColor(s->vg, nvgRGBA(195, 195, 195, 192)); // Add label nvgFontSize(s->vg, labelfontsize); nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); - nvgText(s->vg, 42, 175-30, "ACC: disabled", NULL); + nvgText(s->vg, 20, 175-30, "OpenPilot: Off", NULL); } nvgFontSize(s->vg, defaultfontsize); @@ -718,19 +764,9 @@ static void ui_draw_vision(UIState *s) { (int)(scene->v_cruise * 0.621371 + 0.5)); } nvgTextAlign(s->vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BASELINE); - nvgText(s->vg, 500, 95, speed_str, NULL); + nvgText(s->vg, 480, 95, speed_str, NULL); } - /****************************************** - * Add background rect so it's easier to see in - * light background scenes - ******************************************/ - // Right side - Actual speed - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, 1920 - 500, 0, 1920, 175, 20); - nvgFillColor(s->vg, nvgRGBA(10, 10, 10, 180)); - nvgFill(s->vg); - // Add label nvgFontSize(s->vg, labelfontsize); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 192)); From 57e39c4472dc1c1f2ed19eea906082598b87bffe Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Mon, 12 Jun 2017 08:27:57 -0700 Subject: [PATCH 5/9] Use color param in ui_draw_rounded_rect instead of hard coding --- selfdrive/ui/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 1fdbb71457..086d9e2fea 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -629,7 +629,7 @@ static void ui_draw_rounded_rect( nvgRoundedRect(c, x, y, bottom_x, bottom_y, radius); // Color the rect - nvgFillColor(c, nvgRGBA(10, 10, 10, 150)); + nvgFillColor(c, color); // Draw the rect nvgFill(c); From 3b909eb6936e97cd39ec15a79f444dec68223a0b Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Mon, 12 Jun 2017 08:41:11 -0700 Subject: [PATCH 6/9] More code cleanup --- selfdrive/ui/ui.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 086d9e2fea..f7511ee9e8 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -633,6 +633,10 @@ static void ui_draw_rounded_rect( // Draw the rect nvgFill(c); + + // Draw white border around rect + nvgStrokeColor(c, nvgRGBA(255,255,255,200)); + nvgStroke(c); } // Draw all world space objects. @@ -650,14 +654,9 @@ static void ui_draw_world(UIState *s) { // Left side ui_draw_rounded_rect(s->vg, -15, 0, 570, 180, 20, nvgRGBA(10,10,10,170)); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); - nvgStroke(s->vg); // Right side ui_draw_rounded_rect(s->vg, 1920-530, 0, 150, 180, 20, nvgRGBA(10,10,10,170)); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); - nvgStroke(s->vg); - /******************************************/ draw_steering(s, scene->v_ego, scene->angle_steers); @@ -683,8 +682,6 @@ static void ui_draw_world(UIState *s) { ******************************************/ // Draw background for radar text ui_draw_rounded_rect(s->vg, 580, 0, 195, 180, 20, nvgRGBA(10,10,10,170)); - nvgStrokeColor(s->vg, nvgRGBA(255,255,255,200)); - nvgStroke(s->vg); /******************************************/ if (s->is_metric) { From 8bc36b7f21cb388e5a6b924c3600be7694a27c75 Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Mon, 12 Jun 2017 09:03:49 -0700 Subject: [PATCH 7/9] Adjust position of left speed to align with label (based on 2 digit speeds) --- selfdrive/ui/ui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index f7511ee9e8..0a4a124f21 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -681,7 +681,7 @@ static void ui_draw_world(UIState *s) { * light background scenes ******************************************/ // Draw background for radar text - ui_draw_rounded_rect(s->vg, 580, 0, 195, 180, 20, nvgRGBA(10,10,10,170)); + ui_draw_rounded_rect(s->vg, 578, 0, 195, 180, 20, nvgRGBA(10,10,10,170)); /******************************************/ if (s->is_metric) { @@ -761,7 +761,7 @@ static void ui_draw_vision(UIState *s) { (int)(scene->v_cruise * 0.621371 + 0.5)); } nvgTextAlign(s->vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BASELINE); - nvgText(s->vg, 480, 95, speed_str, NULL); + nvgText(s->vg, 430, 95, speed_str, NULL); } // Add label From 5ec1e7307e3b6ff67ad22655bed4b0a40d73406f Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Mon, 12 Jun 2017 09:30:47 -0700 Subject: [PATCH 8/9] Revert last commit since KPH can get 3 digits long --- selfdrive/ui/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index 0a4a124f21..c0b129f33a 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -761,7 +761,7 @@ static void ui_draw_vision(UIState *s) { (int)(scene->v_cruise * 0.621371 + 0.5)); } nvgTextAlign(s->vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BASELINE); - nvgText(s->vg, 430, 95, speed_str, NULL); + nvgText(s->vg, 480, 95, speed_str, NULL); } // Add label From 26b573c1d0aad180867af13674743a59aadd0d9f Mon Sep 17 00:00:00 2001 From: Joey Lao Date: Mon, 12 Jun 2017 16:39:10 -0700 Subject: [PATCH 9/9] Make lead car text a little brighter --- selfdrive/ui/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index c0b129f33a..da676a8d91 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -694,7 +694,7 @@ static void ui_draw_world(UIState *s) { (int)(scene->lead_d_rel), lead_v_rel); } nvgFontSize(s->vg, 96.0f); - nvgFillColor(s->vg, nvgRGBA(128, 128, 0, 192)); + nvgFillColor(s->vg, nvgRGBA(200, 200, 0, 192)); nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); nvgText(s->vg, 1920 / 2 - 20, 40, radar_str, NULL);