Skip to content

Commit

Permalink
added new watchfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sqfmi committed Feb 18, 2020
1 parent 179f765 commit 82dfc42
Show file tree
Hide file tree
Showing 4 changed files with 690 additions and 0 deletions.
174 changes: 174 additions & 0 deletions examples/Watchy_DOS/Px437_IBM_BIOS5pt7b.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
//created using https://rop.nl/truetype2gfx/
//https://github.com/ropg/truetype2gfx
//@ropg
//Px437_IBM_BIOS.ttf

const uint8_t Px437_IBM_BIOS5pt7bBitmaps[] PROGMEM = {
0x00, 0x73, 0xFF, 0xF7, 0x39, 0xC0, 0x70, 0xEF, 0xDF, 0xBF, 0x70, 0x77,
0x3B, 0x9D, 0xDF, 0xF7, 0x77, 0xFF, 0xDC, 0xEE, 0x77, 0x00, 0x38, 0x3F,
0x7F, 0xE0, 0x7C, 0x07, 0x04, 0xFC, 0x38, 0xE3, 0xF1, 0xF9, 0xC1, 0x83,
0x81, 0x9D, 0xCF, 0xC7, 0x3C, 0x1B, 0x9D, 0xC7, 0x87, 0xBF, 0x7B, 0xBD,
0xCE, 0x7B, 0x80, 0x77, 0x7E, 0x18, 0x9D, 0xCE, 0x73, 0xCE, 0x18, 0xE7,
0x9C, 0x31, 0x8C, 0x4E, 0xE0, 0x73, 0x9C, 0xE3, 0xF3, 0xFF, 0x3F, 0x0C,
0xE7, 0x38, 0x38, 0x38, 0x38, 0xFF, 0x38, 0x38, 0x38, 0x77, 0x7E, 0xFF,
0xFF, 0x80, 0x03, 0x81, 0x81, 0xC1, 0x83, 0x83, 0x81, 0x81, 0xC0, 0x80,
0x00, 0x7F, 0x31, 0xF8, 0xFC, 0xFE, 0xFF, 0xDF, 0xCF, 0xE7, 0x7F, 0x00,
0x38, 0x38, 0x78, 0x38, 0x38, 0x38, 0x38, 0x38, 0xFF, 0x7C, 0x67, 0xE7,
0x07, 0x3C, 0x70, 0x67, 0xE7, 0xFF, 0x7C, 0x67, 0xE7, 0x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 0x83, 0xE0, 0x7B, 0xF3, 0xB9, 0xDC, 0xE7, 0xF0,
0x38, 0x3E, 0xEF, 0x3D, 0xDC, 0xEE, 0x77, 0x07, 0xC0, 0x7F, 0xE0, 0x7C,
0x7F, 0x07, 0xFC, 0x10, 0x21, 0xC7, 0xF7, 0x0E, 0x1D, 0xBB, 0x18, 0xE7,
0x73, 0xB9, 0xDC, 0xEE, 0x73, 0xDC, 0xE7, 0xE7, 0xE7, 0xE4, 0x7C, 0x38,
0xE3, 0xF5, 0xFF, 0xFF, 0xFF, 0xFB, 0xB8, 0xE3, 0xBB, 0x8F, 0x06, 0xE7,
0x77, 0x1C, 0xE7, 0xE7, 0xE7, 0xE7, 0x7F, 0x07, 0xFC, 0xFF, 0x8C, 0x38,
0x33, 0x73, 0xFF, 0x0F, 0x08, 0x38, 0x38, 0xF0, 0x38, 0x38, 0x38, 0x0F,
0xFF, 0x3F, 0xC0, 0xF0, 0xF8, 0x38, 0x38, 0x0F, 0x38, 0x38, 0x38, 0xF0,
0x7B, 0xB5, 0xBB, 0xC0 };

const GFXglyph Px437_IBM_BIOS5pt7bGlyphs[] PROGMEM = {
{ 0, 1, 1, 10, 0, 0 }, // 0x20 ' '
{ 1, 5, 9, 10, 1, -8 }, // 0x21 '!'
{ 7, 7, 4, 10, 1, -8 }, // 0x22 '"'
{ 11, 9, 9, 10, 0, -8 }, // 0x23 '#'
{ 22, 8, 9, 10, 0, -8 }, // 0x24 '$'
{ 31, 9, 8, 10, 0, -7 }, // 0x25 '%'
{ 40, 9, 9, 10, 0, -8 }, // 0x26 '&'
{ 51, 4, 4, 10, 0, -8 }, // 0x27 '''
{ 53, 5, 9, 10, 1, -8 }, // 0x28 '('
{ 59, 5, 9, 10, 1, -8 }, // 0x29 ')'
{ 65, 10, 7, 10, 0, -7 }, // 0x2A '*'
{ 74, 8, 7, 10, 0, -7 }, // 0x2B '+'
{ 81, 4, 4, 10, 1, -2 }, // 0x2C ','
{ 83, 8, 1, 10, 0, -4 }, // 0x2D '-'
{ 84, 3, 3, 10, 2, -2 }, // 0x2E '.'
{ 86, 9, 9, 10, 0, -8 }, // 0x2F '/'
{ 97, 9, 9, 10, 0, -8 }, // 0x30 '0'
{ 108, 8, 9, 10, 0, -8 }, // 0x31 '1'
{ 117, 8, 9, 10, 0, -8 }, // 0x32 '2'
{ 126, 8, 9, 10, 0, -8 }, // 0x33 '3'
{ 135, 9, 9, 10, 0, -8 }, // 0x34 '4'
{ 146, 8, 9, 10, 0, -8 }, // 0x35 '5'
{ 155, 8, 9, 10, 0, -8 }, // 0x36 '6'
{ 164, 8, 9, 10, 0, -8 }, // 0x37 '7'
{ 173, 8, 9, 10, 0, -8 }, // 0x38 '8'
{ 182, 8, 9, 10, 0, -8 }, // 0x39 '9'
{ 191, 3, 8, 10, 2, -7 }, // 0x3A ':'
{ 194, 4, 9, 10, 1, -7 }, // 0x3B ';'
{ 199, 6, 9, 10, 0, -8 }, // 0x3C '<'
{ 206, 8, 5, 10, 0, -5 }, // 0x3D '='
{ 211, 7, 9, 10, 1, -8 }, // 0x3E '>'
{ 219, 8, 9, 10, 0, -8 }, // 0x3F '?'
{ 228, 9, 9, 10, 0, -8 }, // 0x40 '@'
{ 239, 8, 9, 10, 0, -8 }, // 0x41 'A'
{ 248, 9, 9, 10, 0, -8 }, // 0x42 'B'
{ 259, 9, 9, 10, 0, -8 }, // 0x43 'C'
{ 270, 9, 9, 10, 0, -8 }, // 0x44 'D'
{ 281, 9, 9, 10, 0, -8 }, // 0x45 'E'
{ 292, 9, 9, 10, 0, -8 }, // 0x46 'F'
{ 303, 9, 9, 10, 0, -8 }, // 0x47 'G'
{ 314, 8, 9, 10, 0, -8 }, // 0x48 'H'
{ 323, 5, 9, 10, 1, -8 }, // 0x49 'I'
{ 329, 9, 9, 10, 0, -8 }, // 0x4A 'J'
{ 340, 9, 9, 10, 0, -8 }, // 0x4B 'K'
{ 351, 9, 9, 10, 0, -8 }, // 0x4C 'L'
{ 362, 9, 9, 10, 0, -8 }, // 0x4D 'M'
{ 373, 9, 9, 10, 0, -8 }, // 0x4E 'N'
{ 384, 9, 9, 10, 0, -8 }, // 0x4F 'O'
{ 395, 9, 9, 10, 0, -8 }, // 0x50 'P'
{ 406, 8, 9, 10, 0, -8 }, // 0x51 'Q'
{ 415, 9, 9, 10, 0, -8 }, // 0x52 'R'
{ 426, 8, 9, 10, 0, -8 }, // 0x53 'S'
{ 435, 8, 9, 10, 0, -8 }, // 0x54 'T'
{ 444, 8, 9, 10, 0, -8 }, // 0x55 'U'
{ 453, 8, 9, 10, 0, -8 }, // 0x56 'V'
{ 462, 9, 9, 10, 0, -8 }, // 0x57 'W'
{ 473, 9, 9, 10, 0, -8 }, // 0x58 'X'
{ 484, 8, 9, 10, 0, -8 }, // 0x59 'Y'
{ 493, 9, 9, 10, 0, -8 }, // 0x5A 'Z'
{ 504, 5, 9, 10, 1, -8 }, // 0x5B '['
{ 510, 9, 9, 10, 0, -8 }, // 0x5C '\'
{ 521, 5, 9, 10, 1, -8 }, // 0x5D ']'
{ 527, 9, 5, 10, 0, -8 }, // 0x5E '^'
{ 533, 10, 1, 10, 0, 1 }, // 0x5F '_'
{ 535, 4, 4, 10, 2, -8 }, // 0x60 '`'
{ 537, 9, 6, 10, 0, -5 }, // 0x61 'a'
{ 544, 9, 9, 10, 0, -8 }, // 0x62 'b'
{ 555, 8, 6, 10, 0, -5 }, // 0x63 'c'
{ 561, 9, 9, 10, 0, -8 }, // 0x64 'd'
{ 572, 8, 6, 10, 0, -5 }, // 0x65 'e'
{ 578, 8, 9, 10, 0, -8 }, // 0x66 'f'
{ 587, 9, 7, 10, 0, -5 }, // 0x67 'g'
{ 595, 9, 9, 10, 0, -8 }, // 0x68 'h'
{ 606, 5, 9, 10, 1, -8 }, // 0x69 'i'
{ 612, 8, 10, 10, 0, -8 }, // 0x6A 'j'
{ 622, 9, 9, 10, 0, -8 }, // 0x6B 'k'
{ 633, 5, 9, 10, 1, -8 }, // 0x6C 'l'
{ 639, 9, 6, 10, 0, -5 }, // 0x6D 'm'
{ 646, 8, 6, 10, 0, -5 }, // 0x6E 'n'
{ 652, 8, 6, 10, 0, -5 }, // 0x6F 'o'
{ 658, 9, 7, 10, 0, -5 }, // 0x70 'p'
{ 666, 9, 7, 10, 0, -5 }, // 0x71 'q'
{ 674, 9, 6, 10, 0, -5 }, // 0x72 'r'
{ 681, 8, 6, 10, 0, -5 }, // 0x73 's'
{ 687, 7, 9, 10, 1, -8 }, // 0x74 't'
{ 695, 9, 6, 10, 0, -5 }, // 0x75 'u'
{ 702, 8, 6, 10, 0, -5 }, // 0x76 'v'
{ 708, 9, 6, 10, 0, -5 }, // 0x77 'w'
{ 715, 9, 6, 10, 0, -5 }, // 0x78 'x'
{ 722, 8, 7, 10, 0, -5 }, // 0x79 'y'
{ 729, 8, 6, 10, 0, -5 }, // 0x7A 'z'
{ 735, 8, 9, 10, 0, -8 }, // 0x7B '{'
{ 744, 2, 9, 10, 4, -8 }, // 0x7C '|'
{ 747, 8, 9, 10, 0, -8 }, // 0x7D '}'
{ 756, 9, 3, 10, 0, -8 } }; // 0x7E '~'

