Skip to content

Commit

Permalink
ui: Screen Recorder toggle display (commaai#207)
Browse files Browse the repository at this point in the history
* ui: Screen Recorder toggle display

* not needed

* duplicate

* Update CHANGELOGS.md
  • Loading branch information
sunnyhaibin authored Jul 9, 2023
1 parent f269e79 commit d435920
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ sunnypilot - 0.9.3.1 (2023-07-xx)
* This is only applicable to HKG CAN platforms using openpilot longitudinal control
* NEW❗: Toyota: TSS2 longitudinal: Custom Tuning
* Smoother longitudinal performance for Toyota/Lexus TSS2/LSS2 cars thanks to dragonpilot-community!
* NEW❗: Enable Screen Recorder toggle
* Enable this will display a button on the onroad screen to toggle on or off real-time screen recording with UI elements.
* IMPROVED: Dynamic Lane Profile: when using Laneline planner via Laneline Mode or Auto Mode, enforce Laneless planner while traveling below 10 MPH or 16 km/h
* REMOVED: Display CPU Temperature on Sidebar

Expand Down
6 changes: 6 additions & 0 deletions selfdrive/ui/qt/offroad/sunnypilot_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ SPGeneralPanel::SPGeneralPanel(QWidget *parent) : ListWidget(parent) {
.arg(tr("Disabled: Wake the brightness of the screen to display critical events.")),
"../assets/offroad/icon_blank.png",
},
{
"ScreenRecorder",
tr("Enable Screen Recorder"),
tr("Enable this will display a button on the onroad screen to toggle on or off real-time screen recording with UI elements."),
"../assets/offroad/icon_calibration.png"
},
{
"DisableOnroadUploads",
tr("Disable Onroad Uploads"),
Expand Down
4 changes: 4 additions & 0 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {

setProperty("e2eStatus", chime_prompt);
setProperty("e2eState", e2eLStatus);

#ifdef ENABLE_DASHCAM
recorder->updateState(s);
#endif
}

void AnnotatedCameraWidget::drawHud(QPainter &p) {
Expand Down
6 changes: 6 additions & 0 deletions selfdrive/ui/qt/screenrecorder/screenrecorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ScreenRecoder::ScreenRecoder(QWidget *parent) : QPushButton(parent), image_queue
started = 0;
frame = 0;

setVisible(false);
setFixedSize(btn_size, btn_size);
setFocusPolicy(Qt::NoFocus);
connect(this, SIGNAL(pressed()),this,SLOT(btnPressed()));
Expand Down Expand Up @@ -176,3 +177,8 @@ void ScreenRecoder::update_screen() {

frame++;
}

void ScreenRecoder::updateState(const UIState &s) {
bool show_toggle = params.getBool("ScreenRecorder") || recording;
setVisible(show_toggle);
}
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/screenrecorder/screenrecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public slots:
void paintEvent(QPaintEvent*) override;

private:
Params params;
bool recording;
long long started;
int src_width, src_height;
Expand All @@ -53,4 +54,5 @@ public slots:
void stop();
void toggle();
void update_screen();
void updateState(const UIState &s);
};

0 comments on commit d435920

Please sign in to comment.