Skip to content

Commit 98d8952

Browse files
committed
Starting to work on fix
1 parent 5479e21 commit 98d8952

File tree

3 files changed

+69
-24
lines changed

3 files changed

+69
-24
lines changed

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

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,40 @@ const uint8_t *pictures[] = {picture1, picture2,
3232
// so we can easly select it by selecting index in array
3333

3434
#define uS_TO_S_FACTOR 1000000 // Conversion factor for micro seconds to seconds
35-
#define TIME_TO_SLEEP 20 // How long ESP32 will be in deep sleep (in seconds)
35+
#define TIME_TO_SLEEP 120 // How long ESP32 will be in deep sleep (in seconds)
3636
RTC_DATA_ATTR int slide = 0;
3737

3838
Inkplate display; // Create an object on Inkplate library and also set library into 3 Bit mode (gray)
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+
4250
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
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
51+
52+
delay(1000);
53+
5254

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

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

61+
blinkLED();
62+
blinkLED();
63+
display.sleepColorPanel();
64+
delay(1000);
65+
66+
blinkLED();
67+
blinkLED();
68+
blinkLED();
5969
// Put ESP32 into deep sleep. Program stops here.
6070
esp_deep_sleep_start();
6171
}
@@ -65,3 +75,15 @@ void loop()
6575
// Nothing! If you use deep sleep, whole program should be in setup() because each time the board restarts, not in a
6676
// loop()! loop() must be empty!
6777
}
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+
89+
}

src/Inkplate.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ class Inkplate : public System, public Graphics
135135
void sleepPeripheral(uint8_t _peripheral);
136136
#endif
137137

138+
#ifdef ARDUINO_INKPLATECOLOR
139+
void sleepColorPanel();
140+
#endif
141+
138142
#if defined(ARDUINO_INKPLATE6PLUS) || defined(ARDUINO_INKPLATE6PLUSV2)
139143
void setInkplatePowerMode(uint8_t _mode);
140144
#endif
@@ -196,6 +200,7 @@ class Inkplate : public System, public Graphics
196200
#if defined(ARDUINO_INKPLATE6PLUS) || defined(ARDUINO_INKPLATE6PLUSV2)
197201
uint8_t pwrMode = INKPLATE_NORMAL_PWR_MODE;
198202
#endif
203+
199204
};
200205

201206
#endif

src/boards/Inkplate6Color.cpp

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,25 @@ 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+
5960
_beginDone = true;
60-
}
6161

62-
// Wake the ePaper and initialize everything
63-
// If it fails, return false
64-
if (!setPanelDeepSleep(false))
65-
return false;
62+
Serial.println("the display has NOT been previously init'ed, starting up...");
63+
// The display has not been initialized before
64+
// Wake the ePaper and initialize everything
65+
// If it fails, return false
66+
if (!setPanelDeepSleep(false))
67+
return false;
68+
69+
70+
delay(1000);
71+
}
72+
else
73+
{
74+
Serial.println("the display has been previously init'ed, resetting...");
75+
resetPanel();
76+
}
6677

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);
7078
return true;
7179
}
7280

@@ -76,9 +84,6 @@ bool Inkplate::begin(void)
7684
*/
7785
void Inkplate::display()
7886
{
79-
// Wake the panel back up
80-
setPanelDeepSleep(false);
81-
8287
// Set resolution setting
8388
uint8_t res_set_data[] = {0x02, 0x58, 0x01, 0xc0};
8489
sendCommand(0x61);
@@ -103,9 +108,6 @@ void Inkplate::display()
103108
while (digitalRead(EPAPER_BUSY_PIN))
104109
; // Wait for busy low signal
105110
delay(200);
106-
107-
// Put the panel to sleep again
108-
setPanelDeepSleep(true);
109111
}
110112

111113
/**
@@ -329,6 +331,7 @@ bool Inkplate::setPanelDeepSleep(bool _state)
329331
else
330332
{
331333
// _state is true? Put the panel to sleep.
334+
// This is not used in the driver because waking up from deep sleep causes brownout
332335

333336
delay(10);
334337
sendCommand(DEEP_SLEEP_REGISTER);
@@ -392,4 +395,19 @@ void Inkplate::setIOExpanderForLowPower()
392395
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B6, LOW);
393396
digitalWriteInternal(IO_INT_ADDR, ioRegsInt, IO_PIN_B7, LOW);
394397
}
398+
399+
void Inkplate::sleepColorPanel()
400+
{
401+
Serial.println("putting the color panel to sleep...");
402+
delay(10);
403+
sendCommand(DEEP_SLEEP_REGISTER);
404+
sendData(0x10);
405+
sendData(0xA5);
406+
delay(100);
407+
digitalWrite(EPAPER_RST_PIN, LOW);
408+
digitalWrite(EPAPER_DC_PIN, LOW);
409+
digitalWrite(EPAPER_CS_PIN, LOW);
410+
411+
}
412+
395413
#endif

0 commit comments

Comments
 (0)