Skip to content

Commit

Permalink
Edit README, add TZ information to clock
Browse files Browse the repository at this point in the history
Edit README with hardware model information and OTA upgrade information

Add either UTC offset or TZ code to clock screen (if code entered)
  • Loading branch information
johnheenan committed May 15, 2020
1 parent e5f0970 commit dc41b2a
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 7 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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.

Expand Down Expand 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

Expand All @@ -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:

Expand Down
1 change: 1 addition & 0 deletions include/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/timezones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <NTP.h> // for enums


#define DST_CODE_STRLEN_MAX 4
#define DST_CODE_STRLEN_MAX 10
#define DST_REGION_STRLEN_MAX 20
#define DST_MAX 100

Expand Down
28 changes: 28 additions & 0 deletions src/hardware/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hardware/timezones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pages/page-tz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/tft/wristband-tft.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "wristband-tft.hpp"
#include "clock.hpp" // for getDstCode

TFT_eSPI tft = TFT_eSPI();

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dc41b2a

Please sign in to comment.