Update Bahn.ino
parent
3c114b0249
commit
6a9c7d207d
71
Bahn.ino
71
Bahn.ino
|
@ -1,6 +1,6 @@
|
||||||
#include <Watchy.h> //include the Watchy library
|
#include <Watchy.h> //include the Watchy library
|
||||||
#include <DIN_1451_Engschrift_Regular64pt7b.h>
|
#include <DIN_1451_Engschrift_Regular64pt7b.h>
|
||||||
#include <DIN_1451_Engschrift_Regular14pt7b.h>
|
#include <DIN_1451_Engschrift_Regular12pt7b.h>
|
||||||
|
|
||||||
|
|
||||||
class WatchFace : public Watchy { //inherit and extend Watchy class
|
class WatchFace : public Watchy { //inherit and extend Watchy class
|
||||||
|
@ -24,7 +24,7 @@ class WatchFace : public Watchy { //inherit and extend Watchy class
|
||||||
//draw hours
|
//draw hours
|
||||||
textstring = currentTime.Hour;
|
textstring = currentTime.Hour;
|
||||||
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
||||||
display.setCursor(184-w, 100-5-h);
|
display.setCursor(184-w, 100-5);
|
||||||
display.print(textstring);
|
display.print(textstring);
|
||||||
|
|
||||||
//draw minutes
|
//draw minutes
|
||||||
|
@ -35,53 +35,54 @@ class WatchFace : public Watchy { //inherit and extend Watchy class
|
||||||
}
|
}
|
||||||
textstring += currentTime.Minute;
|
textstring += currentTime.Minute;
|
||||||
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
||||||
display.setCursor(184-w, 100+5);
|
display.setCursor(183-w, 100+3+h);
|
||||||
display.print(textstring);
|
display.print(textstring);
|
||||||
|
|
||||||
// draw battery
|
// draw battery
|
||||||
display.fillRoundRect(16,16,34,12,4,light ? GxEPD_BLACK : GxEPD_WHITE);
|
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(49,20,3,4,2,light ? GxEPD_BLACK : GxEPD_WHITE);
|
||||||
display.fillRoundRect(17,17,32,10,3,light ? GxEPD_WHITE : GxEPD_BLACK);
|
display.fillRoundRect(18,18,30,8,3,light ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
float batt = (getBatteryVoltage()-3.8)/0.45;
|
float batt = (getBatteryVoltage()-3.8)/0.40;
|
||||||
if (batt > 0) {
|
if (batt > 0) {
|
||||||
display.fillRoundRect(18,18,30*batt,8,2,light ? GxEPD_BLACK : GxEPD_WHITE);
|
display.fillRoundRect(20,20,26*batt,4,2,light ? GxEPD_BLACK : GxEPD_WHITE);
|
||||||
|
}
|
||||||
// draw steps
|
|
||||||
display.setFont(&DIN_1451_Engschrift_Regular14pt7b);
|
display.setFont(&DIN_1451_Engschrift_Regular12pt7b);
|
||||||
textstring = sensor.getCounter();
|
lasty = 200 - 16;
|
||||||
textstring += " steps";
|
|
||||||
|
//draw steps
|
||||||
|
textstring = sensor.getCounter();
|
||||||
|
textstring += " steps";
|
||||||
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
||||||
display.setTextColor(light ? GxEPD_WHITE : GxEPD_BLACK);
|
display.fillRoundRect(16,lasty-h-2,w + 7,h+4,2,light ? GxEPD_BLACK : GxEPD_WHITE);
|
||||||
display.fillRoundRect(16,16,w+4,h+4,2,light ? GxEPD_BLACK : GxEPD_WHITE);
|
display.setCursor(19, lasty-3);
|
||||||
display.setCursor(18, 200-18-h);
|
display.setTextColor(light ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
display.print(textstring);
|
display.print(textstring);
|
||||||
lasty = 200-16-h-4;
|
display.setTextColor(light ? GxEPD_BLACK : GxEPD_WHITE);
|
||||||
|
lasty += -8-h;
|
||||||
// draw year
|
|
||||||
display.setTextColor(light ? GxEPD_BLACK : GxEPD_WHITE);
|
// draw year
|
||||||
textstring = currentTime.Year + 1970;
|
textstring = currentTime.Year + 1970;
|
||||||
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
||||||
display.setCursor(16, lasty - 6 - h);
|
display.setCursor(16, lasty);
|
||||||
display.print(textstring);
|
display.print(textstring);
|
||||||
lasty += -6-h;
|
lasty += -20;
|
||||||
|
|
||||||
// draw date
|
// draw date
|
||||||
textstring = monthShortStr(currentTime.Month);
|
textstring = monthShortStr(currentTime.Month);
|
||||||
textstring += " ";
|
textstring += " ";
|
||||||
textstring += currentTime.Day;
|
textstring += currentTime.Day;
|
||||||
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
||||||
display.setCursor(16, lasty - 6 - h);
|
display.setCursor(16, lasty);
|
||||||
display.print(textstring);
|
display.print(textstring);
|
||||||
lasty += -6-h;
|
lasty += -20;
|
||||||
|
|
||||||
// draw day
|
// draw day
|
||||||
textstring = dayStr(currentTime.Wday);
|
textstring = dayStr(currentTime.Wday);
|
||||||
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
||||||
display.setCursor(16, lasty - 6 - h);
|
display.setCursor(16, lasty);
|
||||||
display.print(textstring);
|
display.print(textstring);
|
||||||
lasty += -6-h;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue