Unarchive labrary EPD1IN54 from to arduino librares
github.com/MHEtLive/__/arduino/EPD1IN54_200PIX.zip
Library hardcoded PIN adresses
// EPD Pin definition
#define RST_PIN 8
#define DC_PIN 9
#define CS_PIN 10
#define BUSY_PIN 7
Code Block |
---|
/*demo for MH-ET LVIE 1.54 Black Epaper
*Set the toggle switch to the correct gear position according to the supply voltage.
*SPI:4line-wire
*EPD Pin(s) definition hardcoded in library
* RST_PIN 8
* DC_PIN 9
* CS_PIN 10
* BUSY_PIN 7
* Board specific PIN(s)
* SDI_PIN 51
* SCLK_PIN 52
*/
#include <epd1in54.h>
#include <epdpaint.h>
#include "imagedata.h"
#define WHITE 1
#define BLACK 0
/**
* Due to RAM not enough in Arduino UNO or NANO a pattern buffer is not allowed.
* In this case, a smaller image buffer is allocated and you have to
* update a partial display several times.
* 1 byte = 8 pixels, therefore you have to set 8*N pixels at a time.
*/
unsigned char image[1024];
Paint paint(image, 0, 0); // width should be the multiple of 8
Epd epd;
unsigned long time_start_ms;
unsigned long time_now_s;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
if (epd.Init(lut_full_update) != 0) {
Serial.print("e-Paper init failed");
return;
}
Serial.print("e-Paper init");
/**
* there are 2 memory areas embedded in the e-paper display
* and once the display is refreshed, the memory area will be auto-toggled,
* i.e. the next action of SetPatternMemory will set the other memory area
* therefore you have to clear the pattern memory twice.
*/
epd.ClearPatternMemory(0xFF); // bit set = white, bit reset = black
epd.DisplayPattern();
epd.ClearPatternMemory(0xFF); // bit set = white, bit reset = black
epd.DisplayPattern();
paint.SetRotate(ROTATE_0);
paint.SetWidth(200);
paint.SetHeight(24);
/* For simplicity, the arguments are explicit numerical coordinates */
paint.Clear(BLACK);
paint.DrawStringAt(30, 4, "Hello world!", &Font16, WHITE);
epd.SetPatternMemory(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());
paint.Clear(WHITE);
paint.DrawStringAt(16, 4, "---MH---", &Font24, BLACK);
epd.SetPatternMemory(paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight());
paint.SetWidth(64);
paint.SetHeight(64);
paint.Clear(WHITE);
paint.DrawRectangle(0, 0, 40, 50, BLACK);
paint.DrawLine(0, 0, 40, 50, BLACK);
paint.DrawLine(40, 0, 0, 50, BLACK);
epd.SetPatternMemory(paint.GetImage(), 16, 60, paint.GetWidth(), paint.GetHeight());
paint.Clear(WHITE);
paint.DrawCircle(32, 32, 30, BLACK);
epd.SetPatternMemory(paint.GetImage(), 120, 60, paint.GetWidth(), paint.GetHeight());
paint.Clear(WHITE);
paint.DrawFilledRectangle(0, 0, 40, 50, BLACK);
epd.SetPatternMemory(paint.GetImage(), 16, 130, paint.GetWidth(), paint.GetHeight());
paint.Clear(WHITE);
paint.DrawFilledCircle(32, 32, 30, BLACK);
epd.SetPatternMemory(paint.GetImage(), 120, 130, paint.GetWidth(), paint.GetHeight());
epd.DisplayPattern();
delay(2000);
epd.SetPatternMemory(IMAGE_DATA);
epd.DisplayPattern();
if (epd.Init(lut_partial_update) != 0) {
Serial.print("e-Paper init failed");
return;
}
delay(2000);
/**
* there are 2 memory areas embedded in the e-paper display
* and once the display is refreshed, the memory area will be auto-toggled,
* i.e. the next action of SetPatternMemory will set the other memory area
* therefore you have to set the pattern memory and refresh the display twice.
*/
epd.ClearPatternMemory(0xFF); // bit set = white, bit reset = black
epd.DisplayPattern();
epd.ClearPatternMemory(0xFF); // bit set = white, bit reset = black
epd.DisplayPattern();
delay(2000);
time_start_ms = millis();
}
void loop() {
// put your main code here, to run repeatedly:
time_now_s = (millis() - time_start_ms) / 1000;
char time_string[] = {'0', '0', ':', '0', '0', '\0'};
time_string[0] = time_now_s / 60 / 10 + '0';
time_string[1] = time_now_s / 60 % 10 + '0';
time_string[3] = time_now_s % 60 / 10 + '0';
time_string[4] = time_now_s % 60 % 10 + '0';
paint.SetWidth(90);
paint.SetHeight(32);
paint.SetRotate(ROTATE_0);
paint.Clear(WHITE);
paint.DrawStringAt(0, 4, time_string, &Font24, BLACK);
epd.SetPatternMemory(paint.GetImage(), 8, 128, paint.GetWidth(), paint.GetHeight());
epd.DisplayPattern();
Serial.println(time_string);
delay(500);
}
|