TioRuben / TTGO-T-Wristband

First steps with TTGO T-Wristband
MIT License
65 stars 23 forks source link

Branch with menu for UTC Offsets and DST Regions #9

Open johnheenan opened 4 years ago

johnheenan commented 4 years ago

I have tagged a branch at https://github.com/johnheenan/TTGO-T-Wristband/tree/v0.1-alpha which adds menu for UTC Offsets and DST Regions as well as other improvements.

The tag is at the current head of the poweropts branch.

There is a firmware file attached which can be OTA uploaded if you have a working version of TioRuben's code.

johnheenan commented 4 years ago

Releases from poweropts branch on https://github.com/johnheenan/TTGO-T-Wristband are being updated so If interested please use latest release from https://github.com/johnheenan/TTGO-T-Wristband/releases on which there is a firmware.bin attached (some are a software only release when firmware.bin does not change).

I will keep the master branch on https://github.com/johnheenan/TTGO-T-Wristband in sync with the master branch on https://github.com/TioRuben/TTGO-T-Wristband.

Following is the start of the README for the current head of the poweropts branch.

Modifications in this branch by John Heenan

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.

It can be OTA uploaded to the T-Wristband with:

espota.py --auth=wristbandpass --progress -i <ip address> -f firmware.bin

For example if the screen shows IP address 192.168.1.177 then

espota.py --auth=wristbandpass --progress -i 192.168.1.177 -f firmware.bin

Screen changes

Screen Skipping in mod Long Press Original Long Press Modifed
Orange Local Time No Update Time with NTP Update Time with NTP
Green UTC Time No Update Time with NTP Set DST Region or UTC Offset
Battery Level No None Toggle IMU on or off for power saving
Orange Compass Degrees Yes in mod if IMU off Calibrate Compass Calibrate Compass
Red Temperature Yes in mod if IMU off None None
OTA (upgrade firmware) No Update firmware Update firmware
Deep Sleep Yes in mod if plugged in N/A N/A

In the original there are two types of key presses

Brief press changes screen and a key press of one second chooses an action

So IMU can be toggled on or off by holding down the the button on the battery screen

What toggling IMU on or off does

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.

When IMU is off you can use the button to wake up.

There is relevant information at https://github.com/TioRuben/TTGO-T-Wristband/issues/5

In May 2020 a new hardware version of the T-Wristband went on sale with a different IMU and without a pullup resistor on an interrupt line. The pullup resistor on the previous version drains current unnecessarily in deep sleep due to keeping the interrupt line low during deep sleep.

With the hardware changes mentioned above and software changes in the future, toggling the IMU off may not be as big an issue.

Key Press Behaviour Changes For UTC and DST Menus

The behaviour of key presses change changes in the UTC action to change DST Regions or UTC Offsets

  1. A key press advances either the DST Regions or the UTC Offset screen.
  2. A key press of one second choose an option and backs out
  3. No key press for five seconds backs out and chooses nothing

UTC Offsets Menu

There are 49 choices: 48 for each half hour increment in day and a choice to move to DST Regions menu instead. If you choose DST regions then go back in to view after being backed out.

DST Regions Menu

The sample firmware had four choices and one other to move to UTC Offsets menu

If you choose UTC Offsets then go back to view after being backed out.

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.

NVS (as EEPROM) Settings preserved

If the settings structure has the same size as before then settings are preserved across firmware updates, unless the EEPROM_VER value in platformio.ini is changed

Additional Documentation and TODOs

There are strings in the code that partially serve as documentation. Just search or grep through code for "doco" and "todo jh", such as:

Miscellaneous Notes

platformio.ini documents various build time choices.

The WiFi Manager screen that appears if a WiFi connection fails shows name of AP to connect to (T-Wristband) and when connected what IP to use in a web browser. The screen now times out after two minutes

Internally, since the NTP library code tries many times to get an answer, the code only makes one attempt to get time the time through the library. If there is a failure, just try again later.

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.

From the version cloned from:

[As in README]