Merge branch 'testing' into feature-dynamic-follow

This commit is contained in:
dragonpilot
2020-03-16 14:53:30 +10:00
8 changed files with 49 additions and 38 deletions
+1
View File
@@ -172,6 +172,7 @@ keys = {
"DragonBootHotspot": [TxType.PERSISTENT],
"DragonAccelProfile": [TxType.PERSISTENT],
"DragonLastModified": [TxType.PERSISTENT],
"DragonEnableRegistration": [TxType.PERSISTENT],
"DragonDynamicFollow": [TxType.PERSISTENT],
}
-14
View File
@@ -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")
@@ -70,6 +70,7 @@ default_conf = {
'DragonBootHotspot': 0,
'DragonAccelProfile': '0',
'DragonLastModified': str(floor(time.time())),
'DragonEnableRegistration': '1',
'DragonDynamicFollow': '0', # traffic = -1, stock = 0, roadtrip = 1
}
+3 -1
View File
@@ -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()
+10 -8
View File
@@ -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:
+20 -8
View File
@@ -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);
@@ -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);
+13 -7
View File
@@ -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);
}
@@ -983,13 +984,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) {
+1
View File
@@ -166,6 +166,7 @@ typedef struct UIScene {
// for blinker, from kegman
bool leftBlinker;
bool rightBlinker;
bool brakeLights;
int blinker_blinkingrate;
} UIScene;