const GFXfont Px437_IBM_BIOS5pt7b PROGMEM = {
(uint8_t *)Px437_IBM_BIOS5pt7bBitmaps,
(GFXglyph *)Px437_IBM_BIOS5pt7bGlyphs,
0x20, 0x7E, 10 };

// Approx. 1432 bytes
111 changes: 111 additions & 0 deletions examples/Watchy_DOS/Watchy_DOS.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Watchy - DOS Watchface Example
* Sets the RTC time if not set, goes to sleep and wakes up every minute to update the time on the display
*/

#ifndef ESP32
#error Please select ESP32 Wrover Module under Tools > Board
#endif

#include <DS3232RTC.h>
#include <GxEPD2_BW.h>
#include "Px437_IBM_BIOS5pt7b.h"

#define RTC_PIN GPIO_NUM_33

DS3232RTC RTC(false);
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0154D67

void setup()
{
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0: updateTime(false); break; //RTC Alarm Interrupt
default: updateTime(true); //Hard Reset
}
esp_sleep_enable_ext0_wakeup(RTC_PIN, 0); //enable deep sleep wake on RTC interrupt
esp_deep_sleep_start();
}

void loop(){}

void updateTime(bool reset)
{
RTC.begin();
if(reset){
RTC.squareWave(SQWAVE_NONE); //disable square wave output
RTC.set(compileTime()); //set RTC time to compile time
RTC.setAlarm(ALM2_EVERY_MINUTE, 0, 0, 0, 0);
RTC.alarmInterrupt(ALARM_2, true); //enable alarm interrupt
}
RTC.alarm(ALARM_2); //resets the alarm flag in the RTC
tmElements_t currentTime;
RTC.read(currentTime);

char time[6];
time[0] = '0' + ((currentTime.Hour/10)%10);
time[1] = '0' + (currentTime.Hour%10);
time[2] = ':';
time[3] = '0' + ((currentTime.Minute/10)%10);
time[4] = '0' + (currentTime.Minute%10);
time[5] = 0;

display.init(0, reset); //_initial_refresh to false to prevent full update on init
display.setFullWindow();
display.fillScreen(GxEPD_BLACK);
display.setTextColor(GxEPD_WHITE);
display.setFont(&Px437_IBM_BIOS5pt7b);
display.setCursor(0, 24);
display.println("WATCHY-DOS 1.1.4");
display.println("Copyright (c) 2020");
display.println(" ");
display.print("AUTOEXEC BAT ");
display.println(time);
display.print("COMMAND COM ");
display.println(time);
display.print("CONFIG SYS ");
display.println(time);
display.print("ESPTOOL PY ");
display.println(time);
display.println(" ");
display.println(" 4 files 563 bytes");
display.println(" 2048 bytes free");
display.println(" ");
display.println("<C:\\>esptool");
/*
if(currentTime.Hour < 10){
display.print('0');
}
display.print(currentTime.Hour);
display.print(':');
if(currentTime.Minute < 10){
display.print('0');
}
display.print(currentTime.Minute);*/
display.display(true); //partial refresh
display.hibernate();
}

