Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
}
}

#ifdef PIN_EINK_EN
uint32_t backlight_peek_time = 0;
#endif

void Screen::setup()
{

Expand Down Expand Up @@ -757,6 +761,18 @@ int32_t Screen::runOnce()
enabled = false;
return RUN_SAME;
}
#ifdef PIN_EINK_EN
#ifndef BACKLIGHT_TIMEOUT_MS
#define BACKLIGHT_TIMEOUT_MS 3000 // Turn off backlight after 3 seconds by default
#endif
// Turn off backlight after timeout
if (uiconfig.screen_brightness > 0 && backlight_peek_time != 0 &&
millis() - backlight_peek_time > BACKLIGHT_TIMEOUT_MS) {
digitalWrite(PIN_EINK_EN, LOW);
backlight_peek_time = 0;
uiconfig.screen_brightness = 0;
}
#endif

if (displayHeight == 0) {
displayHeight = dispdev->getHeight();
Expand Down Expand Up @@ -1771,6 +1787,16 @@ int Screen::handleInputEvent(const InputEvent *event)
showFrame(FrameDirection::PREVIOUS);
} else if (event->inputEvent == INPUT_BROKER_CANCEL) {
setOn(false);
#ifdef PIN_EINK_EN
} else if (event->inputEvent == INPUT_BROKER_BACKLIGHT) {
digitalWrite(PIN_EINK_EN, HIGH);
backlight_peek_time = millis();
uiconfig.screen_brightness = 1;
} else if (event->inputEvent == INPUT_BROKER_BACKLIGHT_TOGGLE) {
uiconfig.screen_brightness = 1 - uiconfig.screen_brightness;
digitalWrite(PIN_EINK_EN, uiconfig.screen_brightness == 0 ? LOW : HIGH);
backlight_peek_time = 0;
#endif
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/input/InputBroker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ enum input_broker_event {
INPUT_BROKER_RIGHT = 20,
INPUT_BROKER_CANCEL = 24,
INPUT_BROKER_BACK = 27,
INPUT_BROKER_BACKLIGHT = 28,
INPUT_BROKER_BACKLIGHT_TOGGLE = 29,
INPUT_BROKER_USER_PRESS,
INPUT_BROKER_ALT_PRESS,
INPUT_BROKER_ALT_LONG,
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,10 @@ void setup()
BaseType_t higherWake = 0;
mainDelay.interruptFromISR(&higherWake);
};
#if defined(TTGO_T_ECHO) && defined(PIN_EINK_EN)
touchConfig.singlePress = INPUT_BROKER_BACKLIGHT;
touchConfig.longPress = INPUT_BROKER_BACKLIGHT_TOGGLE;
#else
touchConfig.singlePress = INPUT_BROKER_NONE;
touchConfig.longPress = INPUT_BROKER_BACK;
#if defined(TTGO_T_ECHO_PLUS) && defined(PIN_EINK_EN)
Expand All @@ -1071,6 +1075,7 @@ void setup()
}
touchBacklightActive = false;
};
#endif
#endif
TouchButtonThread->initButton(touchConfig);
#endif
Expand Down