main
Paco Hope 2021-12-28 10:11:59 -05:00
parent d2f0444533
commit 9652e0ac32
2 changed files with 177 additions and 5 deletions

View File

@ -93,8 +93,9 @@ const uint8_t DIN_1451_Engschrift_Regular12pt7bBitmaps[] PROGMEM = {
0x18, 0x70, 0x60, 0xFF, 0xF0, 0xC6, 0x10, 0xC2, 0x18, 0xC3, 0xFF, 0xC0,
0x3B, 0xD8, 0xC6, 0x31, 0x8C, 0x67, 0x30, 0xC6, 0x31, 0x8C, 0x63, 0x1E,
0x70, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE7, 0x8C, 0x63, 0x18, 0xC6, 0x30,
0xCE, 0x63, 0x18, 0xC6, 0x31, 0xBD, 0xC0, 0x38, 0x2F, 0xCF, 0x1F, 0xA0,
0xE0 };
0xCE, 0x63, 0x18, 0xC6, 0x31, 0xBD, 0xC0,
0x6F, 0xFF, 0xFF, 0x6F, 0xF0 // º symbol, normally 0xBA, stored at 0x7e
};
const GFXglyph DIN_1451_Engschrift_Regular12pt7bGlyphs[] PROGMEM = {
{ 0, 1, 1, 4, 0, 0 }, // 0x20 ' '
@ -191,11 +192,25 @@ const GFXglyph DIN_1451_Engschrift_Regular12pt7bGlyphs[] PROGMEM = {
{ 1104, 5, 20, 7, 0, -15 }, // 0x7B '{'
{ 1117, 2, 19, 5, 1, -15 }, // 0x7C '|'
{ 1122, 5, 20, 7, 1, -15 }, // 0x7D '}'
{ 1135, 11, 4, 16, 2, -9 } }; // 0x7E '~'
{ 1135, 4, 9, 6, 1, -15 } // 0x7E '~' replaced by 'º'
};
// Approx. 1818 bytes
const GFXfont DIN_1451_Engschrift_Regular12pt7b PROGMEM = {
(uint8_t *)DIN_1451_Engschrift_Regular12pt7bBitmaps,
(GFXglyph *)DIN_1451_Engschrift_Regular12pt7bGlyphs,
0x20, 0x7E, 27 };
0x20, 0xBA, 27 };
// Approx. 1813 bytes
// 'feet', 32x32px
// Generated using https://javl.github.io/image2cpp/
const unsigned char png_feet [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x01, 0xb7, 0x00, 0x00,
0x06, 0x87, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x18, 0xfc, 0x00, 0x00, 0x1b, 0xfc, 0x60, 0x00,
0x07, 0xfc, 0x70, 0x00, 0x07, 0xfc, 0x76, 0x00, 0x0f, 0xfc, 0x75, 0x80, 0x0f, 0xf8, 0x01, 0x00,
0x0f, 0xf0, 0x00, 0xc0, 0x0f, 0xe0, 0x78, 0xc0, 0x07, 0xe0, 0xfe, 0x30, 0x07, 0xe0, 0xff, 0x30,
0x07, 0xe0, 0xff, 0x80, 0x03, 0xe0, 0x7f, 0x80, 0x03, 0xf0, 0x3f, 0xc0, 0x03, 0xf8, 0x3f, 0xc0,
0x03, 0xfc, 0x3f, 0x80, 0x01, 0xfc, 0x3f, 0x80, 0x01, 0xfc, 0x3f, 0x00, 0x01, 0xf8, 0x7f, 0x00,
0x00, 0xf0, 0xfe, 0x00, 0x00, 0x01, 0xfc, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x07, 0xf8, 0x00,
0x00, 0x07, 0xf0, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x01, 0xc0, 0x00
};

157
PacoWatchyBahn.ino Normal file
View File

