mirror of https://github.com/sqfmi/Watchy.git
Compare commits
5 Commits
7ffb458385
...
8ace9dba96
Author | SHA1 | Date |
---|---|---|
SQFMI | 8ace9dba96 | |
SQFMI | 2bfe297e7b | |
SQFMI | 79553f4abd | |
SQFMI | c5be1917a5 | |
sqfmi | 9f0ce88057 |
|
@ -1,6 +1,7 @@
|
||||||
#include "Watchy_7_SEG.h"
|
#include "Watchy_7_SEG.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
Watchy7SEG watchy;
|
Watchy7SEG watchy(settings);
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
watchy.init();
|
watchy.init();
|
||||||
|
|
|
@ -8,8 +8,6 @@ const uint8_t BATTERY_SEGMENT_SPACING = 9;
|
||||||
const uint8_t WEATHER_ICON_WIDTH = 48;
|
const uint8_t WEATHER_ICON_WIDTH = 48;
|
||||||
const uint8_t WEATHER_ICON_HEIGHT = 32;
|
const uint8_t WEATHER_ICON_HEIGHT = 32;
|
||||||
|
|
||||||
Watchy7SEG::Watchy7SEG(){} //constructor
|
|
||||||
|
|
||||||
void Watchy7SEG::drawWatchFace(){
|
void Watchy7SEG::drawWatchFace(){
|
||||||
display.fillScreen(DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);
|
display.fillScreen(DARKMODE ? GxEPD_BLACK : GxEPD_WHITE);
|
||||||
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.setTextColor(DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
|
@ -124,7 +122,7 @@ void Watchy7SEG::drawWeather(){
|
||||||
display.setCursor(159 - w - x1, 136);
|
display.setCursor(159 - w - x1, 136);
|
||||||
}
|
}
|
||||||
display.println(temperature);
|
display.println(temperature);
|
||||||
display.drawBitmap(165, 110, strcmp(TEMP_UNIT, "metric") == 0 ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
display.drawBitmap(165, 110, currentWeather.isMetric ? celsius : fahrenheit, 26, 20, DARKMODE ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
const unsigned char* weatherIcon;
|
const unsigned char* weatherIcon;
|
||||||
|
|
||||||
//https://openweathermap.org/weather-conditions
|
//https://openweathermap.org/weather-conditions
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
|
|
||||||
class Watchy7SEG : public Watchy{
|
class Watchy7SEG : public Watchy{
|
||||||
|
using Watchy::Watchy;
|
||||||
public:
|
public:
|
||||||
Watchy7SEG();
|
|
||||||
void drawWatchFace();
|
void drawWatchFace();
|
||||||
void drawTime();
|
void drawTime();
|
||||||
void drawDate();
|
void drawDate();
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
//Weather Settings
|
||||||
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||||
|
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
|
#define TEMP_LANG "en"
|
||||||
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
//NTP Settings
|
||||||
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
||||||
|
#define DST_OFFSET_SEC 3600
|
||||||
|
|
||||||
|
watchySettings settings{
|
||||||
|
CITY_ID,
|
||||||
|
OPENWEATHERMAP_APIKEY,
|
||||||
|
OPENWEATHERMAP_URL,
|
||||||
|
TEMP_UNIT,
|
||||||
|
TEMP_LANG,
|
||||||
|
WEATHER_UPDATE_INTERVAL,
|
||||||
|
NTP_SERVER,
|
||||||
|
GMT_OFFSET_SEC,
|
||||||
|
DST_OFFSET_SEC
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include <Watchy.h>
|
#include <Watchy.h>
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
Watchy watchy;
|
Watchy watchy(settings);
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
watchy.init();
|
watchy.init();
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
//Weather Settings
|
||||||
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||||
|
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
|
#define TEMP_LANG "en"
|
||||||
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
//NTP Settings
|
||||||
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
||||||
|
#define DST_OFFSET_SEC 3600
|
||||||
|
|
||||||
|
watchySettings settings{
|
||||||
|
CITY_ID,
|
||||||
|
OPENWEATHERMAP_APIKEY,
|
||||||
|
OPENWEATHERMAP_URL,
|
||||||
|
TEMP_UNIT,
|
||||||
|
TEMP_LANG,
|
||||||
|
WEATHER_UPDATE_INTERVAL,
|
||||||
|
NTP_SERVER,
|
||||||
|
GMT_OFFSET_SEC,
|
||||||
|
DST_OFFSET_SEC
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Watchy_DOS.h"
|
#include "Watchy_DOS.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
WatchyDOS watchy;
|
WatchyDOS watchy(settings);
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
watchy.init();
|
watchy.init();
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "Watchy_DOS.h"
|
#include "Watchy_DOS.h"
|
||||||
|
|
||||||
WatchyDOS::WatchyDOS(){} //constructor
|
|
||||||
|
|
||||||
void WatchyDOS::drawWatchFace(){
|
void WatchyDOS::drawWatchFace(){
|
||||||
char time[6];
|
char time[6];
|
||||||
time[0] = '0' + ((currentTime.Hour/10)%10);
|
time[0] = '0' + ((currentTime.Hour/10)%10);
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include "Px437_IBM_BIOS5pt7b.h"
|
#include "Px437_IBM_BIOS5pt7b.h"
|
||||||
|
|
||||||
class WatchyDOS : public Watchy{
|
class WatchyDOS : public Watchy{
|
||||||
|
using Watchy::Watchy;
|
||||||
public:
|
public:
|
||||||
WatchyDOS();
|
|
||||||
void drawWatchFace();
|
void drawWatchFace();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
//Weather Settings
|
||||||
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||||
|
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
|
#define TEMP_LANG "en"
|
||||||
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
//NTP Settings
|
||||||
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
||||||
|
#define DST_OFFSET_SEC 3600
|
||||||
|
|
||||||
|
watchySettings settings{
|
||||||
|
CITY_ID,
|
||||||
|
OPENWEATHERMAP_APIKEY,
|
||||||
|
OPENWEATHERMAP_URL,
|
||||||
|
TEMP_UNIT,
|
||||||
|
TEMP_LANG,
|
||||||
|
WEATHER_UPDATE_INTERVAL,
|
||||||
|
NTP_SERVER,
|
||||||
|
GMT_OFFSET_SEC,
|
||||||
|
DST_OFFSET_SEC
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Watchy_MacPaint.h"
|
#include "Watchy_MacPaint.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
WatchyMacPaint watchy;
|
WatchyMacPaint watchy(settings);
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
watchy.init();
|
watchy.init();
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
const unsigned char *numbers [10] = {numbers0, numbers1, numbers2, numbers3, numbers4, numbers5, numbers6, numbers7, numbers8, numbers9};
|
const unsigned char *numbers [10] = {numbers0, numbers1, numbers2, numbers3, numbers4, numbers5, numbers6, numbers7, numbers8, numbers9};
|
||||||
|
|
||||||
WatchyMacPaint::WatchyMacPaint(){} //constructor
|
|
||||||
|
|
||||||
void WatchyMacPaint::drawWatchFace(){
|
void WatchyMacPaint::drawWatchFace(){
|
||||||
display.fillScreen(GxEPD_WHITE);
|
display.fillScreen(GxEPD_WHITE);
|
||||||
display.drawBitmap(0, 0, window, DISPLAY_WIDTH, DISPLAY_HEIGHT, GxEPD_BLACK);
|
display.drawBitmap(0, 0, window, DISPLAY_WIDTH, DISPLAY_HEIGHT, GxEPD_BLACK);
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include "macpaint.h"
|
#include "macpaint.h"
|
||||||
|
|
||||||
class WatchyMacPaint : public Watchy{
|
class WatchyMacPaint : public Watchy{
|
||||||
|
using Watchy::Watchy;
|
||||||
public:
|
public:
|
||||||
WatchyMacPaint();
|
|
||||||
void drawWatchFace();
|
void drawWatchFace();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
//Weather Settings
|
||||||
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||||
|
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
|
#define TEMP_LANG "en"
|
||||||
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
//NTP Settings
|
||||||
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
||||||
|
#define DST_OFFSET_SEC 3600
|
||||||
|
|
||||||
|
watchySettings settings{
|
||||||
|
CITY_ID,
|
||||||
|
OPENWEATHERMAP_APIKEY,
|
||||||
|
OPENWEATHERMAP_URL,
|
||||||
|
TEMP_UNIT,
|
||||||
|
TEMP_LANG,
|
||||||
|
WEATHER_UPDATE_INTERVAL,
|
||||||
|
NTP_SERVER,
|
||||||
|
GMT_OFFSET_SEC,
|
||||||
|
DST_OFFSET_SEC
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Watchy_Pokemon.h"
|
#include "Watchy_Pokemon.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
WatchyPokemon watchy;
|
WatchyPokemon watchy(settings);
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
watchy.init();
|
watchy.init();
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "Watchy_Pokemon.h"
|
#include "Watchy_Pokemon.h"
|
||||||
|
|
||||||
WatchyPokemon::WatchyPokemon(){} //constructor
|
|
||||||
|
|
||||||
void WatchyPokemon::drawWatchFace(){
|
void WatchyPokemon::drawWatchFace(){
|
||||||
display.fillScreen(GxEPD_WHITE);
|
display.fillScreen(GxEPD_WHITE);
|
||||||
display.drawBitmap(0, 0, pokemon, DISPLAY_WIDTH, DISPLAY_HEIGHT, GxEPD_BLACK);
|
display.drawBitmap(0, 0, pokemon, DISPLAY_WIDTH, DISPLAY_HEIGHT, GxEPD_BLACK);
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include "pokemon.h"
|
#include "pokemon.h"
|
||||||
|
|
||||||
class WatchyPokemon : public Watchy{
|
class WatchyPokemon : public Watchy{
|
||||||
|
using Watchy::Watchy;
|
||||||
public:
|
public:
|
||||||
WatchyPokemon();
|
|
||||||
void drawWatchFace();
|
void drawWatchFace();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
//Weather Settings
|
||||||
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||||
|
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
|
#define TEMP_LANG "en"
|
||||||
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
//NTP Settings
|
||||||
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
||||||
|
#define DST_OFFSET_SEC 3600
|
||||||
|
|
||||||
|
watchySettings settings{
|
||||||
|
CITY_ID,
|
||||||
|
OPENWEATHERMAP_APIKEY,
|
||||||
|
OPENWEATHERMAP_URL,
|
||||||
|
TEMP_UNIT,
|
||||||
|
TEMP_LANG,
|
||||||
|
WEATHER_UPDATE_INTERVAL,
|
||||||
|
NTP_SERVER,
|
||||||
|
GMT_OFFSET_SEC,
|
||||||
|
DST_OFFSET_SEC
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -6,6 +6,7 @@
|
||||||
#include <Fonts/FreeSansBold9pt7b.h> //include any fonts you want to use
|
#include <Fonts/FreeSansBold9pt7b.h> //include any fonts you want to use
|
||||||
#include "MadeSunflower39pt7b.h"
|
#include "MadeSunflower39pt7b.h"
|
||||||
#include "stars.h"
|
#include "stars.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
#define STAR_COUNT 900
|
#define STAR_COUNT 900
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ struct xyPoint rotatePointAround(int x, int y, int ox, int oy, double angle) {
|
||||||
|
|
||||||
class StarryHorizon : public Watchy {
|
class StarryHorizon : public Watchy {
|
||||||
public:
|
public:
|
||||||
StarryHorizon() {
|
StarryHorizon(const watchySettings& s) : Watchy(s) {
|
||||||
// uncomment to re-generate stars
|
// uncomment to re-generate stars
|
||||||
// initStars();
|
// initStars();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +140,7 @@ class StarryHorizon : public Watchy {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
StarryHorizon face; //instantiate watchface
|
StarryHorizon face(settings); //instantiate watchface
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
face.init(); //call init in setup
|
face.init(); //call init in setup
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
//Weather Settings
|
||||||
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||||
|
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
|
#define TEMP_LANG "en"
|
||||||
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
//NTP Settings
|
||||||
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
||||||
|
#define DST_OFFSET_SEC 3600
|
||||||
|
|
||||||
|
watchySettings settings{
|
||||||
|
CITY_ID,
|
||||||
|
OPENWEATHERMAP_APIKEY,
|
||||||
|
OPENWEATHERMAP_URL,
|
||||||
|
TEMP_UNIT,
|
||||||
|
TEMP_LANG,
|
||||||
|
WEATHER_UPDATE_INTERVAL,
|
||||||
|
NTP_SERVER,
|
||||||
|
GMT_OFFSET_SEC,
|
||||||
|
DST_OFFSET_SEC
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Watchy_Tetris.h"
|
#include "Watchy_Tetris.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
WatchyTetris watchy;
|
WatchyTetris watchy(settings);
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
watchy.init();
|
watchy.init();
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "tetris.h"
|
#include "tetris.h"
|
||||||
|
|
||||||
class WatchyTetris : public Watchy{
|
class WatchyTetris : public Watchy{
|
||||||
|
using Watchy::Watchy;
|
||||||
public:
|
public:
|
||||||
WatchyTetris();
|
WatchyTetris();
|
||||||
void drawWatchFace();
|
void drawWatchFace();
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
//Weather Settings
|
||||||
|
#define CITY_ID "5128581" //New York City https://openweathermap.org/current#cityid
|
||||||
|
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
||||||
|
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?id=" //open weather api
|
||||||
|
#define TEMP_UNIT "metric" //metric = Celsius , imperial = Fahrenheit
|
||||||
|
#define TEMP_LANG "en"
|
||||||
|
#define WEATHER_UPDATE_INTERVAL 30 //must be greater than 5, measured in minutes
|
||||||
|
//NTP Settings
|
||||||
|
#define NTP_SERVER "pool.ntp.org"
|
||||||
|
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
||||||
|
#define DST_OFFSET_SEC 3600
|
||||||
|
|
||||||
|
watchySettings settings{
|
||||||
|
CITY_ID,
|
||||||
|
OPENWEATHERMAP_APIKEY,
|
||||||
|
OPENWEATHERMAP_URL,
|
||||||
|
TEMP_UNIT,
|
||||||
|
TEMP_LANG,
|
||||||
|
WEATHER_UPDATE_INTERVAL,
|
||||||
|
NTP_SERVER,
|
||||||
|
GMT_OFFSET_SEC,
|
||||||
|
DST_OFFSET_SEC
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Watchy",
|
"name": "Watchy",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"description": "Watchy - An Open Source E-Paper Watch by SQFMI",
|
"description": "Watchy - An Open Source E-Paper Watch by SQFMI",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,10 @@
|
||||||
"name": "Rtc_Pcf8563",
|
"name": "Rtc_Pcf8563",
|
||||||
"version": "https://github.com/orbitalair/Rtc_Pcf8563.git#master"
|
"version": "https://github.com/orbitalair/Rtc_Pcf8563.git#master"
|
||||||
},
|
},
|
||||||
{ "name": "GxEPD2" },
|
{
|
||||||
|
"name": "GxEPD2"
|
||||||
|
"version": "https://github.com/ZinggJM/GxEPD2.git#master"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "WiFiManager",
|
"name": "WiFiManager",
|
||||||
"version": "https://github.com/tzapu/WiFiManager.git#2.0.3-alpha"
|
"version": "https://github.com/tzapu/WiFiManager.git#2.0.3-alpha"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name=Watchy
|
name=Watchy
|
||||||
version=1.3.0
|
version=1.3.1
|
||||||
author=SQFMI
|
author=SQFMI
|
||||||
maintainer=SQFMI
|
maintainer=SQFMI
|
||||||
sentence=Watchy - An Open Source E-Paper Watch by SQFMI
|
sentence=Watchy - An Open Source E-Paper Watch by SQFMI
|
||||||
|
|
|
@ -9,11 +9,9 @@ RTC_DATA_ATTR BMA423 sensor;
|
||||||
RTC_DATA_ATTR bool WIFI_CONFIGURED;
|
RTC_DATA_ATTR bool WIFI_CONFIGURED;
|
||||||
RTC_DATA_ATTR bool BLE_CONFIGURED;
|
RTC_DATA_ATTR bool BLE_CONFIGURED;
|
||||||
RTC_DATA_ATTR weatherData currentWeather;
|
RTC_DATA_ATTR weatherData currentWeather;
|
||||||
RTC_DATA_ATTR int weatherIntervalCounter = WEATHER_UPDATE_INTERVAL;
|
RTC_DATA_ATTR int weatherIntervalCounter = -1;
|
||||||
RTC_DATA_ATTR bool displayFullInit = true;
|
RTC_DATA_ATTR bool displayFullInit = true;
|
||||||
|
|
||||||
Watchy::Watchy(){} //constructor
|
|
||||||
|
|
||||||
void Watchy::init(String datetime){
|
void Watchy::init(String datetime){
|
||||||
esp_sleep_wakeup_cause_t wakeup_reason;
|
esp_sleep_wakeup_cause_t wakeup_reason;
|
||||||
wakeup_reason = esp_sleep_get_wakeup_cause(); //get wake up reason
|
wakeup_reason = esp_sleep_get_wakeup_cause(); //get wake up reason
|
||||||
|
@ -561,18 +559,27 @@ void Watchy::drawWatchFace(){
|
||||||
}
|
}
|
||||||
|
|
||||||
weatherData Watchy::getWeatherData(){
|
weatherData Watchy::getWeatherData(){
|
||||||
if(weatherIntervalCounter >= WEATHER_UPDATE_INTERVAL){ //only update if WEATHER_UPDATE_INTERVAL has elapsed i.e. 30 minutes
|
return getWeatherData(settings.cityID, settings.weatherUnit, settings.weatherLang, settings.weatherURL, settings.weatherAPIKey, settings.weatherUpdateInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
weatherData Watchy::getWeatherData(String cityID, String units, String lang, String url, String apiKey, uint8_t updateInterval){
|
||||||
|
if(weatherIntervalCounter < 0){ //-1 on first run, set to updateInterval
|
||||||
|
weatherIntervalCounter = updateInterval;
|
||||||
|
}
|
||||||
|
if(weatherIntervalCounter >= updateInterval){ //only update if WEATHER_UPDATE_INTERVAL has elapsed i.e. 30 minutes
|
||||||
if(connectWiFi()){
|
if(connectWiFi()){
|
||||||
HTTPClient http; //Use Weather API for live data if WiFi is connected
|
HTTPClient http; //Use Weather API for live data if WiFi is connected
|
||||||
http.setConnectTimeout(3000);//3 second max timeout
|
http.setConnectTimeout(3000);//3 second max timeout
|
||||||
String weatherQueryURL = String(OPENWEATHERMAP_URL) + String(CITY_NAME) + String(",") + String(COUNTRY_CODE) + String("&units=") + String(TEMP_UNIT) + String("&appid=") + String(OPENWEATHERMAP_APIKEY);
|
String weatherQueryURL = url + cityID + String("&units=") + units + String("&lang=") + lang + String("&appid=") + apiKey;
|
||||||
http.begin(weatherQueryURL.c_str());
|
http.begin(weatherQueryURL.c_str());
|
||||||
int httpResponseCode = http.GET();
|
int httpResponseCode = http.GET();
|
||||||
if(httpResponseCode == 200) {
|
if(httpResponseCode == 200) {
|
||||||
String payload = http.getString();
|
String payload = http.getString();
|
||||||
JSONVar responseObject = JSON.parse(payload);
|
JSONVar responseObject = JSON.parse(payload);
|
||||||
currentWeather.temperature = int(responseObject["main"]["temp"]);
|
currentWeather.temperature = int(responseObject["main"]["temp"]);
|
||||||
|
currentWeather.isMetric = settings.weatherUnit == String("metric");
|
||||||
currentWeather.weatherConditionCode = int(responseObject["weather"][0]["id"]);
|
currentWeather.weatherConditionCode = int(responseObject["weather"][0]["id"]);
|
||||||
|
currentWeather.weatherDescription = responseObject["weather"][0]["main"];
|
||||||
}else{
|
}else{
|
||||||
//http error
|
//http error
|
||||||
}
|
}
|
||||||
|
@ -582,7 +589,7 @@ weatherData Watchy::getWeatherData(){
|
||||||
btStop();
|
btStop();
|
||||||
}else{//No WiFi, use internal temperature sensor
|
}else{//No WiFi, use internal temperature sensor
|
||||||
uint8_t temperature = sensor.readTemperature(); //celsius
|
uint8_t temperature = sensor.readTemperature(); //celsius
|
||||||
if(strcmp(TEMP_UNIT, "imperial") == 0){
|
if(units != String("metric")){
|
||||||
temperature = temperature * 9. / 5. + 32.; //fahrenheit
|
temperature = temperature * 9. / 5. + 32.; //fahrenheit
|
||||||
}
|
}
|
||||||
currentWeather.temperature = temperature;
|
currentWeather.temperature = temperature;
|
||||||
|
@ -904,7 +911,11 @@ void Watchy::showSyncNTP(){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Watchy::syncNTP(){ //NTP sync - call after connecting to WiFi and remember to turn it back off
|
bool Watchy::syncNTP(){ //NTP sync - call after connecting to WiFi and remember to turn it back off
|
||||||
configTime(GMT_OFFSET_SEC, DST_OFFSET_SEC, NTP_SERVER);
|
return syncNTP(settings.gmtOffset, settings.dstOffset, settings.ntpServer.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Watchy::syncNTP(long gmt, int dst, String ntpServer){ //NTP sync - call after connecting to WiFi and remember to turn it back off
|
||||||
|
configTime(gmt, dst, ntpServer.c_str());
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
if(!getLocalTime(&timeinfo)){
|
if(!getLocalTime(&timeinfo)){
|
||||||
return false; //NTP sync failed
|
return false; //NTP sync failed
|
||||||
|
|
21
src/Watchy.h
21
src/Watchy.h
|
@ -17,15 +17,32 @@
|
||||||
typedef struct weatherData{
|
typedef struct weatherData{
|
||||||
int8_t temperature;
|
int8_t temperature;
|
||||||
int16_t weatherConditionCode;
|
int16_t weatherConditionCode;
|
||||||
|
bool isMetric;
|
||||||
|
String weatherDescription;
|
||||||
}weatherData;
|
}weatherData;
|
||||||
|
|
||||||
|
typedef struct watchySettings{
|
||||||
|
//Weather Settings
|
||||||
|
String cityID;
|
||||||
|
String weatherAPIKey;
|
||||||
|
String weatherURL;
|
||||||
|
String weatherUnit;
|
||||||
|
String weatherLang;
|
||||||
|
int8_t weatherUpdateInterval;
|
||||||
|
//NTP Settings
|
||||||
|
String ntpServer;
|
||||||
|
int gmtOffset;
|
||||||
|
int dstOffset;
|
||||||
|
}watchySettings;
|
||||||
|
|
||||||
class Watchy {
|
class Watchy {
|
||||||
public:
|
public:
|
||||||
static WatchyRTC RTC;
|
static WatchyRTC RTC;
|
||||||
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
||||||
tmElements_t currentTime;
|
tmElements_t currentTime;
|
||||||
|
watchySettings settings;
|
||||||
public:
|
public:
|
||||||
Watchy();
|
explicit Watchy(const watchySettings& s) : settings(s){} //constructor
|
||||||
void init(String datetime = "");
|
void init(String datetime = "");
|
||||||
void deepSleep();
|
void deepSleep();
|
||||||
static void displayBusyCallback(const void*);
|
static void displayBusyCallback(const void*);
|
||||||
|
@ -41,10 +58,12 @@ class Watchy {
|
||||||
void showUpdateFW();
|
void showUpdateFW();
|
||||||
void showSyncNTP();
|
void showSyncNTP();
|
||||||
bool syncNTP();
|
bool syncNTP();
|
||||||
|
bool syncNTP(long gmt, int dst, String ntpServer);
|
||||||
void setTime();
|
void setTime();
|
||||||
void setupWifi();
|
void setupWifi();
|
||||||
bool connectWiFi();
|
bool connectWiFi();
|
||||||
weatherData getWeatherData();
|
weatherData getWeatherData();
|
||||||
|
weatherData getWeatherData(String cityID, String units, String lang, String url, String apiKey, uint8_t updateInterval);
|
||||||
void updateFWBegin();
|
void updateFWBegin();
|
||||||
|
|
||||||
void showWatchFace(bool partialRefresh);
|
void showWatchFace(bool partialRefresh);
|
||||||
|
|
10
src/config.h
10
src/config.h
|
@ -25,13 +25,6 @@
|
||||||
//display
|
//display
|
||||||
#define DISPLAY_WIDTH 200
|
#define DISPLAY_WIDTH 200
|
||||||
#define DISPLAY_HEIGHT 200
|
#define DISPLAY_HEIGHT 200
|
||||||
//weather api
|
|
||||||
#define CITY_NAME "NEW+YORK" //if your city name has a space, replace with '+'
|
|
||||||
#define COUNTRY_CODE "US"
|
|
||||||
#define OPENWEATHERMAP_APIKEY "f058fe1cad2afe8e2ddc5d063a64cecb" //use your own API key :)
|
|
||||||
#define OPENWEATHERMAP_URL "http://api.openweathermap.org/data/2.5/weather?q="
|
|
||||||
#define TEMP_UNIT "metric" //use "imperial" for Fahrenheit"
|
|
||||||
#define WEATHER_UPDATE_INTERVAL 30 //minutes
|
|
||||||
//wifi
|
//wifi
|
||||||
#define WIFI_AP_TIMEOUT 60
|
#define WIFI_AP_TIMEOUT 60
|
||||||
#define WIFI_AP_SSID "Watchy AP"
|
#define WIFI_AP_SSID "Watchy AP"
|
||||||
|
@ -49,9 +42,6 @@
|
||||||
#define SET_MONTH 3
|
#define SET_MONTH 3
|
||||||
#define SET_DAY 4
|
#define SET_DAY 4
|
||||||
#define HOUR_12_24 24
|
#define HOUR_12_24 24
|
||||||
#define NTP_SERVER "pool.ntp.org"
|
|
||||||
#define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5
|
|
||||||
#define DST_OFFSET_SEC 3600
|
|
||||||
//BLE OTA
|
//BLE OTA
|
||||||
#define BLE_DEVICE_NAME "Watchy BLE OTA"
|
#define BLE_DEVICE_NAME "Watchy BLE OTA"
|
||||||
#define WATCHFACE_NAME "Watchy 7 Segment"
|
#define WATCHFACE_NAME "Watchy 7 Segment"
|
||||||
|
|
Loading…
Reference in New Issue