Arduino uno Codes
these codes control what is output onto the screen
#include <SPI.h>
#include "epd1in54_V2.h"
#include "epdpaint.h"
#include <stdio.h>
#include <Wire.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()
{
Serial.begin(115200);
Serial.println("e-Paper init and clear");
epd.LDirInit();
epd.Clear();
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(COLORED);
paint.DrawStringAt(45, 4, "ALIBABA HQ", &Font16, UNCOLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(40, 4, "JACK MA", &Font24, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 34, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(76, 4, "CEO", &Font16, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 58, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "STATUS:", &Font12, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 86, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 10, "CONTACT:", &Font12, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 142, paint.GetWidth(), paint.GetHeight());
paint.Clear(COLORED);
paint.DrawStringAt(28, 4, "130 6778 6582", &Font16, UNCOLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 166, paint.GetWidth(), paint.GetHeight());
paint.SetWidth(200);
paint.SetHeight(4);
paint.Clear(COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 82, paint.GetWidth(), paint.GetHeight());
paint.Clear(COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 138, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
Wire.begin(0x40);
Wire.onReceive(receiveEvent);
//Serial.begin(9600);
}
void loop()
{
}
void receiveEvent(int howMany)
{
Serial.println("data received");
char cReceivedData = Wire.read();
Serial.println(cReceivedData);
if('1' == cReceivedData)
{
Serial.println("AVAILABLE");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "AVAILABLE", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('0' == cReceivedData)
{
Serial.println("UNAVAILABLE");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "UNAVAILABLE", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('2' == cReceivedData)
{
Serial.println("AT LUNCH");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "AT LUNCH", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('3' == cReceivedData)
{
Serial.println("BUSY");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "BUSY", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('4' == cReceivedData)
{
Serial.println("DO NOT DISTURB");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "DO NOT DISTURB", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('5' == cReceivedData)
{
Serial.println("BE BACK SOON");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "BE BACK SOON", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('6' == cReceivedData)
{
Serial.println("PLEASE KNOCK");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "PLEASE KNOCK", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('7' == cReceivedData)
{
Serial.println("ON VACATION");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "ON VACATION", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('8' == cReceivedData)
{
Serial.println("PLEASE WAIT");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "PLEASE WAIT", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else if('9' == cReceivedData)
{
Serial.println("IN A MEETING");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "IN A MEETING", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
else
{
Serial.println("NO STATUS");
paint.SetWidth(200);
paint.SetHeight(24);
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 4, "NO STATUS", &Font20, COLORED);
epd.SetFrameMemory(paint.GetImage(), 0, 110, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
}
}