Skip to content

Commit e76e670

Browse files
committed
Fixed the basic deep sleep sketch, testing this branch
1 parent 9706791 commit e76e670

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

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

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,26 @@ Inkplate display; // Create an object on Inkplate library and also set library i
3939

4040
void setup()
4141
{
42-
pinMode(25, OUTPUT);
43-
44-
Serial.begin(115200);
45-
Serial.println("about to enter begin...");
46-
47-
48-
delay(1000);
49-
5042
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
51-
52-
delay(1000);
53-
43+
display.clearDisplay(); // Clear frame buffer of display
44+
display.drawImage(
45+
pictures[slide], 0, 0, 600,
46+
448); // Display selected picture at location X=0, Y=0. All three pictures have resolution of 600x448 pixels
47+
display.display(); // Refresh the screen with new picture
48+
slide++; // Update counter for pictures. With this variable, we choose what picture is going to be displayed on
49+
// screen
50+
if (slide > 2)
51+
slide = 0; // We do not have more than 3 images, so roll back to zero
5452

5553
// Uncomment this line if your Inkplate is older than Aug 2021 as older Inkplates have ESP32 wrover-e chips
5654
// rtc_gpio_isolate(GPIO_NUM_12); // Isolate/disable GPIO12 on ESP32 (only to reduce power consumption in sleep)
5755

5856
// Activate wake-up timer -- wake up after 20s here
5957
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
6058

61-
blinkLED();
62-
blinkLED();
59+
// This function must additionaly be called on Inkplate 6COLOR to initiate sleep
6360
display.sleepColorPanel();
64-
delay(1000);
6561

66-
blinkLED();
67-
blinkLED();
68-
blinkLED();
6962
// Put ESP32 into deep sleep. Program stops here.
7063
esp_deep_sleep_start();
7164
}
@@ -74,16 +67,4 @@ void loop()
7467
{
7568
// Nothing! If you use deep sleep, whole program should be in setup() because each time the board restarts, not in a
7669
// loop()! loop() must be empty!
77-
}
78-
79-
void blinkLED()
80-
{
81-
digitalWrite(25,HIGH);
82-
delay(100);
83-
digitalWrite(25,LOW);
84-
delay(100);
85-
86-
delay(100);
87-
88-
8970
}

src/boards/Inkplate6Color.cpp

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ bool Inkplate::begin(void)
6666
if (!setPanelDeepSleep(false))
6767
return false;
6868

69-
7069
delay(1000);
7170
}
7271
else
@@ -360,9 +359,9 @@ void Inkplate::setIOExpanderForLowPower()
360359
ioBegin(IO_INT_ADDR, ioRegsInt);
361360

362361
// TOUCHPAD PINS
363-
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B2, INPUT);
364-
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B3, INPUT);
365-
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B4, INPUT);
362+
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B2, OUTPUT);
363+
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B3, OUTPUT);
364+
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B4, OUTPUT);
366365

367366
// Battery voltage Switch MOSFET
368367
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, OUTPUT);
@@ -385,7 +384,7 @@ void Inkplate::setIOExpanderForLowPower()
385384
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A0, LOW);
386385
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A1, LOW);
387386
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A2, LOW);
388-
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A3, LOW);
387+
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A3, LOW);
389388
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A4, LOW);
390389
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A5, LOW);
391390
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A6, LOW);
@@ -396,17 +395,36 @@ void Inkplate::setIOExpanderForLowPower()
396395
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B7, LOW);
397396
}
398397

398+
/**
399+
* @brief This function is added as a fix for low power for Inkplate 6COLOR
400+
* It further decreases the low-power current and makes waking up from sleep stable and
401+
* avoids a double-reset via brownout.
402+
*/
399403
void Inkplate::sleepColorPanel()
400404
{
401-
Serial.println("putting the color panel to sleep...");
405+
// First, put the ePaper to sleep
402406
delay(10);
403407
sendCommand(DEEP_SLEEP_REGISTER);
404-
sendData(0x10);
405408
sendData(0xA5);
406-
delay(100);
407-
digitalWrite(EPAPER_RST_PIN, LOW);
408-
digitalWrite(EPAPER_DC_PIN, LOW);
409-
digitalWrite(EPAPER_CS_PIN, LOW);
409+
delay(100); // Wait a bit until it's surely in sleep
410+
411+
// End the SPI used to communicate with the ePaper
412+
epdSPI.end();
413+
delay(5);
414+
415+
// Set the SPI pins as INPUT as they have hw pull-ups
416+
pinMode(EPAPER_RST_PIN, INPUT);
417+
pinMode(EPAPER_DC_PIN, INPUT);
418+
pinMode(EPAPER_CS_PIN, INPUT);
419+
420+
// Make sure the SD card is in sleep
421+
sdCardSleep();
422+
delay(10);
423+
424+
// Make sure VBAT is disabled
425+
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, OUTPUT);
426+
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, LOW);
427+
delay(10);
410428
}
411429

412430
#endif

0 commit comments

Comments
 (0)