From ec26c84da2b735d3d8acd87d7e3b7c2aff5407e5 Mon Sep 17 00:00:00 2001 From: sqfmi Date: Wed, 1 Dec 2021 18:34:42 -0500 Subject: [PATCH] fixed bugs and change temp. sensor --- library.json | 2 +- library.properties | 2 +- src/Watchy.cpp | 4 ++-- src/WatchyRTC.cpp | 15 +++++++++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/library.json b/library.json index 712e693..b6820da 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Watchy", - "version": "1.2.9", + "version": "1.2.10", "description": "Watchy - An Open Source E-Paper Watch by SQFMI", "authors": [ { diff --git a/library.properties b/library.properties index c805d75..b40895f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Watchy -version=1.2.9 +version=1.2.10 author=SQFMI maintainer=SQFMI sentence=Watchy - An Open Source E-Paper Watch by SQFMI diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 1a1ee9a..1ab935d 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -565,8 +565,8 @@ weatherData Watchy::getWeatherData(){ //turn off radios WiFi.mode(WIFI_OFF); btStop(); - }else{//No WiFi, use RTC Temperature - uint8_t temperature = RTC.temperature() / 4; //celsius + }else{//No WiFi, use internal temperature sensor + uint8_t temperature = sensor.readTemperature(); //celsius if(strcmp(TEMP_UNIT, "imperial") == 0){ temperature = temperature * 9. / 5. + 32.; //fahrenheit } diff --git a/src/WatchyRTC.cpp b/src/WatchyRTC.cpp index a03bd8a..3b6e558 100644 --- a/src/WatchyRTC.cpp +++ b/src/WatchyRTC.cpp @@ -62,7 +62,11 @@ void WatchyRTC::set(tmElements_t tm){ rtc_ds.set(t); }else{ rtc_pcf.setDate(tm.Day, _getDayOfWeek(tm.Day, tm.Month, tm.Year+YEAR_OFFSET_PCF), tm.Month, 0, tm.Year); - rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second); + rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second); + rtc_pcf.clearAlarm(); + int nextAlarmMinute = rtc_pcf.getMinute(); + nextAlarmMinute = (nextAlarmMinute == 59) ? 0 : (nextAlarmMinute + 1); + rtc_pcf.setAlarm(nextAlarmMinute, 99, 99, 99); } } @@ -70,12 +74,12 @@ uint8_t WatchyRTC::temperature(){ if(rtcType == DS3231){ return rtc_ds.temperature(); }else{ - return 25; + return 255; //error } } void WatchyRTC::_DSConfig(String datetime){ - if(datetime != NULL){ + if(datetime != ""){ tmElements_t tm; tm.Year = _getValue(datetime, ':', 0).toInt() - YEAR_OFFSET_DS;//offset from 1970, since year is stored in uint8_t tm.Month = _getValue(datetime, ':', 1).toInt(); @@ -93,7 +97,8 @@ void WatchyRTC::_DSConfig(String datetime){ } void WatchyRTC::_PCFConfig(String datetime){ - if(datetime != NULL){ + rtc_pcf.initClock(); + if(datetime != ""){ tmElements_t tm; tm.Year = _getValue(datetime, ':', 0).toInt(); tm.Month = _getValue(datetime, ':', 1).toInt(); @@ -102,12 +107,10 @@ void WatchyRTC::_PCFConfig(String datetime){ tm.Minute = _getValue(datetime, ':', 4).toInt(); tm.Second = _getValue(datetime, ':', 5).toInt(); - rtc_pcf.initClock(); //day, weekday, month, century(1=1900, 0=2000), year(0-99) rtc_pcf.setDate(tm.Day, _getDayOfWeek(tm.Day, tm.Month, tm.Year), tm.Month, 0, tm.Year - YEAR_OFFSET_PCF);//offset from 2000, since year is stored in uint8_t //hr, min, sec rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second); - } rtc_pcf.clearAlarm(); int nextAlarmMinute = rtc_pcf.getMinute();