Thinknode button and backlight fixes (#7641)

* Thinknode button and backlight fixes

* Save backlight value between reboots
This commit is contained in:
Jonathan Bennett 2025-08-15 14:41:21 -05:00 committed by GitHub
parent 8d5ae1d5d2
commit 4a241deb96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 31 additions and 19 deletions

View File

@ -61,8 +61,8 @@ monitor_filters = direct
lib_deps = lib_deps =
# renovate: datasource=git-refs depName=meshtastic-esp8266-oled-ssd1306 packageName=https://github.com/meshtastic/esp8266-oled-ssd1306 gitBranch=master # renovate: datasource=git-refs depName=meshtastic-esp8266-oled-ssd1306 packageName=https://github.com/meshtastic/esp8266-oled-ssd1306 gitBranch=master
https://github.com/meshtastic/esp8266-oled-ssd1306/archive/0119501e9983bd894830b02f545c377ee08d66fe.zip https://github.com/meshtastic/esp8266-oled-ssd1306/archive/0119501e9983bd894830b02f545c377ee08d66fe.zip
# renovate: datasource=custom.pio depName=OneButton packageName=mathertel/library/OneButton # renovate: datasource=git-refs depName=meshtastic-OneButton packageName=https://github.com/meshtastic/OneButton gitBranch=master
mathertel/OneButton@2.6.1 https://github.com/meshtastic/OneButton/archive/fa352d668c53f290cfa480a5f79ad422cd828c70.zip
# renovate: datasource=git-refs depName=meshtastic-arduino-fsm packageName=https://github.com/meshtastic/arduino-fsm gitBranch=master # renovate: datasource=git-refs depName=meshtastic-arduino-fsm packageName=https://github.com/meshtastic/arduino-fsm gitBranch=master
https://github.com/meshtastic/arduino-fsm/archive/7db3702bf0cfe97b783d6c72595e3f38e0b19159.zip https://github.com/meshtastic/arduino-fsm/archive/7db3702bf0cfe97b783d6c72595e3f38e0b19159.zip
# renovate: datasource=git-refs depName=meshtastic-TinyGPSPlus packageName=https://github.com/meshtastic/TinyGPSPlus gitBranch=master # renovate: datasource=git-refs depName=meshtastic-TinyGPSPlus packageName=https://github.com/meshtastic/TinyGPSPlus gitBranch=master

View File

@ -365,9 +365,6 @@ void Screen::doDeepSleep()
{ {
#ifdef USE_EINK #ifdef USE_EINK
setOn(false, graphics::UIRenderer::drawDeepSleepFrame); setOn(false, graphics::UIRenderer::drawDeepSleepFrame);
#ifdef PIN_EINK_EN
digitalWrite(PIN_EINK_EN, LOW); // power off backlight
#endif
#else #else
// Without E-Ink display: // Without E-Ink display:
setOn(false); setOn(false);
@ -391,7 +388,11 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
dispdev->displayOn(); dispdev->displayOn();
#endif #endif
#ifdef ELECROW_ThinkNode_M5 #ifdef PIN_EINK_EN
if (uiconfig.screen_brightness == 1)
digitalWrite(PIN_EINK_EN, HIGH);
#elif defined(PCA_PIN_EINK_EN)
if (uiconfig.screen_brightness == 1)
io.digitalWrite(PCA_PIN_EINK_EN, HIGH); io.digitalWrite(PCA_PIN_EINK_EN, HIGH);
#endif #endif
@ -424,13 +425,10 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
// eInkScreensaver parameter is usually NULL (default argument), default frame used instead // eInkScreensaver parameter is usually NULL (default argument), default frame used instead
setScreensaverFrames(einkScreensaver); setScreensaverFrames(einkScreensaver);
#endif #endif
#ifdef ELECROW_ThinkNode_M1
if (digitalRead(PIN_EINK_EN) == HIGH) {
digitalWrite(PIN_EINK_EN, LOW);
}
#endif
#ifdef ELECROW_ThinkNode_M5 #ifdef PIN_EINK_EN
digitalWrite(PIN_EINK_EN, LOW);
#elif defined(PCA_PIN_EINK_EN)
io.digitalWrite(PCA_PIN_EINK_EN, LOW); io.digitalWrite(PCA_PIN_EINK_EN, LOW);
#endif #endif

View File

@ -318,7 +318,7 @@ void menuHandler::homeBaseMenu()
static int optionsEnumArray[enumEnd] = {Back}; static int optionsEnumArray[enumEnd] = {Back};
int options = 1; int options = 1;
#ifdef PIN_EINK_EN #if defined(PIN_EINK_EN) || defined(PCA_PIN_EINK_EN)
optionsArray[options] = "Toggle Backlight"; optionsArray[options] = "Toggle Backlight";
optionsEnumArray[options++] = Backlight; optionsEnumArray[options++] = Backlight;
#else #else
@ -342,12 +342,24 @@ void menuHandler::homeBaseMenu()
bannerOptions.optionsCount = options; bannerOptions.optionsCount = options;
bannerOptions.bannerCallback = [](int selected) -> void { bannerOptions.bannerCallback = [](int selected) -> void {
if (selected == Backlight) { if (selected == Backlight) {
#ifdef PIN_EINK_EN #if defined(PIN_EINK_EN)
if (digitalRead(PIN_EINK_EN) == HIGH) { if (uiconfig.screen_brightness == 1) {
uiconfig.screen_brightness = 0;
digitalWrite(PIN_EINK_EN, LOW); digitalWrite(PIN_EINK_EN, LOW);
} else { } else {
uiconfig.screen_brightness = 1;
digitalWrite(PIN_EINK_EN, HIGH); digitalWrite(PIN_EINK_EN, HIGH);
} }
saveUIConfig();
#elif defined(PCA_PIN_EINK_EN)
if (uiconfig.screen_brightness == 1) {
uiconfig.screen_brightness = 0;
io.digitalWrite(PCA_PIN_EINK_EN, LOW);
} else {
uiconfig.screen_brightness = 1;
io.digitalWrite(PCA_PIN_EINK_EN, HIGH);
}
saveUIConfig();
#endif #endif
} else if (selected == Sleep) { } else if (selected == Sleep) {
screen->setOn(false); screen->setOn(false);

View File

@ -92,8 +92,11 @@ bool ButtonThread::initButton(const ButtonConfig &config)
if (config.shortLong != INPUT_BROKER_NONE) { if (config.shortLong != INPUT_BROKER_NONE) {
_shortLong = config.shortLong; _shortLong = config.shortLong;
} }
#ifdef USE_EINK
userButton.setDebounceMs(0);
#else
userButton.setDebounceMs(1); userButton.setDebounceMs(1);
#endif
userButton.setPressMs(_longPressTime); userButton.setPressMs(_longPressTime);
if (screen) { if (screen) {

View File

@ -304,7 +304,6 @@ void setup()
Wire.begin(48, 47); Wire.begin(48, 47);
io.pinMode(PCA_PIN_EINK_EN, OUTPUT); io.pinMode(PCA_PIN_EINK_EN, OUTPUT);
io.pinMode(PCA_PIN_POWER_EN, OUTPUT); io.pinMode(PCA_PIN_POWER_EN, OUTPUT);
io.digitalWrite(PCA_PIN_EINK_EN, HIGH);
io.digitalWrite(PCA_PIN_POWER_EN, HIGH); io.digitalWrite(PCA_PIN_POWER_EN, HIGH);
// io.pinMode(C2_PIN, OUTPUT); // io.pinMode(C2_PIN, OUTPUT);
#endif #endif

View File

@ -61,7 +61,7 @@
#define LORA_DIO1 SX126X_DIO1 #define LORA_DIO1 SX126X_DIO1
#define USE_EINK #define USE_EINK
#define PIN_EINK_EN -1 // Note: this is really just backlight power // Note: this is really just backlight power
#define PCA_PIN_EINK_EN 5 // This is the pin number on the GPIO expander #define PCA_PIN_EINK_EN 5 // This is the pin number on the GPIO expander
#define PIN_EINK_CS 39 #define PIN_EINK_CS 39
#define PIN_EINK_BUSY 42 #define PIN_EINK_BUSY 42