Unified version 1.3.4. See Compilation Instructions.
This commit is contained in:
parent
7dea7ab45a
commit
050a0a94f1
@ -1,8 +1,7 @@
|
|||||||
#ifndef DEFINES_GSR_H
|
#ifndef DEFINES_GSR_H
|
||||||
#define DEFINES_GSR_H
|
#define DEFINES_GSR_H
|
||||||
|
|
||||||
// Watchy has the newer PCF8563 RTC clock.
|
#define __cplusplus 1
|
||||||
//#define PCF8563RTC 1
|
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
#define USEDEBUG 1 // !0 is on, will not setup Serial OR print output if zero.
|
#define USEDEBUG 1 // !0 is on, will not setup Serial OR print output if zero.
|
||||||
@ -10,7 +9,7 @@
|
|||||||
//display
|
//display
|
||||||
#define SOFTWARE_VERSION_MAJOR 1
|
#define SOFTWARE_VERSION_MAJOR 1
|
||||||
#define SOFTWARE_VERSION_MINOR 3
|
#define SOFTWARE_VERSION_MINOR 3
|
||||||
#define SOFTWARE_VERSION_PATCH 3
|
#define SOFTWARE_VERSION_PATCH 4
|
||||||
#define HARDWARE_VERSION_MAJOR 1
|
#define HARDWARE_VERSION_MAJOR 1
|
||||||
#define HARDWARE_VERSION_MINOR 0
|
#define HARDWARE_VERSION_MINOR 0
|
||||||
|
|
||||||
@ -107,11 +106,6 @@
|
|||||||
#define AlarmSetup 1234567890
|
#define AlarmSetup 1234567890
|
||||||
|
|
||||||
//pins
|
//pins
|
||||||
#ifndef PCF8563RTC
|
|
||||||
#define ADC_PIN 33
|
|
||||||
#else
|
|
||||||
#define ADC_PIN 35
|
|
||||||
#endif
|
|
||||||
#define RTC_PIN GPIO_NUM_27
|
#define RTC_PIN GPIO_NUM_27
|
||||||
#define CS 5
|
#define CS 5
|
||||||
#define DC 10
|
#define DC 10
|
||||||
|
|||||||
@ -138,12 +138,7 @@ RTC_DATA_ATTR struct dispUpdate {
|
|||||||
RTC_DATA_ATTR BMA423 sensor;
|
RTC_DATA_ATTR BMA423 sensor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PCF8563RTC
|
WatchyRTC WatchyGSR::RTC;
|
||||||
DS3232RTC WatchyGSR::RTC(false);
|
|
||||||
#else
|
|
||||||
PCF8563 WatchyGSR::RTC(false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> WatchyGSR::display(GxEPD2_154_D67(CS, DC, RESET, BUSY));
|
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> WatchyGSR::display(GxEPD2_154_D67(CS, DC, RESET, BUSY));
|
||||||
|
|
||||||
volatile uint8_t Button;
|
volatile uint8_t Button;
|
||||||
@ -197,7 +192,7 @@ void WatchyGSR::setupDefaults(){
|
|||||||
Steps.Minutes = 0;
|
Steps.Minutes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchyGSR::init(){
|
void WatchyGSR::init(String datetime){
|
||||||
uint64_t wakeupBit;
|
uint64_t wakeupBit;
|
||||||
int AlarmIndex, Pushed; // Alarm being played.
|
int AlarmIndex, Pushed; // Alarm being played.
|
||||||
bool WaitForNext, Pulse, DoOnce, B;
|
bool WaitForNext, Pulse, DoOnce, B;
|
||||||
@ -207,6 +202,7 @@ void WatchyGSR::init(){
|
|||||||
esp_sleep_wakeup_cause_t wakeup_reason;
|
esp_sleep_wakeup_cause_t wakeup_reason;
|
||||||
Wire.begin(SDA, SCL); //init i2c
|
Wire.begin(SDA, SCL); //init i2c
|
||||||
NVS.begin();
|
NVS.begin();
|
||||||
|
RTC.init();
|
||||||
|
|
||||||
pinMode(MENU_BTN_PIN, INPUT); // Prep these for the loop below.
|
pinMode(MENU_BTN_PIN, INPUT); // Prep these for the loop below.
|
||||||
pinMode(BACK_BTN_PIN, INPUT);
|
pinMode(BACK_BTN_PIN, INPUT);
|
||||||
@ -229,7 +225,7 @@ void WatchyGSR::init(){
|
|||||||
WatchTime.Drifting += Options.Drift;
|
WatchTime.Drifting += Options.Drift;
|
||||||
IDidIt = true;
|
IDidIt = true;
|
||||||
UpdateUTC();
|
UpdateUTC();
|
||||||
RTC.alarm(ALARM_2); //resets the alarm flag in the RTC
|
RTC.clearAlarm(); //resets the alarm flag in the RTC
|
||||||
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
||||||
WatchTime.NewMinute = true;
|
WatchTime.NewMinute = true;
|
||||||
RefreshCPU(CPUMAX);
|
RefreshCPU(CPUMAX);
|
||||||
@ -247,7 +243,7 @@ void WatchyGSR::init(){
|
|||||||
default: //reset
|
default: //reset
|
||||||
initZeros();
|
initZeros();
|
||||||
setupDefaults();
|
setupDefaults();
|
||||||
_rtcConfig();
|
RTC.config(datetime);
|
||||||
_bmaConfig();
|
_bmaConfig();
|
||||||
UpdateUTC();
|
UpdateUTC();
|
||||||
B = NVS.getString("GSR-TZ",S);
|
B = NVS.getString("GSR-TZ",S);
|
||||||
@ -1260,7 +1256,7 @@ void WatchyGSR::ProcessNTP(){
|
|||||||
}
|
}
|
||||||
WatchTime.UTC_RAW = time(nullptr);
|
WatchTime.UTC_RAW = time(nullptr);
|
||||||
breakTime(WatchTime.UTC_RAW,WatchTime.UTC);
|
breakTime(WatchTime.UTC_RAW,WatchTime.UTC);
|
||||||
RTC.write(WatchTime.UTC);
|
RTC.set(WatchTime.UTC);
|
||||||
WatchTime.Drifting = 0;
|
WatchTime.Drifting = 0;
|
||||||
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
||||||
WatchTime.WatchyRTC = esp_timer_get_time() + ((60 - WatchTime.UTC.Second) * 1000000);
|
WatchTime.WatchyRTC = esp_timer_get_time() + ((60 - WatchTime.UTC.Second) * 1000000);
|
||||||
@ -2143,14 +2139,6 @@ void WatchyGSR::ManageTime(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchyGSR::_rtcConfig() {
|
|
||||||
tmElements_t TM;
|
|
||||||
RTC.squareWave(SQWAVE_NONE); //disable square wave output
|
|
||||||
RTC.setAlarm(ALM2_EVERY_MINUTE, 0, 0, 0, 0); //alarm wakes up Watchy every minute
|
|
||||||
RTC.alarmInterrupt(ALARM_2, true); //enable alarm interrupt
|
|
||||||
RTC.read(TM);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WatchyGSR::_bmaConfig() {
|
void WatchyGSR::_bmaConfig() {
|
||||||
|
|
||||||
if (sensor.begin(_readRegister, _writeRegister, delay) == false) {
|
if (sensor.begin(_readRegister, _writeRegister, delay) == false) {
|
||||||
@ -2248,10 +2236,11 @@ void WatchyGSR::_bmaConfig() {
|
|||||||
|
|
||||||
float WatchyGSR::getBatteryVoltage(){
|
float WatchyGSR::getBatteryVoltage(){
|
||||||
float A, B, C, D;
|
float A, B, C, D;
|
||||||
A = analogRead(ADC_PIN) - 0.0125;
|
WatchyBatt Batt;
|
||||||
B = analogRead(ADC_PIN) - 0.0125;
|
A = Batt.Read(RTC) - 0.0125;
|
||||||
C = analogRead(ADC_PIN) - 0.0125;
|
B = Batt.Read(RTC) - 0.0125;
|
||||||
D = analogRead(ADC_PIN) - 0.0125;
|
C = Batt.Read(RTC) - 0.0125;
|
||||||
|
D = Batt.Read(RTC) - 0.0125;
|
||||||
return (((A + B + C + D) / 16384.0) * 7.23);
|
return (((A + B + C + D) / 16384.0) * 7.23);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,13 +15,11 @@
|
|||||||
#include <WiFiManager.h>
|
#include <WiFiManager.h>
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
#include <Arduino_JSON.h>
|
#include <Arduino_JSON.h>
|
||||||
#ifndef PCF8563RTC
|
|
||||||
#include <DS3232RTC.h>
|
#include <DS3232RTC.h>
|
||||||
#else
|
#include <Rtc_Pcf8563.h>
|
||||||
#include <PCF8563.h>
|
#include "WatchyBattery.h"
|
||||||
#endif
|
|
||||||
#include "GxEPD2_BW.h"
|
#include "GxEPD2_BW.h"
|
||||||
#include "mbedtls/base64.h"
|
#include <mbedtls/base64.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <bma.h>
|
#include <bma.h>
|
||||||
|
|
||||||
@ -37,15 +35,11 @@
|
|||||||
|
|
||||||
class WatchyGSR{
|
class WatchyGSR{
|
||||||
public:
|
public:
|
||||||
#ifndef PCF8563RTC
|
static WatchyRTC RTC;
|
||||||
static DS3232RTC RTC;
|
|
||||||
#else
|
|
||||||
static PCF8563 RTC;
|
|
||||||
#endif
|
|
||||||
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
||||||
public:
|
public:
|
||||||
WatchyGSR();
|
WatchyGSR();
|
||||||
void init();
|
void init(String datetime = "");
|
||||||
void showWatchFace();
|
void showWatchFace();
|
||||||
void drawWatchFace(); //override this method for different watch faces
|
void drawWatchFace(); //override this method for different watch faces
|
||||||
void drawTime();
|
void drawTime();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user