Skip to content

Commit 3cdf2f9

Browse files
committed
techo: display backlight behavior
1 parent 1a41da6 commit 3cdf2f9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,14 @@ void UITask::loop() {
519519
c = handleLongPress(KEY_ENTER);
520520
}
521521
#endif
522+
#if defined(DISP_BACKLIGHT) && defined(BACKLIGHT_BTN)
523+
static int next_btn_check = 0;
524+
if (millis() > next_btn_check) {
525+
bool touch_state = digitalRead(PIN_BUTTON2);
526+
digitalWrite(DISP_BACKLIGHT, !touch_state);
527+
next_btn_check = millis() + 300;
528+
}
529+
#endif
522530

523531
if (c != 0 && curr) {
524532
curr->handleInput(c);

src/helpers/ui/GxEPDDisplay.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ bool GxEPDDisplay::begin() {
1919
display.fillScreen(GxEPD_WHITE);
2020
display.display(true);
2121
#if DISP_BACKLIGHT
22+
digitalWrite(DISP_BACKLIGHT, LOW);
2223
pinMode(DISP_BACKLIGHT, OUTPUT);
2324
#endif
2425
_init = true;
@@ -27,14 +28,14 @@ bool GxEPDDisplay::begin() {
2728

2829
void GxEPDDisplay::turnOn() {
2930
if (!_init) begin();
30-
#if DISP_BACKLIGHT
31+
#if defined(DISP_BACKLIGHT) && !defined(BACLIGHT_BTN)
3132
digitalWrite(DISP_BACKLIGHT, HIGH);
3233
#endif
3334
_isOn = true;
3435
}
3536

3637
void GxEPDDisplay::turnOff() {
37-
#if DISP_BACKLIGHT
38+
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
3839
digitalWrite(DISP_BACKLIGHT, LOW);
3940
#endif
4041
_isOn = false;

variants/techo/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ build_flags =
7878
-D DISPLAY_CLASS=GxEPDDisplay
7979
-D OFFLINE_QUEUE_SIZE=256
8080
-D UI_RECENT_LIST_SIZE=9
81+
-D BACKLIGHT_BTN=PIN_BUTTON2
8182
; -D MESH_PACKET_LOGGING=1
8283
; -D MESH_DEBUG=1
8384
build_src_filter = ${LilyGo_Techo.build_src_filter}

0 commit comments

Comments
 (0)