diff --git a/README.md b/README.md index 7f88e7e..32cba13 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,18 @@ # Modifications in this branch by John Heenan +### Hardware + +This code is for the T-Wristband from LilyGo at https://www.aliexpress.com/item/4000527495064.html with the previous hardware version with MPU9250 IMU. + +The code will be updated for the current T-Wristband on sale with LSM9DS1 IMU. + ### Uploading Firmware File -If you have got a working version of TioRuben's code on your T-Wristband then you can OTA the firmware file for this source code, firmware.bin from the release section of this github repo, tagged as v0.1a-alpha. +This OTA update method has been tested with the T-Wristband with firmware from source at https://github.com/TioRuben/TTGO-T-Wristband and https://github.com/johnheenan/TTGO-T-Wristband. + +It will be tested with firmware form other sources such as https://github.com/Xinyuan-LilyGO/T-Wristband and with original shipped firmware. + +If you have got a working version of TioRuben's code on your T-Wristband then you can OTA the firmware file for this source code, firmware.bin, from the release section of this github repo, tagged as v0.1c-alpha. It can be OTA uploaded to the T-Wristband with: @@ -36,7 +46,7 @@ So IMU can be toggled on or off by holding down the the button on the battery sc When IMU is toggled on you can view two extra screens (Compass Degrees and Temperature). You can also use movement gestures to wake the watch up from deep sleep. -Currently when the IMU is toggled off battery drain is reduced substantially, increasing the time required between battery recharges. This is for reasons: battery current in deep sleep is reduced with IMU off and the chance of accidental wake ups is reduced. When woken up the current used is dramatically increased compared to when in deep sleep, so accidental wake ups are a battery drain issue. +Currently when the IMU is toggled off battery drain is reduced substantially, increasing the time required between battery recharges. This is for two reasons: battery current in deep sleep is reduced with IMU off and the chance of accidental wake ups is reduced. When woken up the current used is dramatically increased compared to when in deep sleep, so accidental wake ups are a battery drain issue. When IMU is off you can use the button to wake up. @@ -72,7 +82,7 @@ The four choices are A region does not have to be a DST region to put an entry in (such as China and Brisbane) -You can code up to 100 in the timezones.cpp file. Each entry only requires one line. +You can code up to 100 DST regions in the timezones.cpp file and give each whatever name you want, up to 20 characters (but only the middle 12 or so charcters will be displayed). Each entry only requires one line. An up to 10 character zone code, such as "CST" is shown in the local time screen. If preferred you can use a 10 character code code such as as "+8hr" or "+10:30". You can also leave it blank as in "". ## NVS (as EEPROM) Settings preserved @@ -96,7 +106,7 @@ Internally, since the NTP library code tries many times to get an answer, the co The NTP library code was modified minimally. -A firmware ID screen such as "200513,jh,branch,tr" appears in the IMU on/off screen. 200513 means 13 May 2020. "jh,branch,tr" means branch of John Heenan from TioRuben. +A firmware ID screen such as "200515,jh,branch,tr" appears in the IMU on/off screen. 200513 means 13 May 2020. "jh,branch,tr" means branch of John Heenan from TioRuben. # From the version cloned from: diff --git a/include/clock.hpp b/include/clock.hpp index 1637ba8..43f7cd7 100644 --- a/include/clock.hpp +++ b/include/clock.hpp @@ -15,6 +15,7 @@ void initClock(); void rtcSleep(); RTC_Date getClockTime(); RTC_Date getUTCTime(time_t *utc=nullptr); +const char* getTZCode(); void setTime(RTC_Date datetime); void setNtpUtcDst(time_t utcNow); diff --git a/include/timezones.hpp b/include/timezones.hpp index 40ef63c..818b661 100644 --- a/include/timezones.hpp +++ b/include/timezones.hpp @@ -3,7 +3,7 @@ #include // for enums -#define DST_CODE_STRLEN_MAX 4 +#define DST_CODE_STRLEN_MAX 10 #define DST_REGION_STRLEN_MAX 20 #define DST_MAX 100 diff --git a/src/hardware/clock.cpp b/src/hardware/clock.cpp index ccfa7d3..ebd935f 100644 --- a/src/hardware/clock.cpp +++ b/src/hardware/clock.cpp @@ -108,6 +108,34 @@ RTC_Date getUTCTime(time_t *utc) return RTC_Date(utcStructure->tm_year + 1900, utcStructure->tm_mon + 1, utcStructure->tm_mday, utcStructure->tm_hour, utcStructure->tm_min, utcStructure->tm_sec); } +char buf1[10]; +const char *getTZCode() +{ + if (settings.tz_uses_dst) + { + if (ntp.isDST()) + return dst_array[dst_index].dst_code; + else + return dst_array[dst_index].std_code; + } + else + { + int hr = settings.tz_offset / 60; + int min = settings.tz_offset % 60; + char sign = ' '; + if (settings.tz_offset > 0) + sign = '+'; + else if (settings.tz_offset < 0) + sign = '-'; + if(hr<0) + hr=-hr; + if (min < 0) + min = -min; + snprintf(buf1, sizeof(buf1), "%c%02d:%02d", sign, hr, min); + return buf1; + } +} + void setTime(RTC_Date datetime) { rtc.setDateTime(datetime); diff --git a/src/hardware/timezones.cpp b/src/hardware/timezones.cpp index f4b1d93..ec3ef60 100644 --- a/src/hardware/timezones.cpp +++ b/src/hardware/timezones.cpp @@ -12,7 +12,7 @@ int dst_length; // doco Also only up to the first 100 entries will be allowed to show. Can change this by changing DST_MAX dst_t dst_array[] = { //doco there must be at least one try in adition to NULL {"Europe, Central", Last, Sun, "CEST", Mar, 2, 120, "CET", Oct, 3, 60}, //doco - {"China", Last, Sun, "CST", Mar, 2, 480, "CST", Oct, 3, 480}, //doco // no DST + {"China", Last, Sun, "", Mar, 2, 480, "", Oct, 3, 480}, //doco // no DST {"Brisbane", First, Sun, "AEST", Apr, 3, 600, "AEST", Oct, 2, 600}, // doco no DST QLD as represented by Brisbane {"Sydney", First, Sun, "AEDT", Apr, 3, 600, "AEST", Oct, 2, 660}, // doco {"NULL"}, // doco please do not delete this NULL line, it is vital. Entries after this line will not be visible diff --git a/src/pages/page-tz.cpp b/src/pages/page-tz.cpp index 0b9bb0d..0616f51 100644 --- a/src/pages/page-tz.cpp +++ b/src/pages/page-tz.cpp @@ -26,7 +26,7 @@ void handleBtnHeld() void actionTZ() { unsigned long oldmilis = millis(); - char buf1[40]; + char buf1[40]=""; bool tz_uses_dst = settings.tz_uses_dst; menu_state_t menu_tz_uses_dst_true = MENU_STAY; menu_state_t menu_tz_uses_dst_false = MENU_STAY; diff --git a/src/tft/wristband-tft.cpp b/src/tft/wristband-tft.cpp index b0ad917..b900bf1 100644 --- a/src/tft/wristband-tft.cpp +++ b/src/tft/wristband-tft.cpp @@ -1,4 +1,5 @@ #include "wristband-tft.hpp" +#include "clock.hpp" // for getDstCode TFT_eSPI tft = TFT_eSPI(); @@ -167,6 +168,12 @@ void displayDate(const uint8_t day, const uint8_t month, const uint16_t year, bo { tft.print(" **UTC**"); } + else + { + char buf1[40]; + snprintf(buf1, sizeof(buf1), " %s ", getTZCode()); + tft.print(buf1); + } } uint16_t displayHour(const uint8_t hour, const uint8_t minute, bool utc)