@ -0,0 +1,157 @@
#define TEMP_UNIT, "imperial"
#include <Watchy.h> //include the Watchy library
#include "DIN_1451_Engschrift_Regular64pt7b.h"
#include "DIN_1451_Engschrift_Regular12pt7b.h"
class WatchFace : public Watchy { //inherit and extend Watchy class
public:
void drawWatchFace() { //override this method to customize how the watch face looks
int16_t x1, y1, lasty;
uint16_t w, h;
String textstring;
bool light = false;
// ** UPDATE **
//resets step counter at midnight everyday
if(currentTime.Hour == 00 && currentTime.Minute == 00) {
sensor.resetStepCounter();
}
// ** DRAW **
//drawbg
display.fillScreen(light ? GxEPD_WHITE : GxEPD_BLACK);
display.fillRoundRect(2,2,196,196,8,light ? GxEPD_BLACK : GxEPD_WHITE);
display.fillRoundRect(6,6,188,188,5,light ? GxEPD_WHITE : GxEPD_BLACK);
display.setFont(&DIN_1451_Engschrift_Regular64pt7b);
display.setTextColor(light ? GxEPD_BLACK : GxEPD_WHITE);
display.setTextWrap(false);
// draw hours with leading 0
if (currentTime.Hour < 10) {
textstring = "0";
} else {
textstring = "";
}
textstring += currentTime.Hour;
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(183-w, 100-5);
display.print(textstring);
//draw minutes
if (currentTime.Minute < 10) {
textstring = "0";
} else {
textstring = "";
}
textstring += currentTime.Minute;
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(183-w, 100+3+h);
display.print(textstring);
// draw battery
display.fillRoundRect(16,16,34,12,4,light ? GxEPD_BLACK : GxEPD_WHITE);
display.fillRoundRect(49,20,3,4,2,light ? GxEPD_BLACK : GxEPD_WHITE);
display.fillRoundRect(18,18,30,8,3,light ? GxEPD_WHITE : GxEPD_BLACK);
float batt = (getBatteryVoltage()-3.3)/0.9;
if (batt > 0) {
display.fillRoundRect(20,20,26*batt,4,2,light ? GxEPD_BLACK : GxEPD_WHITE);
}
display.setFont(&DIN_1451_Engschrift_Regular12pt7b);
lasty = 200 - 16;
// draw steps with footprint icon
textstring = sensor.getCounter();
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.drawBitmap(58, lasty-h-10, png_feet, 32, 32, GxEPD_WHITE);
display.setCursor(19, lasty-3);
display.print(textstring);
lasty += -8-h;
lasty += -10;
// draw date as DD MMM YY
textstring = currentTime.Day;
textstring += " ";
textstring += monthShortStr(currentTime.Month);
textstring += " ";
textstring += currentTime.Year;
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(16, lasty);
display.print(textstring);
lasty += -20;
// draw day
textstring = dayStr(currentTime.Wday);
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(16, lasty);
display.print(textstring);
lasty += -40;
// weather things
weatherData currentWeather = getWeatherData();
int8_t temperature = currentWeather.temperature;
int16_t weatherConditionCode = currentWeather.weatherConditionCode;
// draw weather state
if (weatherConditionCode >= 801) {
textstring = "Cloudy";
} else if (weatherConditionCode == 800) {
textstring = "Clear";
} else if (weatherConditionCode == 781) {
textstring = "Tornado";
} else if (weatherConditionCode == 771) {
textstring = "Squall";
} else if (weatherConditionCode == 762) {
textstring = "Ash";
} else if (weatherConditionCode == 761 || weatherConditionCode == 731) {
textstring = "Dust";
} else if (weatherConditionCode == 751) {
textstring = "Sand";
} else if (weatherConditionCode == 741) {
textstring = "Fog";
} else if (weatherConditionCode == 721) {
textstring = "Haze";
} else if (weatherConditionCode == 711) {
textstring = "Smoke";
} else if (weatherConditionCode == 701) {
textstring = "Mist";
} else if (weatherConditionCode >= 600) {
textstring = "Snow";
} else if (weatherConditionCode >= 500) {
textstring = "Rain";
} else if (weatherConditionCode >= 300) {
textstring = "Drizzle";
} else if (weatherConditionCode >= 200) {
textstring = "Thunderstorm";
} else {
textstring = "Ambient";
}
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(16, lasty);
display.print(textstring);
lasty += -20;
// draw temperature
textstring = temperature;
textstring += strcmp(TEMP_UNIT, "metric") == 0 ? "~ C" : "~ F"; // ~ will be rendered as º
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
display.setCursor(16, lasty);
display.print(textstring);
}
};
WatchFace m; //instantiate your watchface
void setup() {
m.init(); //call init in setup
}
void loop() {
// this should never run, Watchy deep sleeps after init();
}