Updated weather to work with Watchy 1.3.2. Not quite right yet...
parent
3aef672c4f
commit
cdb56a9508
|
@ -1,9 +1,13 @@
|
|||
#include <Watchy.h> //include the Watchy library
|
||||
#include "settings.h" // stupid static constants
|
||||
#include "DIN_1451_Engschrift_Regular64pt7b.h"
|
||||
#include "DIN_1451_Engschrift_Regular12pt7b.h"
|
||||
#include "heavitas12pt7b.h"
|
||||
|
||||
// RTC_DATA_ATTR weatherData currentWeather;
|
||||
|
||||
class WatchFace : public Watchy { //inherit and extend Watchy class
|
||||
using Watchy::Watchy;
|
||||
public:
|
||||
//! Change these if you want light background, dark text
|
||||
uint16_t bg = GxEPD_BLACK;
|
||||
|
@ -32,7 +36,7 @@ class WatchFace : public Watchy { //inherit and extend Watchy class
|
|||
display.setFont(&DIN_1451_Engschrift_Regular12pt7b);
|
||||
display.setTextColor(fg);
|
||||
drawSteps( 8, 20 );
|
||||
drawDate( 8, 130 );
|
||||
drawDate( 8, 140 );
|
||||
display.setFont(&DIN_1451_Engschrift_Regular12pt7b);
|
||||
display.setTextColor(fg);
|
||||
|
||||
|
@ -40,18 +44,19 @@ class WatchFace : public Watchy { //inherit and extend Watchy class
|
|||
|
||||
lasty = 120;
|
||||
// weather things
|
||||
weatherData currentWeather = getWeatherData();
|
||||
int8_t temperature = currentWeather.temperature;
|
||||
int16_t weatherConditionCode = currentWeather.weatherConditionCode;
|
||||
textstring = currentWeather.weatherDescription;
|
||||
weatherData currentWeather = getWeatherData(settings.cityID, settings.weatherUnit,
|
||||
settings.weatherLang, settings.weatherURL,
|
||||
settings.weatherAPIKey, settings.weatherUpdateInterval);
|
||||
textstring = "";
|
||||
textstring += currentWeather.weatherDescription;
|
||||
display.getTextBounds(textstring, 0, 0, &x1, &y1, &w, &h);
|
||||
display.setCursor(16, lasty);
|
||||
display.print(textstring);
|
||||
lasty += -20;
|
||||
|
||||
// draw temperature
|
||||
textstring = temperature;
|
||||
if( weatherCelsius == true ) {
|
||||
textstring = currentWeather.temperature;
|
||||
if( currentWeather.isMetric ) {
|
||||
textstring += "~ C"; // ~ will be rendered as º
|
||||
} else {
|
||||
textstring += "~ F"; // ~ will be rendered as º
|
||||
|
@ -152,7 +157,7 @@ class WatchFace : public Watchy { //inherit and extend Watchy class
|
|||
}
|
||||
|
||||
#define BOXX (60)
|
||||
#define BOXY (60)
|
||||
#define BOXY (50)
|
||||
|
||||
void drawDate( uint8_t x, uint8_t y ) {
|
||||
int16_t x1;
|
||||
|
@ -195,15 +200,11 @@ class WatchFace : public Watchy { //inherit and extend Watchy class
|
|||
}
|
||||
};
|
||||
|
||||
WatchFace m; //instantiate your watchface
|
||||
WatchFace w(settings); //instantiate your watchface
|
||||
|
||||
void setup() {
|
||||
// Change this to use your own API key!
|
||||
// get an API key at: https://openweathermap.org/api
|
||||
String APIkey = String ("ca4849c5f0c3949bda419307e34a669e");
|
||||
// 4751935 == Chantilly, VA, USA
|
||||
m.setupWeather( 4751935, false, 30, String("en"), APIkey );
|
||||
m.init(); //call init in setup
|
||||
// Weather settings are in settings.h now
|
||||
w.init(); //call init in setup
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
Loading…
Reference in New Issue