time_t compileTime()
{
const time_t FUDGE(10); //fudge factor to allow for upload time, etc. (seconds, YMMV)
const char *compDate = __DATE__, *compTime = __TIME__, *months = "JanFebMarAprMayJunJulAugSepOctNovDec";
char compMon[3], *m;

strncpy(compMon, compDate, 3);
compMon[3] = '\0';
m = strstr(months, compMon);

tmElements_t tm;
tm.Month = ((m - months) / 3 + 1);
tm.Day = atoi(compDate + 4);
tm.Year = atoi(compDate + 7) - 1970;
tm.Hour = atoi(compTime);
tm.Minute = atoi(compTime + 3);
tm.Second = atoi(compTime + 6);

time_t t = makeTime(tm);
return t + FUDGE; //add fudge factor to allow for compile time
}
89 changes: 89 additions & 0 deletions examples/Watchy_Pokemon/Watchy_Pokemon.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Watchy - Pokemon Watchface Example
* Sets the RTC time if not set, goes to sleep and wakes up every minute to update the time on the display
*/

#ifndef ESP32
#error Please select ESP32 Wrover Module under Tools > Board
#endif

#include <DS3232RTC.h>
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include "pokemon.h"

#define RTC_PIN GPIO_NUM_33

DS3232RTC RTC(false);
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); // GDEH0154D67

void setup()
{
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0: updateTime(false); break; //RTC Alarm Interrupt
default: updateTime(true); //Hard Reset
}
esp_sleep_enable_ext0_wakeup(RTC_PIN, 0); //enable deep sleep wake on RTC interrupt
esp_deep_sleep_start();
}

void loop(){}

void updateTime(bool reset)
{
RTC.begin();
if(reset){
RTC.squareWave(SQWAVE_NONE); //disable square wave output
RTC.set(compileTime()); //set RTC time to compile time
RTC.setAlarm(ALM2_EVERY_MINUTE, 0, 0, 0, 0);
RTC.alarmInterrupt(ALARM_2, true); //enable alarm interrupt
}
RTC.alarm(ALARM_2); //resets the alarm flag in the RTC
tmElements_t currentTime;
RTC.read(currentTime);

display.init(0, reset); //_initial_refresh to false to prevent full update on init
display.setFullWindow();
display.fillScreen(GxEPD_WHITE);
display.drawBitmap(0, 0, pokemon, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
display.setTextColor(GxEPD_BLACK);
display.setFont(&FreeMonoBold12pt7b);
display.setCursor(10, 170);

if(currentTime.Hour < 10){
display.print('0');
}
display.print(currentTime.Hour);
display.print(':');
if(currentTime.Minute < 10){
display.print('0');
}
display.print(currentTime.Minute);
display.display(true); //partial refresh
display.hibernate();
}

time_t compileTime()
{
const time_t FUDGE(10); //fudge factor to allow for upload time, etc. (seconds, YMMV)
const char *compDate = __DATE__, *compTime = __TIME__, *months = "JanFebMarAprMayJunJulAugSepOctNovDec";
char compMon[3], *m;

strncpy(compMon, compDate, 3);
compMon[3] = '\0';
m = strstr(months, compMon);

tmElements_t tm;
tm.Month = ((m - months) / 3 + 1);
tm.Day = atoi(compDate + 4);
tm.Year = atoi(compDate + 7) - 1970;
tm.Hour = atoi(compTime);
tm.Minute = atoi(compTime + 3);
tm.Second = atoi(compTime + 6);

time_t t = makeTime(tm);
return t + FUDGE; //add fudge factor to allow for compile time
}
Loading

0 comments on commit 82dfc42

Please sign in to comment.