The watch
Every lesson opens on the same wiring:
- The display: a 1.28 inch GC9A01 round display, 240 x 240, with its backlight on pin 6 so the watch can turn it off.
- The time: a DS3231 real-time clock on I2C at 0x68.
- Steps: an MPU6050 on the same bus at 0x69 (its AD0 pin high).
- Buttons: three pushbuttons, MODE on pin 2 (INT0, so it can wake the chip), UP on 3 and DOWN on 4.
The catalog lists this course on an ESP32-C3. It is built on the Uno, like the watch face and moon clock examples.
How it works
A round display. The GC9A01 is a square of memory behind round glass, so everything is drawn around (120, 120) inside a radius of 120.
The face. A hand ends at x = 120 + r sin, y = 120 - r cos. With no floating point hardware, sines come from a 16 entry table of sin(6 degrees x i) x 127, mirrored for the other three quarters. Each second the old hands are drawn again in black and the new ones drawn on top: a few hundred pixels instead of 57,600. The hour hand creeps a step every 12 minutes.
Real time. The DS3231 keeps time on a coin cell within about a minute a year, in BCD registers the sketch reads and writes over I2C.
Steps. A slow average of each axis is gravity; what is left is the wrist's motion. A step is counted when its magnitude rises through 150 mg, at most every 250 ms, and not again until it falls under half that. Mokxi's MPU6050 feels tilt, so swinging its pitch stands in for an arm swing.
Battery life. Idle for 8 seconds, the watch turns its backlight off, sends the display DISPOFF and powers down until MODE wakes it. At 30 mA for an hour a day and 0.25 mA the rest, that is 35.8 mAh a day: 5.6 days on 200 mAh.
Menus. A state machine of four screens (face, steps, stopwatch, set time): MODE moves on, and each screen owns what UP and DOWN do.
The course
Build a smartwatch gets there in seven lessons, each a sketch on the same wiring:
- A round display: drawing on round glass.
- Watch faces: hands from a sine table.
- RTC time: the DS3231 and BCD.
- Step counting: a peak detector on the wrist's motion.
- Battery life: a mAh budget and power-down.
- Menus: screens as a state machine.
- Project: a daily-wear watch: all of it together.
Every step but the last is checked against the running circuit.