|
#include <epd.h>
|
|
|
|
const int led = 13;
|
|
|
|
void setup() {
|
|
/*
|
|
user led init
|
|
*/
|
|
pinMode(led, OUTPUT);
|
|
digitalWrite(led, LOW);
|
|
|
|
// random number seeding
|
|
Serial.begin(9600);
|
|
|
|
// if analog input pin 0 is unconnected, random analog
|
|
// noise will cause the call to randomSeed() to generate
|
|
// different seed numbers each time the sketch runs.
|
|
randomSeed(analogRead(0));
|
|
|
|
epd_init();
|
|
epd_wakeup();
|
|
epd_set_memory(MEM_NAND);
|
|
epd_screen_rotation(EPD_INVERSION);
|
|
}
|
|
|
|
void loop() {
|
|
char flag = 0;
|
|
draw_calendar();
|
|
epd_enter_stopmode();
|
|
while (1)
|
|
{
|
|
if(flag)
|
|
{
|
|
flag = 0;
|
|
digitalWrite(led, LOW);
|
|
delay(1000);
|
|
}
|
|
else
|
|
{
|
|
flag = 1;
|
|
digitalWrite(led, HIGH);
|
|
delay(3000);
|
|
}
|
|
}
|
|
}
|
|
|
|
void draw_calendar(void) {
|
|
char const *date[] = {"Saturday", "04", "January", "2020"};
|
|
char const *title = " ABHOR-";
|
|
char const *words[] = {
|
|
"To shrink back with shuddering from; to",
|
|
"regard with horror; to feel excessive",
|
|
"repugnance toward; to detest; to loathe.",
|
|
" Thou liest, abhorred tyrant; with my ",
|
|
"sword I'll prove the lie."
|
|
};
|
|
|
|
epd_clear();
|
|
|
|
// draw the word of the day
|
|
epd_set_color(BLACK, WHITE);
|
|
epd_set_en_font(ASCII48);
|
|
epd_disp_string(title, 8, 8);
|
|
|
|
// draw the definition
|
|
epd_set_en_font(ASCII32);
|
|
epd_set_color(DARK_GRAY, WHITE);
|
|
for (int i=0; i<5; i++) {
|
|
epd_disp_string(words[i], 16, 58 + (38 * i));
|
|
}
|
|
|
|
// draw the date
|
|
epd_set_color(DARK_GRAY, WHITE);
|
|
epd_set_en_font(ASCII48);
|
|
epd_disp_string(date[0], 578, 13);
|
|
epd_set_color(BLACK, WHITE);
|
|
epd_set_en_font(ASCII64);
|
|
epd_disp_string(date[1], 633, 59);
|
|
epd_set_color(DARK_GRAY, WHITE);
|
|
epd_set_en_font(ASCII48);
|
|
epd_disp_string(date[2], 578, 117);
|
|
epd_set_color(BLACK, WHITE);
|
|
epd_disp_string(date[3], 616, 169);
|
|
|
|
// draw a decorative border around the screen
|
|
for (int i=0; i < 4; i++) {
|
|
epd_set_color(DARK_GRAY, WHITE);
|
|
draw_rect(i, i, 799 - (2*i), 599 - (2*i));
|
|
}
|
|
|
|
// draw a light gray round ended line between the date and the word of the day
|
|
for (int i=0; i < 5; i++) {
|
|
int h = abs(i-2) * 2;
|
|
epd_set_color(GRAY, WHITE);
|
|
epd_draw_line(540 + i, 18 + h, 540 + i, 578 - h);
|
|
}
|
|
// draw_grid(8, 8, 10, 5);
|
|
|
|
epd_udpate();
|
|
}
|
|
|
|
void draw_rect(int t, int l, int h, int w) {
|
|
epd_draw_line(t, l, t, l + w);
|
|
epd_draw_line(t, l, t + h, l);
|
|
epd_draw_line(t + h, l, t + h, l + w);
|
|
epd_draw_line(t, l + w, t + h, l + w);
|
|
}
|
|
|
|
/**
|
|
* Draw a grid from (t,l) with points spaced `w` pixels apart and with
|
|
* major `tick` marks as specified.
|
|
*/
|
|
void draw_grid(int t, int l, int w, int tick) {
|
|
int i = 0;
|
|
int j = 0;
|
|
for (int x = l; x <= 800; x += w) {
|
|
i++;
|
|
for (int y = t; y <= 600; y += w) {
|
|
j++;
|
|
epd_draw_pixel(x, y);
|
|
if ((i % tick == 0) && (j % tick == 0)) {
|
|
draw_tick(x, y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw a major tick mark at the point specified.
|
|
*/
|
|
void draw_tick(int x, int y) {
|
|
epd_draw_pixel(x - 1, y);
|
|
epd_draw_pixel(x + 1, y);
|
|
epd_draw_pixel(x, y - 1);
|
|
epd_draw_pixel(x, y + 1);
|
|
}
|