mirror of https://github.com/sqfmi/Watchy.git
Seperating the watch managment and watch face, so we can have multiple watch faces
parent
2b96e25364
commit
8ec4b0a8ee
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class CWatchFace
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,90 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <WiFiManager.h>
|
||||||
|
#include <HTTPClient.h>
|
||||||
|
#include <NTPClient.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
#include <Arduino_JSON.h>
|
||||||
|
#include <GxEPD2_BW.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||||
|
#include "DSEG7_Classic_Bold_53.h"
|
||||||
|
#include "WatchyRTC.h"
|
||||||
|
#include "BLE.h"
|
||||||
|
#include "bma.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
typedef struct weatherData{
|
||||||
|
int8_t temperature;
|
||||||
|
int16_t weatherConditionCode;
|
||||||
|
bool isMetric;
|
||||||
|
String weatherDescription;
|
||||||
|
}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
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static WatchyRTC RTC;
|
||||||
|
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
||||||
|
tmElements_t currentTime;
|
||||||
|
watchySettings settings;
|
||||||
|
public:
|
||||||
|
explicit Watchy(const watchySettings& s) : settings(s){} //constructor
|
||||||
|
void init(String datetime = "");
|
||||||
|
void deepSleep();
|
||||||
|
static void displayBusyCallback(const void*);
|
||||||
|
float getBatteryVoltage();
|
||||||
|
void vibMotor(uint8_t intervalMs = 100, uint8_t length = 20);
|
||||||
|
|
||||||
|
void handleButtonPress();
|
||||||
|
void showMenu(byte menuIndex, bool partialRefresh);
|
||||||
|
void showFastMenu(byte menuIndex);
|
||||||
|
void showAbout();
|
||||||
|
void showBuzz();
|
||||||
|
void showAccelerometer();
|
||||||
|
void showUpdateFW();
|
||||||
|
void showSyncNTP();
|
||||||
|
bool syncNTP();
|
||||||
|
bool syncNTP(long gmt, int dst, String ntpServer);
|
||||||
|
void setTime();
|
||||||
|
void setupWifi();
|
||||||
|
bool connectWiFi();
|
||||||
|
weatherData getWeatherData();
|
||||||
|
weatherData getWeatherData(String cityID, String units, String lang, String url, String apiKey, uint8_t updateInterval);
|
||||||
|
void updateFWBegin();
|
||||||
|
|
||||||
|
void showWatchFace(bool partialRefresh);
|
||||||
|
virtual void drawWatchFace(); //override this method for different watch faces
|
||||||
|
|
||||||
|
// Expanded
|
||||||
|
JSONVar& getWeatherJSON();
|
||||||
|
JSONVar& getWeatherJSON(String cityID, String units, String lang, String url, String apiKey,
|
||||||
|
uint8_t updateInterval);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _bmaConfig();
|
||||||
|
static void _configModeCallback(WiFiManager *myWiFiManager);
|
||||||
|
static uint16_t _readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
|
||||||
|
static uint16_t _writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern RTC_DATA_ATTR int guiState;
|
||||||
|
extern RTC_DATA_ATTR int menuIndex;
|
||||||
|
extern RTC_DATA_ATTR BMA423 sensor;
|
||||||
|
extern RTC_DATA_ATTR bool WIFI_CONFIGURED;
|
||||||
|
extern RTC_DATA_ATTR bool BLE_CONFIGURED;
|
File diff suppressed because it is too large
Load Diff
|
@ -1,90 +1,27 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
// STL
|
||||||
#include <WiFiManager.h>
|
#include <vector.h>
|
||||||
#include <HTTPClient.h>
|
|
||||||
#include <NTPClient.h>
|
// Defs
|
||||||
#include <WiFiUdp.h>
|
class CWatchFace;
|
||||||
#include <Arduino_JSON.h>
|
|
||||||
#include <GxEPD2_BW.h>
|
class CWatchyExpanded
|
||||||
#include <Wire.h>
|
{
|
||||||
#include <Fonts/FreeMonoBold9pt7b.h>
|
public:
|
||||||
#include "DSEG7_Classic_Bold_53.h"
|
CWatchyExpanded();
|
||||||
#include "WatchyRTC.h"
|
|
||||||
#include "BLE.h"
|
void AddWatchFace(CWatchFace* pFace);
|
||||||
#include "bma.h"
|
|
||||||
#include "config.h"
|
void Init();
|
||||||
|
|
||||||
typedef struct weatherData{
|
private:
|
||||||
int8_t temperature;
|
void displayBusyCallback(const void*);
|
||||||
int16_t weatherConditionCode;
|
void UpdateScreen();
|
||||||
bool isMetric;
|
|
||||||
String weatherDescription;
|
std::vector<CWatchFace*> m_faces;
|
||||||
}weatherData;
|
std::int8_t m_face = 0;
|
||||||
|
|
||||||
typedef struct watchySettings{
|
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> m_display;
|
||||||
//Weather Settings
|
tmElements_t m_currentTime;
|
||||||
String cityID;
|
};
|
||||||
String weatherAPIKey;
|
|
||||||
String weatherURL;
|
|
||||||
String weatherUnit;
|
|
||||||
String weatherLang;
|
|
||||||
int8_t weatherUpdateInterval;
|
|
||||||
//NTP Settings
|
|
||||||
String ntpServer;
|
|
||||||
int gmtOffset;
|
|
||||||
int dstOffset;
|
|
||||||
} watchySettings;
|
|
||||||
|
|
||||||
class WatchyExpanded
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static WatchyRTC RTC;
|
|
||||||
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
|
||||||
tmElements_t currentTime;
|
|
||||||
watchySettings settings;
|
|
||||||
public:
|
|
||||||
explicit WatchyExpanded(const watchySettings& s) : settings(s){} //constructor
|
|
||||||
void init(String datetime = "");
|
|
||||||
void deepSleep();
|
|
||||||
static void displayBusyCallback(const void*);
|
|
||||||
float getBatteryVoltage();
|
|
||||||
void vibMotor(uint8_t intervalMs = 100, uint8_t length = 20);
|
|
||||||
|
|
||||||
void handleButtonPress();
|
|
||||||
void showMenu(byte menuIndex, bool partialRefresh);
|
|
||||||
void showFastMenu(byte menuIndex);
|
|
||||||
void showAbout();
|
|
||||||
void showBuzz();
|
|
||||||
void showAccelerometer();
|
|
||||||
void showUpdateFW();
|
|
||||||
void showSyncNTP();
|
|
||||||
bool syncNTP();
|
|
||||||
bool syncNTP(long gmt, int dst, String ntpServer);
|
|
||||||
void setTime();
|
|
||||||
void setupWifi();
|
|
||||||
bool connectWiFi();
|
|
||||||
weatherData getWeatherData();
|
|
||||||
weatherData getWeatherData(String cityID, String units, String lang, String url, String apiKey, uint8_t updateInterval);
|
|
||||||
void updateFWBegin();
|
|
||||||
|
|
||||||
void showWatchFace(bool partialRefresh);
|
|
||||||
virtual void drawWatchFace(); //override this method for different watch faces
|
|
||||||
|
|
||||||
// Expanded
|
|
||||||
JSONVar& getWeatherJSON();
|
|
||||||
JSONVar& getWeatherJSON(String cityID, String units, String lang, String url, String apiKey,
|
|
||||||
uint8_t updateInterval);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void _bmaConfig();
|
|
||||||
static void _configModeCallback(WiFiManager *myWiFiManager);
|
|
||||||
static uint16_t _readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
|
|
||||||
static uint16_t _writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern RTC_DATA_ATTR int guiState;
|
|
||||||
extern RTC_DATA_ATTR int menuIndex;
|
|
||||||
extern RTC_DATA_ATTR BMA423 sensor;
|
|
||||||
extern RTC_DATA_ATTR bool WIFI_CONFIGURED;
|
|
||||||
extern RTC_DATA_ATTR bool BLE_CONFIGURED;
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#define WIFI_AP_TIMEOUT 60
|
#define WIFI_AP_TIMEOUT 60
|
||||||
#define WIFI_AP_SSID "Watchy AP"
|
#define WIFI_AP_SSID "Watchy AP"
|
||||||
//menu
|
//menu
|
||||||
#define WATCHFACE_STATE -1
|
constexpr std::int8_t kWatchFace_State -1
|
||||||
#define MAIN_MENU_STATE 0
|
#define MAIN_MENU_STATE 0
|
||||||
#define APP_STATE 1
|
#define APP_STATE 1
|
||||||
#define FW_UPDATE_STATE 2
|
#define FW_UPDATE_STATE 2
|
||||||
|
|
Loading…
Reference in New Issue