e-paper-display/bcm2835-1.71/e-Paper/Arduino/epd1in54_V2/epd1in54_V2.ino

91 lines
2.4 KiB
Arduino
Raw Normal View History

2024-01-31 22:04:09 +00:00
#include <SPI.h>
#include "epd1in54_V2.h"
#include "imagedata.h"
#include "epdpaint.h"
#include <stdio.h>
Epd epd;
unsigned char image[1024];
Paint paint(image, 0, 0);
unsigned long time_start_ms;
unsigned long time_now_s;
#define COLORED 0
#define UNCOLORED 1
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("e-Paper init and clear");
epd.LDirInit();
epd.Clear();
paint.SetWidth(200);
paint.SetHeight(24);
Serial.println("e-Paper paint");
paint.Clear(COLORED);
paint.DrawStringAt(30, 4, "Hello world!", &Font16, UNCOLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(30, 4, "e-Paper Demo", &Font16, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight());
paint.SetWidth(64);
paint.SetHeight(64);
paint.Clear(UNCOLORED);
paint.DrawRectangle(0, 0, 40, 50, COLORED);
paint.DrawLine(0, 0, 40, 50, COLORED);
paint.DrawLine(40, 0, 0, 50, COLORED);
epd.SetFrameMemory(paint.GetImage(), 16, 60, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawCircle(32, 32, 30, COLORED);
epd.SetFrameMemory(paint.GetImage(), 120, 60, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawFilledRectangle(0, 0, 40, 50, COLORED);
epd.SetFrameMemory(paint.GetImage(), 16, 130, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawFilledCircle(32, 32, 30, COLORED);
epd.SetFrameMemory(paint.GetImage(), 120, 130, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
delay(2000);
Serial.println("e-Paper show pic");
epd.HDirInit();
// epd.Display(IMAGE_DATA);
//Part display
epd.HDirInit();
epd.DisplayPartBaseImage(IMAGE_DATA);
paint.SetWidth(50);
paint.SetHeight(60);
paint.Clear(UNCOLORED);
char i = 0;
char str[10][10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
for (i = 0; i < 10; i++) {
paint.Clear(UNCOLORED);
paint.DrawStringAt(10, 10, str[i], &Font24, COLORED);
epd.SetFrameMemoryPartial(paint.GetImage(), 80, 70, paint.GetWidth(), paint.GetHeight());
epd.DisplayPartFrame();
delay(100);
}
Serial.println("e-Paper clear and goto sleep");
epd.HDirInit();
epd.Clear();
epd.Sleep();
}
void loop()
{
}