Skip to content

Commit

Permalink
Added examples for Inkplate PLUS2
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoric committed Jul 24, 2023
1 parent 1ad8771 commit 82a7af3
Show file tree
Hide file tree
Showing 148 changed files with 29,868 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int timeZone = 2; // 2 means UTC+2

//----------------------------------------------

// Create object on Inkplate library and set library to work in gray mode (3-bit)
// Create object on Inkplate library
Inkplate display;

// Our networking functions, see Network.cpp for info
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
Inkplate5_Wake_Up_Button example for Soldered Inkplate 5
For this example you will need a USB-C cable and an Inkplate5
Select "Soldered Inkplate5" from Tools -> Board menu.
Don't have "Soldered Inkplate5" option? Follow our tutorial and add it:
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
Here is shown how to use ESP interrupts to wake up the MCU from deepsleep when wake up button
is pressed. Also, wake up on timer after 30 seconds of deep sleep if the button is not pressed.
NOTE: Button press will be detected when Inkplate ends with drawing to the screen(when the red
color stops flickering). If it is pressed when the Inkplate is drawing, nothing will happen,
the click will be ignored.
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
24 July 2023 by Soldered
*/

// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
#ifndef ARDUINO_INKPLATE5
#error "Wrong board selection for this example, please select Soldered Inkplate5 in the boards menu."
#endif

// Include Inkplate library to the sketch
#include <Inkplate.h>

// Create an object on Inkplate library and also set library into 1-bit mode (BW)
Inkplate display(INKPLATE_1BIT);

// Conversion factor for micro seconds to seconds
#define uS_TO_S_FACTOR 1000000

// Time ESP32 will go to sleep (in seconds)
#define TIME_TO_SLEEP 30

// Store int in rtc data, to remain persistent during deep sleep
RTC_DATA_ATTR int bootCount = 0;

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

++bootCount;

// Our function declared below
displayInfo();

// Go to sleep for TIME_TO_SLEEP seconds
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);

// Enable wakeup from deep sleep on gpio 36 (wake button)
esp_sleep_enable_ext0_wakeup(GPIO_NUM_36, 0);

// Start deep sleep (this function does not return). Program stops here.
esp_deep_sleep_start();
}

void loop()
{
// Never here! If you use deep sleep, the whole program should be in setup() because the board restarts each
// time. loop() must be empty!
}

// Function that will write number of boots and boot reason to screen
void displayInfo()
{
// First, lets delete everything from frame buffer
display.clearDisplay();

// Set text cursor and size
display.setCursor(30, 40);
display.setTextSize(3);

display.print(F("Boot count: "));
display.println(bootCount, DEC); // Print the number

// Set next line cursor position
display.setCursor(30, 100);

// Display wake up reason
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch (wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0:
display.println("Wakeup caused by WakeUp button");
break;
case ESP_SLEEP_WAKEUP_TIMER:
display.println("Wakeup caused by timer");
break;
default:
display.println("Wakeup was not caused by deep sleep");
break;
}

// Show everything on the screen
display.display();
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void setup()

// Keep trying to get data if it fails the first time
Serial.println("Getting data... ");
while (!network.getData(calendarURL, data, &dataLen))
while (!network.getData(calendarURL, data))
{
delay(1000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
13 July 2023 by Soldered
24 July 2023 by Soldered
*/

// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
Expand Down Expand Up @@ -70,14 +70,14 @@ void displayInfo()
display.clearDisplay();

// Set text cursor and size
display.setCursor(20, 180);
display.setCursor(30, 40);
display.setTextSize(2);

display.print(F("Boot count: "));
display.println(bootCount, DEC); // Print the number

// Set next line cursor position
display.setCursor(20, 220);
display.setCursor(30, 80);

// Display wake up reason
esp_sleep_wakeup_cause_t wakeup_reason;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
InkplatePLUS2_Burn_In_Clean example for Soldered Inkplate PLUS2
For this example you will need only USB-C cable and Inkplate PLUS2.
Select "Soldered Inkplate PLUS2" from Tools -> Board menu.
Don't have "Soldered Inkplate PLUS2" option? Follow our tutorial and add it:
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
This example will try to remove heavy burn-in visible on the panel.
Set number of refresh / clear cycles and upload the program.
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
24 July 2023 by Soldered
*/

// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
#ifndef ARDUINO_INKPLATEPLUS2
#error "Wrong board selection for this example, please select Inkplate PLUS2 in the boards menu."
#endif

#include "Inkplate.h" //Include Inkplate library to the sketch
Inkplate display(INKPLATE_1BIT); // Create object on Inkplate library and set library to work in monochorme mode

// Nubmer of clear cycles.
#define CLEAR_CYCLES 20

// Delay between clear cycles (in milliseconds)
#define CYCLES_DELAY 5000

void setup()
{
display.begin(); // Init library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear any data that may have been in (software) frame buffer.

display.einkOn(); // Power up epaper power supply

int cycles = CLEAR_CYCLES;

// Clean it by writing clear sequence to the panel.
while (cycles)
{
display.clean(1, 21);
display.clean(2, 1);
display.clean(0, 12);
display.clean(2, 1);
display.clean(1, 21);
display.clean(2, 1);
display.clean(0, 12);
display.clean(2, 1);

delay(CYCLES_DELAY);
cycles--;
}

// Print text when clearing is done.
display.setTextSize(4);
display.setCursor(125, 270);
display.print("Clearing done.");
display.display();
}

void loop()
{
// Empty...
}
Loading

0 comments on commit 82a7af3

Please sign in to comment.