From 0a74eef8bf068b74c02c3dbac5b23e9f601b674a Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Sun, 15 Mar 2020 20:32:12 +1000 Subject: [PATCH 1/6] update charging ctrl logic --- selfdrive/thermald/thermald.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 2f258cca6..3c760072b 100644 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -204,6 +204,7 @@ def thermald_thread(): ip_addr = '255.255.255.255' dragon_charging_ctrl = False + dragon_charging_ctrl_prev = False dragon_to_discharge = 70 dragon_to_charge = 60 @@ -440,17 +441,18 @@ def thermald_thread(): dp_last_modified = modified ts_last_update_vars = ts - # we update charging status once every min - if ts_last_charging_ctrl is None or ts - ts_last_charging_ctrl >= 60.: - if dragon_charging_ctrl: + if dragon_charging_ctrl != dragon_charging_ctrl_prev: + set_battery_charging(True) + + if dragon_charging_ctrl: + if ts_last_charging_ctrl is None or ts - ts_last_charging_ctrl >= 60.: if msg.thermal.batteryPercent >= dragon_to_discharge and get_battery_charging(): set_battery_charging(False) - if msg.thermal.batteryPercent <= dragon_to_charge and not get_battery_charging(): + elif msg.thermal.batteryPercent <= dragon_to_charge and not get_battery_charging(): set_battery_charging(True) - else: - if not get_battery_charging(): - set_battery_charging(True) - ts_last_charging_ctrl = ts + ts_last_charging_ctrl = ts + + dragon_charging_ctrl_prev = dragon_charging_ctrl # report to server once per minute if (count % int(60. / DT_TRML)) == 0: From 953cfdb17ccd898da2255c90953a1d04da7ef09e Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Mon, 16 Mar 2020 12:16:25 +1000 Subject: [PATCH 2/6] appd do not need to re-enable offroad in waze mode any more. --- selfdrive/dragonpilot/appd/appd.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/selfdrive/dragonpilot/appd/appd.py b/selfdrive/dragonpilot/appd/appd.py index 8da5ff928..3e9900c95 100644 --- a/selfdrive/dragonpilot/appd/appd.py +++ b/selfdrive/dragonpilot/appd/appd.py @@ -20,10 +20,6 @@ class App(): TYPE_FULLSCREEN = 3 TYPE_UTIL = 4 - # offroad app - OFFROAD = "ai.comma.plus.offroad" - OFFROAD_MAIN = ".MainActivity" - # manual switch stats MANUAL_OFF = "-1" MANUAL_IDLE = "0" @@ -54,7 +50,6 @@ class App(): # read manual run param self.manual_ctrl_param = manual_ctrl_param # if it's a service app, we do not kill if device is too hot - # if it's a full screen app, we need to do extra process on offroad self.app_type = app_type # app permissions self.permissions = permissions @@ -113,10 +108,6 @@ class App(): # only run app if it's not running if force or not self.is_running: - # if it's a full screen app, we need to stop frame and offroad to get keyboard access - if self.app_type == self.TYPE_FULLSCREEN: - self.system("am start -n %s/%s" % (self.OFFROAD, self.OFFROAD_MAIN)) - self.system("pm enable %s" % self.app) if self.app_type == self.TYPE_GPS_SERVICE: @@ -138,11 +129,6 @@ class App(): # only kill app if it's running if force or self.is_running: - # if it's a full screen app, we need to restart offroad - if self.app_type == self.TYPE_FULLSCREEN: - self.system("pm disable %s" % self.OFFROAD) - self.system("pm enable %s" % self.OFFROAD) - if self.app_type == self.TYPE_GPS_SERVICE: self.appops_set(self.app, "android:mock_location", "deny") From 436efa2df8e50f2cffb8a2f9a69fc705134d6bba Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Mon, 16 Mar 2020 12:17:06 +1000 Subject: [PATCH 3/6] do not allow sidebar while in waze mode. --- selfdrive/ui/ui.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 3c0a7c50d..79b51be0a 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -983,13 +983,18 @@ int main(int argc, char* argv[]) { s->scene.ui_viz_rw = hasSidebar ? box_w : (box_w + sbr_w - (bdr_s * 2)); s->scene.ui_viz_ro = hasSidebar ? -(sbr_w - 6 * bdr_s) : 0; - // poll for touch events - int touch_x = -1, touch_y = -1; - int touched = touch_poll(&touch, &touch_x, &touch_y, 0); - if (touched == 1) { - set_awake(s, true); - handle_sidebar_touch(s, touch_x, touch_y); - handle_vision_touch(s, touch_x, touch_y); + if (s->vision_connected && s->dragon_waze_mode) { + // always collapsed sidebar when vision is connect and in waze mode + s->scene.uilayout_sidebarcollapsed = true; + } else { + // poll for touch events + int touch_x = -1, touch_y = -1; + int touched = touch_poll(&touch, &touch_x, &touch_y, 0); + if (touched == 1) { + set_awake(s, true); + handle_sidebar_touch(s, touch_x, touch_y); + handle_vision_touch(s, touch_x, touch_y); + } } if (!s->vision_connected) { From a675cff11b6966454bd0a98c27ee0e6a5b1bf532 Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Mon, 16 Mar 2020 12:17:48 +1000 Subject: [PATCH 4/6] add temp/batt back to mini dev ui --- selfdrive/ui/paint.cc | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index f9ea29d15..3b9957eba 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -838,11 +838,19 @@ static void ui_draw_infobar(UIState *s) { char infobar[100]; // create time string - char date_time[20]; + char date_time[17]; time_t rawtime = time(NULL); struct tm timeinfo; localtime_r(&rawtime, &timeinfo); - strftime(date_time, sizeof(date_time),"%F %T", &timeinfo); + strftime(date_time, sizeof(date_time),"%D %T", &timeinfo); + + // Create temp string + char temp[6]; + snprintf(temp, sizeof(temp), "%02d°C", s->scene.paTemp); + + // create battery percentage string + char battery[4]; + snprintf(battery, sizeof(battery), "%02d%%", s->scene.batteryPercent); if (s->dragon_ui_dev_mini) { char rel_steer[9]; @@ -865,8 +873,10 @@ static void ui_draw_infobar(UIState *s) { snprintf( infobar, sizeof(infobar), - "%s /REL: %s /DES: %s /DIS: %s", + "%s /TMP: %s /BAT: %s /REL: %s /DES: %s /DIS: %s", date_time, + temp, + battery, rel_steer, des_steer, lead_dist @@ -875,17 +885,19 @@ static void ui_draw_infobar(UIState *s) { snprintf( infobar, sizeof(infobar), - "%s", - date_time + "%s /TMP: %s /BAT: %s", + date_time, + temp, + battery ); } nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, rect_x, rect_y, rect_w, rect_h, 15); + nvgRect(s->vg, rect_x, rect_y, rect_w, rect_h); nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 180)); nvgFill(s->vg); - nvgFontSize(s->vg, hasSidebar? 43:50); + nvgFontSize(s->vg, hasSidebar? 35:42); nvgFontFace(s->vg, "courbd"); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 180)); nvgTextAlign(s->vg, NVG_ALIGN_CENTER); From d1bfc252f36fcc44bd3bc44b19e1c53a72e8090c Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Mon, 16 Mar 2020 13:51:49 +1000 Subject: [PATCH 5/6] * ability to disable registration (for some phones that does not have proper IMEI) --- common/params.py | 1 + selfdrive/dragonpilot/dragonconf/__init__.py | 1 + selfdrive/manager.py | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/params.py b/common/params.py index 0f299010a..2e02beba8 100755 --- a/common/params.py +++ b/common/params.py @@ -172,6 +172,7 @@ keys = { "DragonBootHotspot": [TxType.PERSISTENT], "DragonAccelProfile": [TxType.PERSISTENT], "DragonLastModified": [TxType.PERSISTENT], + "DragonEnableRegistration": [TxType.PERSISTENT], } diff --git a/selfdrive/dragonpilot/dragonconf/__init__.py b/selfdrive/dragonpilot/dragonconf/__init__.py index c440cfb55..d8565d91b 100644 --- a/selfdrive/dragonpilot/dragonconf/__init__.py +++ b/selfdrive/dragonpilot/dragonconf/__init__.py @@ -70,6 +70,7 @@ default_conf = { 'DragonBootHotspot': 0, 'DragonAccelProfile': '0', 'DragonLastModified': str(floor(time.time())), + 'DragonEnableRegistration': '1', } deprecated_conf = { diff --git a/selfdrive/manager.py b/selfdrive/manager.py index 041478acc..7c4fbc0b5 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -544,9 +544,11 @@ def main(): if params.get("Passive") is None: raise Exception("Passive must be set to continue") + reg = False if params.get("DragonEnableRegistration", encoding='utf8') == "0" else True + if ANDROID: update_apks() - manager_init() + manager_init(reg) manager_prepare(spinner) spinner.close() From 4df20acf6575b6a0a57145701e60684b80e6a064 Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Mon, 16 Mar 2020 13:52:48 +1000 Subject: [PATCH 6/6] * turn speed (text) to yellow when braking. --- selfdrive/ui/paint.cc | 2 +- selfdrive/ui/ui.cc | 1 + selfdrive/ui/ui.hpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 3b9957eba..a22f18705 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -671,7 +671,7 @@ static void ui_draw_vision_speed(UIState *s) { nvgFontFace(s->vg, "sans-regular"); nvgFontSize(s->vg, 36*2.5); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 200)); + nvgFillColor(s->vg, s->scene.brakeLights? COLOR_YELLOW : nvgRGBA(255, 255, 255, 200)); if (s->is_metric) { nvgText(s->vg, viz_speed_x+viz_speed_w/2, 320, "kph", NULL); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 79b51be0a..4fb9376ad 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -548,6 +548,7 @@ void handle_message(UIState *s, Message * msg) { } s->scene.leftBlinker = datad.leftBlinker; s->scene.rightBlinker = datad.rightBlinker; + s->scene.brakeLights = datad.brakeLights; } capn_free(&ctx); } diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index 384f469c2..c4986b687 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -166,6 +166,7 @@ typedef struct UIScene { // for blinker, from kegman bool leftBlinker; bool rightBlinker; + bool brakeLights; int blinker_blinkingrate; } UIScene;