diff --git a/common/apk.py b/common/apk.py index c04c19aa5f..2dfe838527 100644 --- a/common/apk.py +++ b/common/apk.py @@ -3,6 +3,7 @@ import subprocess import glob import hashlib import shutil +import threading from common.basedir import BASEDIR from selfdrive.swaglog import cloudlog @@ -27,8 +28,10 @@ def install_apk(path): return ret == 0 def start_offroad(): - set_package_permissions() - system("am start -n ai.comma.plus.offroad/.MainActivity") + def f(): + set_package_permissions() + system("am start -n ai.comma.plus.offroad/.MainActivity") + threading.Thread(target=f).start() def set_package_permissions(): pm_grant("ai.comma.plus.offroad", "android.permission.ACCESS_FINE_LOCATION") @@ -90,8 +93,10 @@ def update_apks(): assert success def pm_apply_packages(cmd): - for p in android_packages: - system("pm %s %s" % (cmd, p)) + def f(): + for p in android_packages: + system("pm %s %s" % (cmd, p)) + threading.Thread(target=f).start() if __name__ == "__main__": update_apks() diff --git a/selfdrive/assets/img_comma.png b/selfdrive/assets/img_comma.png new file mode 100644 index 0000000000..8716e47122 --- /dev/null +++ b/selfdrive/assets/img_comma.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc951a4f1e65bf2eab8cfb7e6c25a193520e6fe860bcca973fbc792a6b7a544d +size 11250 diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 881074d8f3..ad37caacad 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -18,12 +18,12 @@ extern "C"{ // TODO: this is also hardcoded in common/transformations/camera.py // TODO: choose based on frame input size -#ifdef QCOM2 -const mat3 intrinsic_matrix = (mat3){{ - 2648.0, 0.0, 1928.0/2, - 0.0, 2648.0, 1208.0/2, - 0.0, 0.0, 1.0 -}}; +#ifdef QCOM2 +const mat3 intrinsic_matrix = (mat3){{ + 2648.0, 0.0, 1928.0/2, + 0.0, 2648.0, 1208.0/2, + 0.0, 0.0, 1.0 +}}; #else const mat3 intrinsic_matrix = (mat3){{ 910., 0., 582., @@ -32,14 +32,6 @@ const mat3 intrinsic_matrix = (mat3){{ }}; #endif -const uint8_t alert_colors[][4] = { - [STATUS_OFFROAD] = {0x07, 0x23, 0x39, 0xf1}, - [STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xc8}, - [STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xf1}, - [STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xf1}, - [STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xf1}, -}; - // Projects a point in car to space to the corresponding point in full frame // image space. vec3 car_space_to_full_frame(const UIState *s, vec4 car_space_projective) { @@ -233,13 +225,13 @@ static void ui_draw_track(UIState *s, bool is_mpc, track_vertices_data *pvd) { NVGpaint track_bg; if (is_mpc) { // Draw colored MPC track - const Color clr = bg_colors[s->status]; + const NVGcolor clr = bg_colors[s->status]; track_bg = nvgLinearGradient(s->vg, s->fb_w, s->fb_h, s->fb_w, s->fb_h*.4, - nvgRGBA(clr.r, clr.g, clr.b, 255), nvgRGBA(clr.r, clr.g, clr.b, 255/2)); + nvgRGBA(clr.r, clr.g, clr.b, 255), nvgRGBA(clr.r, clr.g, clr.b, 255/2)); } else { // Draw white vision track track_bg = nvgLinearGradient(s->vg, s->fb_w, s->fb_h, s->fb_w, s->fb_h*.4, - COLOR_WHITE, COLOR_WHITE_ALPHA(0)); + COLOR_WHITE, COLOR_WHITE_ALPHA(0)); } nvgFillPaint(s->vg, track_bg); nvgFill(s->vg); @@ -443,23 +435,14 @@ static void ui_draw_vision_event(UIState *s) { // draw winding road sign const int img_turn_size = 160*1.5; ui_draw_image(s->vg, viz_event_x - (img_turn_size / 4), viz_event_y + bdr_s - 25, img_turn_size, img_turn_size, s->img_turn, 1.0f); - } else { + } else if (s->scene.controls_state.getEngageable()) { // draw steering wheel const int bg_wheel_size = 96; const int bg_wheel_x = viz_event_x + (viz_event_w-bg_wheel_size); const int bg_wheel_y = viz_event_y + (bg_wheel_size/2); - NVGcolor color = COLOR_BLACK_ALPHA(0); - if (s->status == STATUS_ENGAGED) { - color = nvgRGBA(23, 134, 68, 255); - } else if (s->status == STATUS_WARNING) { - color = COLOR_OCHRE; - } else { - color = nvgRGBA(23, 51, 73, 255); - } + const NVGcolor color = bg_colors[s->status]; - if (s->scene.controls_state.getEngageable()){ - ui_draw_circle_image(s->vg, bg_wheel_x, bg_wheel_y, bg_wheel_size, s->img_wheel, color, 1.0f, bg_wheel_y - 25); - } + ui_draw_circle_image(s->vg, bg_wheel_x, bg_wheel_y, bg_wheel_size, s->img_wheel, color, 1.0f, bg_wheel_y - 25); } } @@ -541,7 +524,7 @@ static void ui_draw_vision_footer(UIState *s) { ui_draw_vision_face(s); } -void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, int va_color, +void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, UIStatus va_color, const char* va_text1, const char* va_text2) { static std::map alert_size_map = { {cereal::ControlsState::AlertSize::NONE, 0}, @@ -552,7 +535,8 @@ void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, const UIScene *scene = &s->scene; bool longAlert1 = strlen(va_text1) > 15; - const uint8_t *color = alert_colors[va_color]; + NVGcolor color = bg_colors[va_color]; + color.a *= s->alert_blinking_alpha; int alr_s = alert_size_map[va_size]; const int alr_x = scene->viz_rect.x - bdr_s; @@ -560,10 +544,10 @@ void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, const int alr_h = alr_s+(va_size==cereal::ControlsState::AlertSize::NONE?0:bdr_s); const int alr_y = s->fb_h-alr_h; - ui_draw_rect(s->vg, alr_x, alr_y, alr_w, alr_h, nvgRGBA(color[0],color[1],color[2],(color[3]*s->alert_blinking_alpha))); + ui_draw_rect(s->vg, alr_x, alr_y, alr_w, alr_h, color); NVGpaint gradient = nvgLinearGradient(s->vg, alr_x, alr_y, alr_x, alr_y+alr_h, - nvgRGBAf(0.0,0.0,0.0,0.05), nvgRGBAf(0.0,0.0,0.0,0.35)); + nvgRGBAf(0.0,0.0,0.0,0.05), nvgRGBAf(0.0,0.0,0.0,0.35)); ui_draw_rect(s->vg, alr_x, alr_y, alr_w, alr_h, gradient); nvgFillColor(s->vg, COLOR_WHITE); @@ -589,6 +573,7 @@ void ui_draw_vision_alert(UIState *s, cereal::ControlsState::AlertSize va_size, static void ui_draw_vision(UIState *s) { const UIScene *scene = &s->scene; const Rect &viz_rect = scene->viz_rect; + // Draw video frames glEnable(GL_SCISSOR_TEST); glViewport(viz_rect.x+scene->ui_viz_ro, viz_rect.y, s->fb_w - bdr_s*2, viz_rect.h); @@ -618,8 +603,8 @@ static void ui_draw_vision(UIState *s) { } static void ui_draw_background(UIState *s) { - const Color color = bg_colors[s->status]; - glClearColor(color.r/256.0, color.g/256.0, color.b/256.0, 1.0); + const NVGcolor color = bg_colors[s->status]; + glClearColor(color.r, color.g, color.b, 1.0); glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } @@ -656,7 +641,7 @@ void ui_draw_image(NVGcontext *vg, float x, float y, float w, float h, int image void ui_draw_rect(NVGcontext *vg, float x, float y, float w, float h, NVGcolor color, float r, int width) { nvgBeginPath(vg); - r > 0? nvgRoundedRect(vg, x, y, w, h, r) : nvgRect(vg, x, y, w, h); + r > 0 ? nvgRoundedRect(vg, x, y, w, h, r) : nvgRect(vg, x, y, w, h); if (width) { nvgStrokeColor(vg, color); nvgStrokeWidth(vg, width); diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index a9016dd61e..f09748d0ef 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -33,7 +33,6 @@ #define COLOR_WHITE_ALPHA(x) nvgRGBA(255, 255, 255, x) #define COLOR_YELLOW nvgRGBA(218, 202, 37, 255) #define COLOR_RED nvgRGBA(201, 34, 49, 255) -#define COLOR_OCHRE nvgRGBA(218, 111, 37, 255) #define UI_BUF_COUNT 4 @@ -62,10 +61,6 @@ const int TRACK_POINTS_MAX_CNT = 50 * 2; const int SET_SPEED_NA = 255; -typedef struct Color { - uint8_t r, g, b; -} Color; - typedef enum NetStatus { NET_CONNECTED, NET_DISCONNECTED, @@ -80,12 +75,12 @@ typedef enum UIStatus { STATUS_ALERT, } UIStatus; -static std::map bg_colors = { - {STATUS_OFFROAD, {0x07, 0x23, 0x39}}, - {STATUS_DISENGAGED, {0x17, 0x33, 0x49}}, - {STATUS_ENGAGED, {0x17, 0x86, 0x44}}, - {STATUS_WARNING, {0xDA, 0x6F, 0x25}}, - {STATUS_ALERT, {0xC9, 0x22, 0x31}}, +static std::map bg_colors = { + {STATUS_OFFROAD, nvgRGBA(0x07, 0x23, 0x39, 0xf1)}, + {STATUS_DISENGAGED, nvgRGBA(0x17, 0x33, 0x49, 0xc8)}, + {STATUS_ENGAGED, nvgRGBA(0x17, 0x86, 0x44, 0xf1)}, + {STATUS_WARNING, nvgRGBA(0xDA, 0x6F, 0x25, 0xf1)}, + {STATUS_ALERT, nvgRGBA(0xC9, 0x22, 0x31, 0xf1)}, }; typedef struct UIScene {