Skip to content

Instantly share code, notes, and snippets.

@makermelissa
Created October 21, 2020 15:17
Show Gist options
  • Select an option

  • Save makermelissa/29be681245707aae8dddcc0511418a0b to your computer and use it in GitHub Desktop.

Select an option

Save makermelissa/29be681245707aae8dddcc0511418a0b to your computer and use it in GitHub Desktop.
/***************************************************
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/
#include "Adafruit_ThinkInk.h"
#define EPD_CS 10
#define EPD_DC 9
#define SRAM_CS 11
#define EPD_RESET 5 // can set to -1 and share with microcontroller Reset!
#define EPD_BUSY -1 // can set to -1 to not use a pin (will wait a fixed delay)
//ThinkInk_154_Grayscale4_T8 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_213_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
ThinkInk_290_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
#define COLOR1 EPD_BLACK
#define COLOR2 EPD_LIGHT
#define COLOR3 EPD_DARK
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}
Serial.println("Adafruit EPD full update test in mono & grayscale");
}
bool gray = false;
void loop() {
// alternate modes!
if (gray) {
display.begin(THINKINK_GRAYSCALE4);
Serial.println("Grayscale!");
} else {
display.begin(THINKINK_MONO);
Serial.println("Monochrome!");
}
display.clearBuffer();
display.setTextSize(3);
display.setTextColor(EPD_BLACK);
display.setCursor(20, 40);
if (gray) {
display.print("Grayscale");
} else {
display.print("Monochrome");
}
gray = !gray;
display.display();
delay(1000);
display.clearBuffer();
display.fillRect(display.width() / 4, 0, display.width() / 4, display.height(), EPD_LIGHT);
display.fillRect((display.width() * 2) / 4, 0, display.width() / 4, display.height(), EPD_DARK);
display.fillRect((display.width() * 3) / 4, 0, display.width() / 4, display.height(), EPD_BLACK);
display.display();
delay(2000);
Serial.println("Text demo");
// large block of text
display.clearBuffer();
display.setTextSize(1);
testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", COLOR1);
display.display();
delay(2000);
display.clearBuffer();
for (int16_t i = 0; i < display.width(); i += 4) {
display.drawLine(0, 0, i, display.height() - 1, COLOR1);
}
for (int16_t i = 0; i < display.height(); i += 4) {
display.drawLine(display.width() - 1, 0, 0, i, COLOR2); // on grayscale this will be mid-gray
}
display.display();
delay(2000);
}
void testdrawtext(char *text, uint16_t color) {
display.setCursor(0, 0);
display.setTextColor(color);
display.setTextWrap(true);
display.print(text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment