Version 1.3.9.
This commit is contained in:
parent
5597a6a552
commit
be16bcd563
@ -118,6 +118,7 @@ RTC_DATA_ATTR struct TimeData final {
|
|||||||
int32_t Drifting; // The amount to add to UTC_RAW after reading from the RTC.
|
int32_t Drifting; // The amount to add to UTC_RAW after reading from the RTC.
|
||||||
int64_t WatchyRTC; // Counts Microseconds from boot.
|
int64_t WatchyRTC; // Counts Microseconds from boot.
|
||||||
bool DeadRTC; // Set when Drift fails to get a good count less than 30 seconds.
|
bool DeadRTC; // Set when Drift fails to get a good count less than 30 seconds.
|
||||||
|
uint8_t NextAlarm; // Next index that will need to wake the Watchy from sleep to fire.
|
||||||
} WatchTime;
|
} WatchTime;
|
||||||
|
|
||||||
RTC_DATA_ATTR struct Countdown final {
|
RTC_DATA_ATTR struct Countdown final {
|
||||||
@ -277,7 +278,6 @@ void WatchyGSR::init(String datetime){
|
|||||||
WatchTime.Drifting += Options.Drift;
|
WatchTime.Drifting += Options.Drift;
|
||||||
IDidIt = true;
|
IDidIt = true;
|
||||||
SRTC.resetWake();
|
SRTC.resetWake();
|
||||||
// SRTC.config("");
|
|
||||||
UpdateUTC();
|
UpdateUTC();
|
||||||
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
||||||
WatchTime.NewMinute = true;
|
WatchTime.NewMinute = true;
|
||||||
@ -294,8 +294,10 @@ void WatchyGSR::init(String datetime){
|
|||||||
if (Darkness.Went && UpRight()){
|
if (Darkness.Went && UpRight()){
|
||||||
if (Button == 5 && Options.SleepStyle > 1){ // Accelerometer caused this.
|
if (Button == 5 && Options.SleepStyle > 1){ // Accelerometer caused this.
|
||||||
if (Options.SleepMode == 0) Options.SleepMode = 2; // Do this to avoid someone accidentally not setting this before usage.
|
if (Options.SleepMode == 0) Options.SleepMode = 2; // Do this to avoid someone accidentally not setting this before usage.
|
||||||
|
UpdateClock(); // Make sure these are done during times when it won't.
|
||||||
Updates.Tapped = true; Darkness.Last=millis(); UpdateDisp = true; // Update Screen to new state.
|
Updates.Tapped = true; Darkness.Last=millis(); UpdateDisp = true; // Update Screen to new state.
|
||||||
}else if (Button == 6){ // Wrist.
|
}else if (Button == 6){ // Wrist.
|
||||||
|
UpdateClock(); // Make sure these are done during times when it won't.
|
||||||
Darkness.Last=millis(); UpdateDisp = true; // Do this anyways, always.
|
Darkness.Last=millis(); UpdateDisp = true; // Do this anyways, always.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +316,6 @@ void WatchyGSR::init(String datetime){
|
|||||||
RefreshCPU(CPUDEF);
|
RefreshCPU(CPUDEF);
|
||||||
WatchTime.WatchyRTC = esp_timer_get_time() + ((60 - WatchTime.UTC.Second) * 1000000);
|
WatchTime.WatchyRTC = esp_timer_get_time() + ((60 - WatchTime.UTC.Second) * 1000000);
|
||||||
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
WatchTime.EPSMS = (millis() + (1000 * (60 - WatchTime.UTC.Second)));
|
||||||
UpdateUTC();
|
|
||||||
UpdateClock();
|
UpdateClock();
|
||||||
AlarmIndex=0;
|
AlarmIndex=0;
|
||||||
UpdateFonts();
|
UpdateFonts();
|
||||||
@ -346,7 +347,6 @@ void WatchyGSR::init(String datetime){
|
|||||||
|
|
||||||
if (Button > 0) { handleButtonPress(Button); Button = 0; }
|
if (Button > 0) { handleButtonPress(Button); Button = 0; }
|
||||||
|
|
||||||
CalculateTones(); monitorSteps();
|
|
||||||
AlarmsOn =(Alarms_Times[0] > 0 || Alarms_Times[1] > 0 || Alarms_Times[2] > 0 || Alarms_Times[3] > 0 || TimerDown.ToneLeft > 0);
|
AlarmsOn =(Alarms_Times[0] > 0 || Alarms_Times[1] > 0 || Alarms_Times[2] > 0 || Alarms_Times[3] > 0 || TimerDown.ToneLeft > 0);
|
||||||
ActiveMode = (InTurbo() || DarkWait() || NTPData.State > 0 || AlarmsOn || WatchyAPOn || OTAUpdate || NTPData.TimeTest || WatchTime.DeadRTC || GSRWiFi.Requested);
|
ActiveMode = (InTurbo() || DarkWait() || NTPData.State > 0 || AlarmsOn || WatchyAPOn || OTAUpdate || NTPData.TimeTest || WatchTime.DeadRTC || GSRWiFi.Requested);
|
||||||
Sensitive = ((OTAUpdate && Menu.SubItem == 3) || (NTPData.TimeTest && Menu.SubItem == 2));
|
Sensitive = ((OTAUpdate && Menu.SubItem == 3) || (NTPData.TimeTest && Menu.SubItem == 2));
|
||||||
@ -621,7 +621,6 @@ void WatchyGSR::init(String datetime){
|
|||||||
if (UpdateDisp) showWatchFace(); //partial updates on tick
|
if (UpdateDisp) showWatchFace(); //partial updates on tick
|
||||||
if (!Updates.Init) { if (!(InTurbo() || DarkWait())) DisplaySleep(); }
|
if (!Updates.Init) { if (!(InTurbo() || DarkWait())) DisplaySleep(); }
|
||||||
|
|
||||||
CalculateTones(); monitorSteps();
|
|
||||||
AlarmsOn =(Alarms_Times[0] > 0 || Alarms_Times[1] > 0 || Alarms_Times[2] > 0 || Alarms_Times[3] > 0 || TimerDown.ToneLeft > 0);
|
AlarmsOn =(Alarms_Times[0] > 0 || Alarms_Times[1] > 0 || Alarms_Times[2] > 0 || Alarms_Times[3] > 0 || TimerDown.ToneLeft > 0);
|
||||||
ActiveMode = (InTurbo() || DarkWait() || NTPData.State > 0 || AlarmsOn || WatchyAPOn || OTAUpdate || NTPData.TimeTest || WatchTime.DeadRTC || GSRWiFi.Requested);
|
ActiveMode = (InTurbo() || DarkWait() || NTPData.State > 0 || AlarmsOn || WatchyAPOn || OTAUpdate || NTPData.TimeTest || WatchTime.DeadRTC || GSRWiFi.Requested);
|
||||||
|
|
||||||
@ -722,8 +721,8 @@ void WatchyGSR::drawMenu(){
|
|||||||
String O, S;
|
String O, S;
|
||||||
|
|
||||||
display.setFont(&aAntiCorona12pt7b);
|
display.setFont(&aAntiCorona12pt7b);
|
||||||
display.fillRect(0, Design.Menu.Top, MenuWidth, MenuHeight, BackColor());
|
//display.fillRect(0, Design.Menu.Top, MenuWidth, MenuHeight, BackColor());
|
||||||
display.drawBitmap(0, Design.Menu.Top, (Menu.Style == MENU_INOPTIONS) ? OptionsMenuBackground : MenuBackground, MenuWidth, MenuHeight, ForeColor());
|
display.drawBitmap(0, Design.Menu.Top, (Menu.Style == MENU_INOPTIONS) ? OptionsMenuBackground : MenuBackground, MenuWidth, MenuHeight, ForeColor(), BackColor());
|
||||||
display.setTextColor(Options.LightMode && Menu.Style != MENU_INNORMAL ? GxEPD_WHITE : GxEPD_BLACK);
|
display.setTextColor(Options.LightMode && Menu.Style != MENU_INNORMAL ? GxEPD_WHITE : GxEPD_BLACK);
|
||||||
switch (Menu.Item){
|
switch (Menu.Item){
|
||||||
case MENU_STEPS:
|
case MENU_STEPS:
|
||||||
@ -1186,19 +1185,30 @@ void WatchyGSR::drawData(String dData, byte Left, byte Bottom, WatchyGSR::DesOps
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WatchyGSR::deepSleep(){
|
void WatchyGSR::deepSleep(){
|
||||||
uint8_t I;
|
uint8_t I, N, D;
|
||||||
bool BT = (Options.SleepStyle == 2 && BedTime());
|
|
||||||
bool B = ((Options.SleepStyle == 1 || Options.SleepStyle > 2) || BT);
|
|
||||||
bool BatOk = (Battery.Last == 0 || Battery.Last > LowBattery);
|
bool BatOk = (Battery.Last == 0 || Battery.Last > LowBattery);
|
||||||
|
bool BT = (Options.SleepStyle == 2 && BedTime());
|
||||||
|
bool B = (((Options.SleepStyle == 1 || Options.SleepStyle > 2) || BT) && BatOk);
|
||||||
|
bool DM;
|
||||||
|
|
||||||
|
UpdateUTC(); UpdateClock(); UpdateBMA(); GoDark();
|
||||||
|
DM = (Darkness.Went && !TimerDown.Active);
|
||||||
|
D = WatchTime.Local.Wday + 1;
|
||||||
|
|
||||||
|
if (DM){
|
||||||
|
N = (WatchTime.UTC.Minute < 30 ? 30 : 60);
|
||||||
|
if (WatchTime.NextAlarm != 99){
|
||||||
|
if (Alarms_Minutes[WatchTime.NextAlarm] >= WatchTime.Local.Minute && Alarms_Minutes[WatchTime.NextAlarm] < N) N = Alarms_Minutes[WatchTime.NextAlarm];
|
||||||
|
}
|
||||||
|
if (N == 60 && WatchTime.Local.Hour == 23) D = constrain(D + 1, 1, 7);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateBMA();
|
|
||||||
GoDark();
|
|
||||||
if (Options.NeedsSaving) RecordSettings();
|
if (Options.NeedsSaving) RecordSettings();
|
||||||
DisplaySleep();
|
DisplaySleep();
|
||||||
for(I = 0; I < 40; I++) { pinMode(I, INPUT); }
|
for(I = 0; I < 40; I++) { pinMode(I, INPUT); }
|
||||||
esp_sleep_enable_ext1_wakeup(((B && !WatchTime.DeadRTC && BatOk) ? (BMA432_INT1_MASK | BMA432_INT2_MASK) : 0) | BTN_PIN_MASK, ESP_EXT1_WAKEUP_ANY_HIGH); //enable deep sleep wake on button press ... |ACC_INT_MASK
|
esp_sleep_enable_ext1_wakeup((B ? (BMA432_INT1_MASK | BMA432_INT2_MASK) : 0) | BTN_PIN_MASK, ESP_EXT1_WAKEUP_ANY_HIGH); //enable deep sleep wake on button press ... |ACC_INT_MASK
|
||||||
esp_sleep_enable_ext0_wakeup(RTC_PIN, 0); //enable deep sleep wake on RTC interrupt
|
esp_sleep_enable_ext0_wakeup(RTC_PIN, 0); //enable deep sleep wake on RTC interrupt
|
||||||
if (BT) SRTC.atMinuteWake((WatchTime.UTC.Minute < 30 ? 30 : 0));
|
if (DM) SRTC.atMinuteWake(N % 60, WatchTime.Local.Hour, D);
|
||||||
else SRTC.nextMinuteWake();
|
else SRTC.nextMinuteWake();
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
}
|
}
|
||||||
@ -1455,7 +1465,7 @@ void WatchyGSR::handleButtonPress(uint8_t Pressed){
|
|||||||
if (Darkness.Went && Options.SleepStyle == 4 && !WatchTime.DeadRTC && !Updates.Tapped) return; // No buttons unless a tapped happened.
|
if (Darkness.Went && Options.SleepStyle == 4 && !WatchTime.DeadRTC && !Updates.Tapped) return; // No buttons unless a tapped happened.
|
||||||
if (!UpRight()) return; // Don't do buttons if not upright.
|
if (!UpRight()) return; // Don't do buttons if not upright.
|
||||||
if (LastButton > 0 && (millis() - LastButton) < KEYPAUSE) return;
|
if (LastButton > 0 && (millis() - LastButton) < KEYPAUSE) return;
|
||||||
if (Darkness.Went) { Darkness.Last=millis(); UpdateDisp=true; return; } // Don't do the button, just exit.
|
if (Darkness.Went) { Darkness.Last=millis(); UpdateClock(); UpdateDisp=true; return; } // Don't do the button, just exit.
|
||||||
if ((NTPData.TimeTest || OTAUpdate) && (Pressed == 3 || Pressed == 4)) return; // Up/Down don't work in these modes.
|
if ((NTPData.TimeTest || OTAUpdate) && (Pressed == 3 || Pressed == 4)) return; // Up/Down don't work in these modes.
|
||||||
|
|
||||||
switch (Pressed){
|
switch (Pressed){
|
||||||
@ -2198,12 +2208,11 @@ void WatchyGSR::handleButtonPress(uint8_t Pressed){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WatchyGSR::UpdateUTC(){
|
void WatchyGSR::UpdateUTC(){
|
||||||
tmElements_t TM; // struct tm * tm;
|
|
||||||
if (!WatchTime.DeadRTC){
|
if (!WatchTime.DeadRTC){
|
||||||
SRTC.read(TM);
|
SRTC.read(WatchTime.UTC);
|
||||||
WatchTime.UTC_RAW = makeTime(TM) + (NTPData.TimeTest ? 0 : WatchTime.Drifting);
|
WatchTime.UTC_RAW = SRTC.MakeTime(WatchTime.UTC) + (NTPData.TimeTest ? 0 : WatchTime.Drifting);
|
||||||
}
|
}
|
||||||
breakTime(WatchTime.UTC_RAW,WatchTime.UTC);
|
SRTC.BreakTime(WatchTime.UTC_RAW,WatchTime.UTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchyGSR::UpdateClock(){
|
void WatchyGSR::UpdateClock(){
|
||||||
@ -2218,6 +2227,7 @@ void WatchyGSR::UpdateClock(){
|
|||||||
WatchTime.Local.Day = TM->tm_mday;
|
WatchTime.Local.Day = TM->tm_mday;
|
||||||
WatchTime.Local.Month = TM->tm_mon + 1;
|
WatchTime.Local.Month = TM->tm_mon + 1;
|
||||||
WatchTime.Local.Year = TM->tm_year;
|
WatchTime.Local.Year = TM->tm_year;
|
||||||
|
CalculateTones(); monitorSteps(); // Moved here for accuracy during Deep Sleep.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manage time will determine if the RTC is in use, will also set a flag to "New Minute" for the loop functions to see the minute change.
|
// Manage time will determine if the RTC is in use, will also set a flag to "New Minute" for the loop functions to see the minute change.
|
||||||
@ -2346,12 +2356,13 @@ void WatchyGSR::_bmaConfig() {
|
|||||||
sensor.setINTPinConfig(config, BMA4_INTR1_MAP);
|
sensor.setINTPinConfig(config, BMA4_INTR1_MAP);
|
||||||
|
|
||||||
struct bma423_axes_remap remap_data;
|
struct bma423_axes_remap remap_data;
|
||||||
remap_data.x_axis = 1;
|
remap_data.x_axis = 0; //1
|
||||||
remap_data.x_axis_sign = 0xFF;
|
remap_data.x_axis_sign = 1;//0xFF;
|
||||||
remap_data.y_axis = 0;
|
remap_data.y_axis = 1; //0
|
||||||
remap_data.y_axis_sign = 0xFF;
|
remap_data.y_axis_sign = 0;//0xFF;
|
||||||
remap_data.z_axis = 2;
|
remap_data.z_axis = 2;
|
||||||
remap_data.z_axis_sign = 0xFF;
|
remap_data.z_axis_sign = 1;//0xFF;
|
||||||
|
|
||||||
// Need to raise the wrist function, need to set the correct axis
|
// Need to raise the wrist function, need to set the correct axis
|
||||||
sensor.setRemapAxes(&remap_data);
|
sensor.setRemapAxes(&remap_data);
|
||||||
|
|
||||||
@ -2497,8 +2508,12 @@ void WatchyGSR::CheckAlarm(int I){
|
|||||||
bA = (Alarms_Hour[I] == WatchTime.Local.Hour && Alarms_Minutes[I] == WatchTime.Local.Minute);
|
bA = (Alarms_Hour[I] == WatchTime.Local.Hour && Alarms_Minutes[I] == WatchTime.Local.Minute);
|
||||||
if (!bA && Alarms_Times[I] == 0 && (Alarms_Active[I] & ALARM_TRIGGERED) != 0){
|
if (!bA && Alarms_Times[I] == 0 && (Alarms_Active[I] & ALARM_TRIGGERED) != 0){
|
||||||
Alarms_Active[I] &= ALARM_NOTRIGGER;
|
Alarms_Active[I] &= ALARM_NOTRIGGER;
|
||||||
}else if ((Alarms_Active[I] & B) == B){ // Active and Active Day.
|
}else if ((Alarms_Active[I] & B) == B && (Alarms_Active[I] & ALARM_TRIGGERED) == 0){ // Active and Active Day.
|
||||||
if (bA && Alarms_Times[I] == 0 && (Alarms_Active[I] & ALARM_TRIGGERED) == 0){
|
// Check alarm listed to see if it is earlier than the one slated.
|
||||||
|
if (Alarms_Hour[I] == WatchTime.Local.Hour && Alarms_Minutes[I] > WatchTime.Local.Minute && !bA){
|
||||||
|
if (WatchTime.NextAlarm == 99) WatchTime.NextAlarm = I; else if (Alarms_Minutes[I] < Alarms_Minutes[WatchTime.NextAlarm]) WatchTime.NextAlarm = I;
|
||||||
|
}
|
||||||
|
if (bA && Alarms_Times[I] == 0){
|
||||||
Alarms_Times[I] = 255;
|
Alarms_Times[I] = 255;
|
||||||
Alarms_Playing[I] = 30;
|
Alarms_Playing[I] = 30;
|
||||||
Darkness.Last=millis();
|
Darkness.Last=millis();
|
||||||
@ -2518,7 +2533,7 @@ void WatchyGSR::CheckCD(){
|
|||||||
uint16_t M = ((WatchTime.UTC_RAW - TimerDown.LastUTC) / 60);
|
uint16_t M = ((WatchTime.UTC_RAW - TimerDown.LastUTC) / 60);
|
||||||
uint16_t E;
|
uint16_t E;
|
||||||
|
|
||||||
if ( M > 0){
|
if (M > 0){
|
||||||
TimerDown.LastUTC = WatchTime.UTC_RAW;
|
TimerDown.LastUTC = WatchTime.UTC_RAW;
|
||||||
E = TimerDown.Mins + (TimerDown.Hours * 60) - M;
|
E = TimerDown.Mins + (TimerDown.Hours * 60) - M;
|
||||||
TimerDown.Hours = (E / 60);
|
TimerDown.Hours = (E / 60);
|
||||||
@ -2536,7 +2551,7 @@ void WatchyGSR::CheckCD(){
|
|||||||
// Counts the active (255) alarms/timers and after 3, sets them to lower values.
|
// Counts the active (255) alarms/timers and after 3, sets them to lower values.
|
||||||
void WatchyGSR::CalculateTones(){
|
void WatchyGSR::CalculateTones(){
|
||||||
uint8_t Count = 0;
|
uint8_t Count = 0;
|
||||||
CheckAlarm(0); CheckAlarm(1); CheckAlarm(2); CheckAlarm(3); CheckCD();
|
WatchTime.NextAlarm = 99; CheckAlarm(0); CheckAlarm(1); CheckAlarm(2); CheckAlarm(3); CheckCD();
|
||||||
if (Alarms_Times[0] > 0) Count++;
|
if (Alarms_Times[0] > 0) Count++;
|
||||||
if (Alarms_Times[1] > 0) Count++;
|
if (Alarms_Times[1] > 0) Count++;
|
||||||
if (Alarms_Times[2] > 0) Count++;
|
if (Alarms_Times[2] > 0) Count++;
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class WatchyGSR{
|
|||||||
static SmallRTC SRTC;
|
static SmallRTC SRTC;
|
||||||
static SmallNTP SNTP;
|
static SmallNTP SNTP;
|
||||||
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
||||||
static constexpr const char* Build = "1.3.8";
|
static constexpr const char* Build = "1.3.9";
|
||||||
enum DesOps {dSTATIC, dLEFT, dRIGHT, dCENTER};
|
enum DesOps {dSTATIC, dLEFT, dRIGHT, dCENTER};
|
||||||
public:
|
public:
|
||||||
WatchyGSR();
|
WatchyGSR();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user