Wednesday, March 10, 2021

LilyGo T-Watch 2020 goes Back to The Future



The LilyGo T-Watch 2020 hit the market in May 2020. A programmable watch with reasonably small size (looking somehow like the Apple watch), based on the ESP32 processor with an accelerometer, plus Wifi and Bluetooth connectivity at a price of only $30-$40.

When I bought mine in December 2020, I thought I was already late to the party. But then, I started to search the web for great watch faces for the T_Watch and I did not find much. So, I decided to make my own, and share this. Being a fan of the "Back to the Future" trilogy, in which the topic of "time" is omnipresent, I decided to make a Back-to-the-Future fun watch - and to share this.

This watch is not a smart watch! It does neither use the Wifi nor Bluetooth connectivity of the watch (I wouldn't know what I would use this for anyway). This watch will just be fun to look at, and without WiFi and Bluetooth, but with a good power management, the watch will be able to run three or four days without charging.

T-Watch 2020 with Back-to-the-Future Time Circuits watch face

Setting up the programming environment

The very first step is to install and set up the Arduino IDE. I have described this in detail in another blog post: Lilygo TTGO T-Watch 2020: Getting Started / The Software Framework.


References

While I did not find many great watches, I found plenty of good information and example codes that helped me to understand specific details of the watch. The power management, in particular, is very important, in order to get a watch that does not have to be charged every day. Here I'm listing some references that were valuable and from which I benefited a lot when writing my code.

  • The SimpleWatch example that comes with the TTGO T-Watch library
  • A series of articles at diyprojects.io (also check the links to their other articles)
  • The code for "aGoodWatch" from Alex Goodyear
  • The article and code at instructables.com by Dan Geiger
  • An interesting "Wordclock" by instructable.com user ArduinoAndy

Requirements

As mentioned above, I wanted this to be a fun watch that can be used in every day life, which means that it needs a very efficient power management. Therefore, in this project I am not using the WiFi and Bluetooth which helps a lot to save power. It allows to reduce the CPU frequency of the watch (from nominal 80MHz out of a max of 240MHz) down to 30MHz. The graphics are all programmed using the TFT_eSPI library. In contrast to many common example codes that have tiny buttons in their settings menus, the Back-to-the-Future watch has large buttons which can easily accessed. 


Features

My Back-to-the-Future watch code features five different watchfaces, a stop watch, and a settings menu with four screens (two to customize the display, and two to set time and date). The different categories can be thought of as three rows: The middle one has the watch faces, to top one the stopwatch, and the bottom row the settings menu.
The watch can be in three states: 
  1.  Full operation with the display on 
  2.  After a few seconds of full operation, it turns to light sleep from which it can be quickly awakened. This is done either by a press on the button at the top right - a quick(!) double tap - or by rapidly moving the watch upwards and rotating it towards you.
  3. To save power (e.g. over night) the watch can be set to deep sleep, by pressing the button for 5 seconds. It takes another (approx. 2 sec) press of this button to wake it up, which takes about 5 seconds.
In a very bright environment, you can use a double tap on the screen to get the maximum screen brightness. The next time when the watch returns from light sleep, the brightness is back at the normal value.

Watchfaces

The watchfaces, include a fluxing flux capacitor, the time circuits (with the current date/time in the middle row, plus typical movie dates in the top/bottom rows), the speedometer plus the plutonium gauges, the SID spectrometer, and the entrance sign to the Mall (which randomly appears as either "Twin Pines Mall" or "Lone Pine Mall"). 


T-Watch 2020 with Back-to-the-Future watch faces

T-Watch 2020 with Back-to-the-Future watch faces

The user can cycle through those with horizontal swipes. There are three different modes of operation: Whenever the watch returns from light sleep it either presents you with a random face (a: random), the next face (b: cycle), or the same face that was displayed before it went to sleep (c: "fixed").

Stopwatch

If you swipe to the top row, you get the stopwatch, which is modeled after the one Doc Brown uses in his experiment with Einstein (except for the display color, since yellow is much brighter than red).


Menu with Settings

When, starting from the watchfaces, you swipe to the bottom row, you get an "entry" screen: "Enter the Settings - swipe" from which you can swipe into the settings. The additional entry screen prevents you from erroneously entering the actual settings and from unwanted changes of your setup.

Swiping to the right, you get to part one of the display settings where you can select 
  • how the watchfaces are diplayed (random, cycle, fixed - as described above) 
  • the format in which the time is displayed: 12h, 12h plus seconds, or 24h format
  • if the stepcounter is shown in the top left corner (on/off)
  • if the remaining battery percentage is dislayed in the top right corner (on/off) 


On part two of the display settings you can select
  • how long the watch stays on: 7 sec, 12 sec, or 20 sec (I prefer 7 sec which is long enough for me to read the time. I used 20 sec to make the video, without the watch turning off all the time. I also use the 20 sec setting if I just enjoy looking at the watch...)
  • three levels of brightness (low, med, high)
  • if you want the display to dim at night (between 10pm and 7am).
On the next two screens, you can set the time and date. Any changes that are made with the "+" and "-" buttons are only stored when the "SET TIME" and "SET DATE" buttons are pressed.  


Swiping to the row above brings you back to the watchfaces.

Installing the Code

The code can be obtained from my github repository https://github.com/mawob/bttfWatch.
From the green "Code" pulldown menu, select "Download ZiP"


Unzipping the file creates a folder "bttfWatch-main" which has all the relevant files. Rename the folder from "bttfWatch-main" to "bttfWatch" and move this into the Sketchbook folder of your Arduino IDE. Then open it from the File menu, connect your watch, upload, and enjoy your new watchface!
 


9 comments:

Anonymous said...

Thanks for posting your complete and working code. I have tried many so called examples and only the simple watch works from a github download. They all require some not included libraries. Again thanks

Markus said...

I'm glad it works for you. Thanks for your nice feedback!

Pedro said...

Hi Markus!
You have an example of a source code using sensor Wi-Fi?

Markus said...

Hi Pedro, sorry, no, I have not (yet) tried using WiFi with this watch. At some point, I plan to try it - just to see how it works. But it seems that the WiFi uses much battery, so the watch may hardly be able to operate a whole day without charging.

DaveW said...

Hi Markus,

Nice project, thanks.
A couple of comments:
1) the local time in the time circuits is in 12 hour format, but others are 24hr
2) the Stopwatch and Settings screens seem to be reverse of your documentation. Swiping down goes to the Settings Screen and Swiping up to the Stopwatch.

Also you're right about the WiFi etc. using power, I have had a flat battery several times.
Dave

Markus said...

Thank you for your nice comment.
On 1): Yes, all other clocks can be switched (in the settings) between 12h and 24h modes. Since the original Time Circuit is only in 12h mode, I decided that this one can not be changed, to resemble the original.
On 2): I am always unsure how to describe this: By swiping down, you get to the screen that is above the original screen (and vice versa).

DaveW said...

Markus,
I may have missed it somewhere, but how do I reset the step counter?

Dave

Markus said...

I don't think that this is possible - except by restarting the watch (power off & on).

DaveW said...

Markus,
I've found a bit of code to add to subroutines.ino. I haven't got my head around github yet, so this is my patch.

at Line 286

// dw add code to reset step count the day changes
uint8_t yday = 0; // dw yesterday

and
line 322

// dw reset step counter when day changes
if (dday != yday){
log_i("reset setcounter: %d != %d", dday, yday );
yday = dday; // set yesterday to today as flag that counter was reset
ttgo->bma->resetStepCounter();
}



regards
Dave