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