Skip to content

Commit

Permalink
Add screen lock mechanism for touch screens (M5 Core2). (#155)
Browse files Browse the repository at this point in the history
On PWR button double-click, lock or unlock the screen.
This is implemented as a modal message box that just blocks all touch
input.
  • Loading branch information
gkoh authored Jan 4, 2025
1 parent 9f16686 commit 817be37
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ During shutter control:
* press and hold 'Shutter Lock' to lock shutter open
* press and hold 'Shutter Lock' again to release

To activate screen lock:
* double click the PWR button
* a message box will open
* double click the PWR button to unlock

### Menu Map

* Connect (if connections are saved)
Expand Down
1 change: 1 addition & 0 deletions include/FurbleUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class UI {
lv_obj_t *batteryIcon;
lv_obj_t *reconnectIcon;
lv_obj_t *gpsData;
bool screenLocked;
} status_t;

class Intervalometer {
Expand Down
19 changes: 19 additions & 0 deletions src/FurbleUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ UI::UI(const interval_t &interval) : m_GPS {GPS::getInstance()}, m_Intervalomete
#else
m_Status.batteryIcon = addIcon(LV_SYMBOL_BATTERY_3);
#endif
m_Status.screenLocked = false;

m_GPS.setIcon(m_Status.gpsIcon);

Expand Down Expand Up @@ -193,6 +194,16 @@ UI::UI(const interval_t &interval) : m_GPS {GPS::getInstance()}, m_Intervalomete
} else {
lv_obj_add_flag(status->gpsIcon, LV_OBJ_FLAG_HIDDEN);
}

static lv_obj_t *lockMsgBox = NULL;
if (status->screenLocked && (lockMsgBox == NULL)) {
lockMsgBox = lv_msgbox_create(NULL);
lv_msgbox_add_title(lockMsgBox, "Screen Locked");
lv_msgbox_add_text(lockMsgBox, "Double-click PWR button to unlock.");
} else if (!status->screenLocked && (lockMsgBox != NULL)) {
lv_msgbox_close_async(lockMsgBox);
lockMsgBox = NULL;
}
},
250, &m_Status);

Expand Down Expand Up @@ -1780,6 +1791,14 @@ void UI::task(void) {
// fake PMIC button as actual button
m_PMICClicked = true;
}

// toggle screen lock on power button double click for touch screens
if (M5.Touch.isEnabled()) {
if (M5.BtnPWR.wasDoubleClicked()) {
m_Status.screenLocked = !m_Status.screenLocked;
}
}

m_Mutex.lock();
lv_task_handler();
m_Mutex.unlock();
Expand Down

0 comments on commit 817be37

Please sign in to comment.