Sleep: drive and hold the 20 RGB panel lines low before deep sleep (white flickering edges seen on the bench)
Firmware / build (push) Successful in 7m7s

This commit is contained in:
2026-09-28 16:53:16 +02:00
parent 803af7568f
commit 59fae2c219
2 changed files with 26 additions and 1 deletions
+22 -1
View File
@@ -15,6 +15,7 @@
#include <lvgl.h>
#include <esp_sleep.h>
#include <driver/rtc_io.h>
#include <driver/gpio.h>
namespace PowerManager {
@@ -78,12 +79,32 @@ static const char* blocker() {
return NULL;
}
// The RGB panel's 20 signal lines (Waveshare 5B board header). In deep sleep the
// LCD peripheral stops and these pins would float: a panel with no clock and
// floating data shows white/flickering edges if any light reaches it. Drive
// them low and HOLD them through the sleep, so the panel sees a black frame.
static const int RGB_PINS[] = {46, 3, 5, 7, 14, 38, 18, 17, 10, 39, 0, 45, 48, 47, 21, 1, 2, 42, 41, 40};
static void parkPanel() {
lvgl_port_lock(-1); // stop the render task from touching the panel while we take the pins
for (int pin : RGB_PINS) {
gpio_reset_pin((gpio_num_t)pin);
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_OUTPUT);
gpio_set_level((gpio_num_t)pin, 0);
gpio_hold_en((gpio_num_t)pin);
}
gpio_deep_sleep_hold_en();
// the lock is deliberately not released: nothing must draw again before sleep
}
static void goToSleep(const char* reason) {
print("[sleep] %s - deep sleep now; the CAN bus wakes me", reason);
Tunables::flush();
DisplayInit::setBacklight(false);
DisplayInit::setBacklight(false); // CH422G EXIO2 low; the expander keeps it while we sleep
delay(50);
CANDriver::stop(); // frees GPIO 16 from the TWAI peripheral
delay(400); // let the CAN task deinit TWAI
parkPanel();
// CAN RX idles high (recessive); the first bit of any frame pulls it low.
rtc_gpio_pulldown_dis((gpio_num_t)CAN_RX_PIN);
rtc_gpio_pullup_en((gpio_num_t)CAN_RX_PIN);