Skip to content

Commit 4dd1c76

Browse files
committed
Figured out a fix, saving progress
1 parent 8a74548 commit 4dd1c76

File tree

2 files changed

+35
-42
lines changed

2 files changed

+35
-42
lines changed

examples/Inkplate6COLOR/Advanced/DeepSleep/Inkplate6COLOR_Simple_Deep_Sleep/Inkplate6COLOR_Simple_Deep_Sleep.ino

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ Inkplate display; // Create an object on Inkplate library and also set library i
3939

4040
void setup()
4141
{
42+
Serial.begin(115200);
43+
Serial.println("about begin..."); Serial.flush();
4244
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
4345
display.clearDisplay(); // Clear frame buffer of display
4446
display.drawImage(
4547
pictures[slide], 0, 0, 600,
4648
448); // Display selected picture at location X=0, Y=0. All three pictures have resolution of 600x448 pixels
49+
Serial.println("displayin..."); Serial.flush();
4750
display.display(); // Refresh the screen with new picture
51+
Serial.println("done displayin..."); Serial.flush();
4852
slide++; // Update counter for pictures. With this variable, we choose what picture is going to be displayed on
4953
// screen
5054
if (slide > 2)
@@ -53,13 +57,14 @@ void setup()
5357
// Uncomment this line if your Inkplate is older than Aug 2021 as older Inkplates have ESP32 wrover-e chips
5458
// rtc_gpio_isolate(GPIO_NUM_12); // Isolate/disable GPIO12 on ESP32 (only to reduce power consumption in sleep)
5559

60+
Serial.println("about to sleep color panel..."); Serial.flush();
61+
display.sleepColorPanel();
5662
// Activate wake-up timer -- wake up after 20s here
5763
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
64+
Serial.println("starting sleep..."); Serial.flush();
5865

59-
// This function must additionaly be called on Inkplate 6COLOR to initiate sleep
60-
display.sleepColorPanel();
61-
62-
// Put ESP32 into deep sleep. Program stops here.
66+
67+
// Put ESP32 into deep sleep. Program stops here.
6368
esp_deep_sleep_start();
6469
}
6570

src/boards/Inkplate6Color.cpp

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@ bool Inkplate::begin(void)
5656
// Color whole frame buffer in white color
5757
memset(DMemory4Bit, INKPLATE_WHITE | (INKPLATE_WHITE << 4), E_INK_WIDTH * E_INK_HEIGHT / 2);
5858

59-
6059
_beginDone = true;
61-
62-
// The display has not been initialized before
63-
// Wake the ePaper and initialize everything
64-
// If it fails, return false
65-
if (!setPanelDeepSleep(false))
66-
return false;
6760
}
6861

62+
// Wake the ePaper and initialize everything
63+
// If it fails, return false
64+
if (!setPanelDeepSleep(false))
65+
return false;
66+
67+
// Put the panel to deep sleep
68+
// The panel is always in sleep unless it's being written display data to
69+
setPanelDeepSleep(true);
6970
return true;
7071
}
7172

@@ -75,6 +76,9 @@ bool Inkplate::begin(void)
7576
*/
7677
void Inkplate::display()
7778
{
79+
// Wake the panel back up
80+
setPanelDeepSleep(false);
81+
7882
// Set resolution setting
7983
uint8_t res_set_data[] = {0x02, 0x58, 0x01, 0xc0};
8084
sendCommand(0x61);
@@ -99,6 +103,9 @@ void Inkplate::display()
99103
while (digitalRead(EPAPER_BUSY_PIN))
100104
; // Wait for busy low signal
101105
delay(200);
106+
107+
// Put the panel to sleep again
108+
setPanelDeepSleep(true);
102109
}
103110

104111
/**
@@ -322,7 +329,6 @@ bool Inkplate::setPanelDeepSleep(bool _state)
322329
else
323330
{
324331
// _state is true? Put the panel to sleep.
325-
// This is not used in the driver because waking up from deep sleep causes brownout
326332

327333
delay(10);
328334
sendCommand(DEEP_SLEEP_REGISTER);
@@ -351,9 +357,9 @@ void Inkplate::setIOExpanderForLowPower()
351357
ioBegin(IO_INT_ADDR, ioRegsInt);
352358

353359
// TOUCHPAD PINS
354-
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B2, OUTPUT);
355-
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B3, OUTPUT);
356-
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B4, OUTPUT);
360+
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B2, INPUT);
361+
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B3, INPUT);
362+
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B4, INPUT);
357363

358364
// Battery voltage Switch MOSFET
359365
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, OUTPUT);
@@ -387,36 +393,18 @@ void Inkplate::setIOExpanderForLowPower()
387393
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B7, LOW);
388394
}
389395

390-
/**
391-
* @brief This function is added as a fix for low power for Inkplate 6COLOR
392-
* It further decreases the low-power current and makes waking up from sleep stable and
393-
* avoids a double-reset via brownout.
394-
*/
395396
void Inkplate::sleepColorPanel()
396397
{
397-
// First, put the ePaper to sleep
398-
delay(10);
398+
// First wake the panel
399+
setPanelDeepSleep(false);
400+
401+
// Now send the sleep command delay(10);
399402
sendCommand(DEEP_SLEEP_REGISTER);
400403
sendData(0xA5);
401-
delay(100); // Wait a bit until it's surely in sleep
402-
403-
// End the SPI used to communicate with the ePaper
404-
epdSPI.end();
405-
delay(5);
406-
407-
// Set the SPI pins as INPUT as they have hw pull-ups
408-
pinMode(EPAPER_RST_PIN, INPUT);
409-
pinMode(EPAPER_DC_PIN, INPUT);
410-
pinMode(EPAPER_CS_PIN, INPUT);
411-
412-
// Make sure the SD card is in sleep
413-
sdCardSleep();
414-
delay(10);
415-
416-
// Make sure VBAT is disabled
417-
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, OUTPUT);
418-
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, LOW);
419-
delay(10);
404+
delay(100);
405+
digitalWrite(EPAPER_DC_PIN, LOW);
406+
digitalWrite(EPAPER_CS_PIN, LOW);
407+
digitalWrite(EPAPER_RST_PIN, HIGH); // Make sure this is HIGH so the display is on
408+
gpio_deep_sleep_hold_en(); // Make sure RST pin stays high during sleep
420409
}
421-
422410
#endif

0 commit comments

Comments
 (0)