Skip to content

Commit

Permalink
Fixed the basic deep sleep sketch, testing this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoric committed Dec 6, 2023
1 parent 9706791 commit e76e670
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,26 @@ Inkplate display; // Create an object on Inkplate library and also set library i

void setup()
{
pinMode(25, OUTPUT);

Serial.begin(115200);
Serial.println("about to enter begin...");


delay(1000);

display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)

delay(1000);

display.clearDisplay(); // Clear frame buffer of display
display.drawImage(
pictures[slide], 0, 0, 600,
448); // Display selected picture at location X=0, Y=0. All three pictures have resolution of 600x448 pixels
display.display(); // Refresh the screen with new picture
slide++; // Update counter for pictures. With this variable, we choose what picture is going to be displayed on
// screen
if (slide > 2)
slide = 0; // We do not have more than 3 images, so roll back to zero

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

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

blinkLED();
blinkLED();
// This function must additionaly be called on Inkplate 6COLOR to initiate sleep
display.sleepColorPanel();
delay(1000);

blinkLED();
blinkLED();
blinkLED();
// Put ESP32 into deep sleep. Program stops here.
esp_deep_sleep_start();
}
Expand All @@ -74,16 +67,4 @@ void loop()
{
// Nothing! If you use deep sleep, whole program should be in setup() because each time the board restarts, not in a
// loop()! loop() must be empty!
}

void blinkLED()
{
digitalWrite(25,HIGH);
delay(100);
digitalWrite(25,LOW);
delay(100);

delay(100);


}
40 changes: 29 additions & 11 deletions src/boards/Inkplate6Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ bool Inkplate::begin(void)
if (!setPanelDeepSleep(false))
return false;


delay(1000);
}
else
Expand Down Expand Up @@ -360,9 +359,9 @@ void Inkplate::setIOExpanderForLowPower()
ioBegin(IO_INT_ADDR, ioRegsInt);

// TOUCHPAD PINS
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B2, INPUT);
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B3, INPUT);
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B4, INPUT);
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B2, OUTPUT);
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B3, OUTPUT);
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B4, OUTPUT);

// Battery voltage Switch MOSFET
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, OUTPUT);
Expand All @@ -385,7 +384,7 @@ void Inkplate::setIOExpanderForLowPower()
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A0, LOW);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A1, LOW);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A2, LOW);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A3, LOW);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A3, LOW);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A4, LOW);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A5, LOW);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_A6, LOW);
Expand All @@ -396,17 +395,36 @@ void Inkplate::setIOExpanderForLowPower()
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B7, LOW);
}

/**
* @brief This function is added as a fix for low power for Inkplate 6COLOR
* It further decreases the low-power current and makes waking up from sleep stable and
* avoids a double-reset via brownout.
*/
void Inkplate::sleepColorPanel()
{
Serial.println("putting the color panel to sleep...");
// First, put the ePaper to sleep
delay(10);
sendCommand(DEEP_SLEEP_REGISTER);
sendData(0x10);
sendData(0xA5);
delay(100);
digitalWrite(EPAPER_RST_PIN, LOW);
digitalWrite(EPAPER_DC_PIN, LOW);
digitalWrite(EPAPER_CS_PIN, LOW);
delay(100); // Wait a bit until it's surely in sleep

// End the SPI used to communicate with the ePaper
epdSPI.end();
delay(5);

// Set the SPI pins as INPUT as they have hw pull-ups
pinMode(EPAPER_RST_PIN, INPUT);
pinMode(EPAPER_DC_PIN, INPUT);
pinMode(EPAPER_CS_PIN, INPUT);

// Make sure the SD card is in sleep
sdCardSleep();
delay(10);

// Make sure VBAT is disabled
pinModeInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, OUTPUT);
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B1, LOW);
delay(10);
}

#endif

0 comments on commit e76e670

Please sign in to comment.