I experimented with the light sleep feature of the Xiao ESP32-C3. Upon pressing the awakening button, I observed flickering on the connected OLED screen, and holding down the button would constantly make the OLED screen flicker, I had to press it down for the perfect amount of time to wake it up and it feel unresponsive, is there a solution to this?
This is my code:
void setup()
{
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP);
gpio_wakeup_enable(GPIO_NUM_3, GPIO_INTR_LOW_LEVEL);
esp_sleep_enable_gpio_wakeup();
oledSetup();
wifiSetup();
}
void loop()
{
// Button, Timeout, TimeKeeping
button();
timeOut();
time();
if (btnPress == 1)
{
display.clearDisplay();
if (screenIndex == 0) screenIndex = 1;
else if (screenIndex == 1) screenIndex = 0;
}
// Screens
if (screenIndex == 0) homeScreen();
if (screenIndex == 1) menuScreen();
// Refreshing Display
openTransition();
display.display();
}
void timeOut()
{
if (btnPress != 0) sleepTime = millis() + sleepTimeout;
if (millis() > sleepTime)
{
closeTransition();
display.clearDisplay();
display.display();
screenIndex = 0;
esp_light_sleep_start();
}
}