add rec screen button

This commit is contained in:
toyboxZ
2021-01-02 23:03:48 +08:00
parent 4bf7baabe6
commit e55185a7bb
10 changed files with 58 additions and 12 deletions
+2 -2
View File
@@ -2160,7 +2160,7 @@ struct DragonConf {
dpAppHr @6 :Bool;
dpAppHrManual @7 :Int8;
dpDashcam @8 :Bool;
dpDashcamHoursStored @9 :UInt8;
dpDashcamUi @9 :Bool;
dpAutoShutdown @10 :Bool;
dpAthenad @11 :Bool;
dpUploader @12 :Bool;
@@ -2226,4 +2226,4 @@ struct DragonConf {
dpDischargingAt @72 :UInt8;
dpIsUpdating @73 :Bool;
dpTimebombAssist @74 :Bool;
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ confs = [
{'name': 'dp_app_hr_manual', 'default': 0, 'type': 'Int8', 'min': -1, 'max': 1, 'depends': [{'name': 'dp_app_hr', 'vals': [True]}], 'conf_type': ['param', 'struct']},
# dashcam related
{'name': 'dp_dashcam', 'default': 0, 'type': 'Bool', 'conf_type': ['param', 'struct']},
{'name': 'dp_dashcam_hours_stored', 'default': 24, 'type': 'UInt8', 'min': 1, 'max': 255, 'depends': [{'name': 'dp_dashcam', 'vals': [True]}], 'conf_type': ['param', 'struct']},
{'name': 'dp_dashcam_ui', 'default': 0, 'type': 'Bool', 'conf_type': ['param', 'struct']},
# auto shutdown
{'name': 'dp_auto_shutdown', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']},
{'name': 'dp_auto_shutdown_in', 'default': 90, 'type': 'UInt16', 'min': 1, 'max': 65535, 'depends': [{'name': 'dp_auto_shutdown', 'vals': [True]}], 'conf_type': ['param']},
+4
View File
@@ -28,6 +28,10 @@ class Dashcam():
self.record()
self.clean_up()
def stop(self):
os.system("killall -SIGINT screenrecord")
self.dashcam_next_time = 0
def make_folder(self):
if not self.dashcam_folder_exists and self.dashcam_mkdir_retry <= 5:
# create dashcam folder if not exist
+5
View File
@@ -42,6 +42,7 @@ def confd_thread():
last_charging_ctrl = False
last_started = False
dashcam = Dashcam()
last_dashcam_recorded = False
while True:
start_sec = sec_since_boot()
@@ -147,6 +148,10 @@ def confd_thread():
'''
if msg.dragonConf.dpDashcam and frame % HERTZ == 0:
dashcam.run(started, free_space)
last_dashcam_recorded = True
if last_dashcam_recorded and not msg.dragonConf.dpDashcam:
dashcam.stop()
last_dashcam_recorded = False
'''
===================================================
finalise
+15 -7
View File
@@ -70,6 +70,7 @@ static void handle_display_state(UIState *s, bool user_input) {
}
static bool handle_dp_btn_touch(UIState *s, int touch_x, int touch_y) {
bool update_dp_last_modified = false ;
//dfButton manager // code below thanks to kumar: https://github.com/arne182/openpilot/commit/71d5aac9f8a3f5942e89634b20cbabf3e19e3e78
if (s->started && s->active_app != cereal::UiLayoutState::App::SETTINGS) {
if (s->scene.dpDynamicFollow > 0 && touch_x >= df_btn_x && touch_x <= (df_btn_x + df_btn_w) && touch_y >= df_btn_y && touch_y <= (df_btn_y + df_btn_h)) {
@@ -82,11 +83,8 @@ static bool handle_dp_btn_touch(UIState *s, int touch_x, int touch_y) {
char str[2] = {0};
sprintf(str, "%d", val);
Params().write_db_value("dp_dynamic_follow", str, 1);
char time_str[11];
snprintf(time_str, 11, "%lu", time(NULL));
Params().write_db_value("dp_last_modified", time_str, 11);
return true;
update_dp_last_modified = true;
} else if (s->scene.dpAccelProfile > 0 && touch_x >= ap_btn_x && touch_x <= (ap_btn_x + ap_btn_w) && touch_y >= ap_btn_y && touch_y <= (ap_btn_y + ap_btn_h)) {
int val = s->scene.dpAccelProfile;
val++;
@@ -97,13 +95,23 @@ static bool handle_dp_btn_touch(UIState *s, int touch_x, int touch_y) {
char str[2] = {0};
sprintf(str, "%d", val);
Params().write_db_value("dp_accel_profile", str, 1);
update_dp_last_modified = true;
} else if (s->scene.dpDashcamUi && touch_x >= rec_btn_x && touch_x <= (rec_btn_x + rec_btn_w) && touch_y >= rec_btn_y && touch_y <= (rec_btn_y + rec_btn_h)) {
char str[2] = {0};
sprintf(str, "%d", !s->scene.dpDashcam);
Params().write_db_value("dp_dashcam", str, 1);
update_dp_last_modified = true;
}
}
if ( update_dp_last_modified ) {
char time_str[11];
snprintf(time_str, 11, "%lu", time(NULL));
Params().write_db_value("dp_last_modified", time_str, 11);
return true;
}
}
return false;
}
+3
View File
@@ -498,6 +498,9 @@ static void ui_draw_vision_footer(UIState *s) {
} else {
ui_draw_blindspots(s, false);
}
if (s->scene.dpDashcamUi) {
ui_draw_rec_button(s);
}
}
static void ui_draw_vision_alert(UIState *s) {
+19 -1
View File
@@ -362,4 +362,22 @@ void ui_draw_bbui(UIState *s) {
bb_ui_draw_measures_right(s, bb_dml_x, bb_dml_y, bb_dml_w);
bb_ui_draw_measures_left(s, bb_dmr_x, bb_dmr_y, bb_dmr_w);
}
}
void ui_draw_rec_button(UIState *s) {
nvgBeginPath(s->vg);
nvgRoundedRect(s->vg, rec_btn_x, rec_btn_y, rec_btn_w, rec_btn_h, 20);
nvgStrokeColor(s->vg, COLOR_WHITE_ALPHA(80));
nvgStrokeWidth(s->vg, 6);
nvgStroke(s->vg);
nvgFontSize(s->vg, 80);
if (s->scene.dpDashcam) {
nvgFillColor(s->vg, nvgRGBA(255,0,0,255));
}
else {
nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255));
}
nvgTextAlign(s->vg, NVG_ALIGN_CENTER);
nvgText(s->vg, rec_btn_x + rec_btn_w / 2, rec_btn_y + (rec_btn_h / 2)+20,"REC",NULL);
}
+2 -1
View File
@@ -3,6 +3,7 @@
void ui_draw_df_button(UIState *s);
void ui_draw_ap_button(UIState *s);
void ui_draw_rec_button(UIState *s);
void ui_draw_infobar(UIState *s);
void ui_draw_blindspots(UIState *s, bool hasInfobar);
void ui_draw_bbui(UIState *s);
void ui_draw_bbui(UIState *s);
+1
View File
@@ -245,6 +245,7 @@ void update_sockets(UIState *s) {
if (sm.updated("dragonConf")) {
auto data = sm["dragonConf"].getDragonConf();
scene.dpDashcam = data.getDpDashcam();
scene.dpDashcamUi = data.getDpDashcamUi();
scene.dpFullScreenApp = data.getDpAppWaze() || data.getDpAppHr();
scene.dpDrivingUi = data.getDpDrivingUi();
scene.dpUiScreenOffReversing = data.getDpUiScreenOffReversing();
+6
View File
@@ -71,6 +71,11 @@ const int ap_btn_w = 180;
const int ap_btn_x = 1450;
const int ap_btn_y = 750;
const int info_bar_h = 80;
// dp - rec btn
const int rec_btn_h = 130;
const int rec_btn_w = 180;
const int rec_btn_x = 870;
const int rec_btn_y = 800;
typedef enum NetStatus {
NET_CONNECTED,
@@ -140,6 +145,7 @@ typedef struct UIScene {
// dp
bool dpDashcam;
bool dpDashcamUi;
bool dpFullScreenApp;
bool dpDrivingUi;
bool dpUiScreenOffReversing;