T-watch-2020
a watch project for the TTGO T-watch-2020 version 1
This work is licensed under the BSD 3-clause license. See LICENSE.txt.
This builds with Arduino IDE version 1.8.13. It also requires:
This is a "sketch" in Arduino parlance, not a library. That means you should do the "git clone" or unpack the zip file in the place where your Arduino sketches live. It also means that you should rename the directory in which the code lives to "DudleyWatch", so it matches the name of the .ino file. Or change the name of the .ino file to be the same as the directory (but with the .ino extension); I think either one should work.
Also note that when building with the Arduino IDE, you must set the partitioning to the special T-watch partitioning scheme: 2x6.5 MB APP, 3.6MB SPIFFS.
For more on building this sketch, see Using this code on your watch, below. For beginner/newbie instructions, starting from "I have a
computer, but have not installed Arduino", then read these beginner instructions.
I took bits from Dan Geiger's watch code (https://www.instructables.com/Lilygo-T-Watch-2020-Arduino-Framework/),
and bits from SimpleWatch (the shipped demo), and added many new features.
Existing Features
- Dan's Jupiter's moon's calculator is mostly unchanged.
- Dan's accelerometer demo is now tarted up a little as a "Level"
- Dan's battery app is mostly unchanged.
- Dan's "Basic" watch face has been enhanced with step counter, battery charge icon.
- Dan's "LCARS" watch face has been enhanced with step counter, battery charge icon, more.
- Dan's Bitcoin app is mostly unchanged.
New Features
- choice of Analog, "Basic digital", "LilyGoGui", or LCARS watch face. LCARS and Basic are derived from Dan Geiger's watch. LilyGoGui derived from the demo code that comes with the watch.
- The ability to show time in your local time zone plus your home time zone if you're travelling
- If you attempt to use WiFi with an unfamiliar access point, the watch will open a page where you can choose from the available SSIDs and then enter the password associated with that SSID. This information is stored in a "file" in the SPIFFs part of the flash. This is not overwritten when you re-upload the program from the Arduino IDE, so your WiFi SSID's and passwords are stored "forever".
- step counter (can be disabled in Settings)
- MQTT monitor and control (for your home automation system, for example)
- 9 pages of Settings in three groups (alarm, weather and "other") using the LVGL framework. Settings are stored in EEPROM.
- A "maze" game. Swipe or tilt watch left, right, up, down to move your cursor. Try to move it to the red endpoint. CW circle gesture to exit.
- A simple stopwatch. Beep function added by Frank Scholl (Fra4prg) on 2021-01-13. Documentation for the beep function is here. A Tea Timer function was added by Frank Scholl (Fra4prg) on 2021-01-31. Documentation for that feature is here.
- A function to set the time from NTP. If that fails, run's Dan Geiger's "SetTime" app.
- Storage for multiple WiFi credential sets, so the watch can connect to any SSID you regularly visit
- An alarm clock function. Alarm is interpreted in the current timezone, so 08:00 is always 08:00 local time.
- The world's stupidest "paint" program
- Polish postfix scientific calculator.
- Conway's game of life. (No user controls, "yet"). Randomly populates the "board" and runs forever. Touch the screen to exit.
- Recognition of 6 gestures (left, right, up, down, cw circle, ccw circle). (The FT6236 chip claims to recognize gestures, but it doesn't.)
- Battery level icon, "is plugged into charger" icon, and step counter icon.
- A Mandelbrot/Julia set app, written by "FabriceA6" (sorry, I couldn't find better attribution).
- The WiFi access points database is now stored in a file acc_pts.txt in the SPIFFs filesystem. If you try to use any WiFi app to connect to a new access point, the app will open up a settings page where you can enter the password and timezone for this new access point, and then it will be appended to the file acc_pts.txt.
- Most clocks (not LCARS) now can show either 12 or 24 hour clocks. Setting is controlled in 4th page of Settings app.
- A simple calendar app. Shows one month at a time, and you can navigate to any month using +month, -month, +year, -year buttons. At compile time, you can define your own holidays and events like birthdays, which are highlighted different colors on the calendar display. Touch anywhere not on a button to exit the app.
- An app to allow deletion of WiFi access point from the internal flash storage (SPIFF file acc_pts.txt). This is useful if you enter the password incorrectly, or the password changes. Simply delete the SSID and then re-enter it by using the NTP Time app or the Weather app, which will ask you for the credentials when it fails to connect to wifi.
- A weather app. The app attempts to figure your location using your IP address, which works pretty well with WiFi that is not a cell phone hotspot. The reason cell phone hotspots give a bad location is that your cell data may be routed to a city 100 miles away before it gets a routable IP address and gets to the internet. So the weather location may be off by quite a bit when using a cell phone hotspot for connectivity. You'll need an OpenWeatherMap.org API key, which was free at time of writing. Also note the LIBRARY REQUIREMENT listed at the beginning of the file. The weather app shows today's conditions, the conditions for the next week, and any National Weather Service alerts if there are any for "your" location. Swipe left and right to see different pages, swipe down to exit.
- A weather settings app. Allows you to set your home latitude, home longitude, the openweathermap.org API key, and metric/imperial units. When changing a text box content, make sure to hit the check icon on the keyboard to tell the GUI that you've made a change.
- A WiFi scanner app. It supplies two views: (1) list of access points, channel, RSSI; (2) graphical representation, channel vs strength. Swipe left or right to switch views. Swipe down to exit.
- A Color Picker app. It displays a palette of many colors, and when you touch the screen, it displays the R,G,B values. To exit the app, touch the lower left corner (outlined with light grey lines).
Using this code on your watch
To use this code, edit personal_info.h to have the IP, port, username, password of your MQTT server (assuming you have one), plus your home latitiude, longitude, and city, and also your openweathermap.org API key. Edit my_WiFi.h to have the SSID's, passwords, and timezones of all the WiFi access points you want your watch to connect with. If you have an MQTT installation, edit appMQTT.h to change my topics to your topics. Finally, compile and upload to your watch.
warning about the LVGL User Interface
The LVGL UI is used to build the setup, WiFi, and alarm screens with all the dropdowns, buttons, etc. The text entry boxes put up a keyboard when touched. When you have finished entering your text into the box (WiFi password, for example), make sure that you hit the checkmark on the keyboard. This ensures that the characters you have entered are seen by the UI.
Gestures Mapping
From the watch display, the following gestures work:
- swipe down : go to app select screen
- swipe right : run Battery app to see battery charge level, etc.
- swipe left : go to alarm settings. If alarm is beeping, silence alarm.
- CW circle : run MQTT app
- CCW circle : run Settings app.
In the scientific calculator, the following gestures work:
- swipe right : exit app
- swipe down : push value onto stack
- swipe up : pop stack and discard the value
- swipe left : backspace to erase most recently typed digit
- CW circle : put the value of pi on the top of the stack (3.141...)
- CCW circle : switch to second keyboard, where most of the transcendental functions live, plus "CHS" (change sign), "CLX" (clear "x" or top of stack), swap X <-> Y
To compute 2 + 3, do: 2, swipe down, 3, +
Screen Shots
"LCARS" watch face
|
"LilyGoGui" watch face
|
Analog watch face
|
Conway's Life
|
settings page 4
|
alarm settings page 1
|
MQTT client sensor page
|
MQTT client control page
|
Stop Watch
|
Scientific Calculator page 1
|
Scientific Calculator page 2
|
Maze game
|
Weather App
|
WiFi scanner App
|
Stop Watch App
|
Stop Watch App, Tea Timer function
|
Stop Watch App, Tea Timer function
|
Stop Watch App, Tea Timer function
|