A board replacement for the classic Casio F-91W wristwatch
Find a file
Mikhail Svarichevsky 6b71711079
Precision watch update (#152)
* Intermediate changes

* Databank working

* Main commit for precision timing

First version where all functions are supposed to be working

* Fix math error in nanosec. File storage for location.

* Remove obsolete comments

* Missing page name on pages rotation - thanks to jeremy

* Delete file.diff

* Cleanup+tempchart

1) finetune must always reset last calibration time when doing non-0 time correction, even when you are not applying ppm correction.
2) Dithers over 31 periods not 10, more resolution with still no risk of overflow
3) Minute-boundery finetune fix. I also just got this 1-minute error after finetune...
4) Write frequency calibration value in 1 operation rather than 2. All RTC writes must be single operations to avoid partially correct data.
5) Some code cleanup
6) Tempchart face is added for temperature statistics

* Update set_time_hackwatch_face.c

* Math error in display code of finetune, allow to update correction time even without correction - by long alarm press

* Increase reliability of stopping & starting RTC timer

As it's quite dangerous operation

* hackwatch - days adjust down fix by long alarm

* unify style

* More comments & last style change

* Simulator support

RTC operations (watch_rtc_enable and watch_rtc_freqcorr_write) are in common libs.

* Unicode fix

* Crystal aging is now adjustable (AA page in nanosec - annual aging, ppm/year)

Aging is baked into fixed offset every time finetune is performed, as it relies on last adjustment time.

* Blink on non-0 page every minute in finetune to measure clock error

* Rolling back private changes

* Cleanup

* Cleanup

* Quality of life changes in nanosec

1. Does not calculate & apply ppm correction if less than 6 hours passed since previous adjustment (as it gives very high correction values which are unrealistic and unhelpful)
2. Idle timeout resets to face 0 only if no correction was made

* unify style

* Fix low-power errors in nanosec infrastructure, faster display in finetune

* Merge fix

* unify style

Co-authored-by: Jeremy O'Brien <neutral@fastmail.com>
Co-authored-by: joeycastillo <joeycastillo@utexas.edu>
2023-01-10 16:56:26 -05:00
.devcontainer Add Devcontainer as an easy dev environment option (#65) 2022-05-18 11:17:51 -04:00
.github/workflows Fix up build. 2022-11-02 08:28:03 +11:00
apps Merge branch 'main' of github.com:joeycastillo/Sensor-Watch into lfs 2022-08-02 08:17:26 -06:00
boards add support for latest board revision 2021-11-29 10:46:53 -05:00
images add pinout table for sensor boards 2021-08-05 17:31:01 -04:00
littlefs@40dba4a556 add littlefs module 2022-05-05 08:12:16 -05:00
movement Precision watch update (#152) 2023-01-10 16:56:26 -05:00
PCB added new sensor-board with the BMI270 IMU 2022-11-15 21:43:29 +05:30
tinyusb@f8288be03f add tinyusb as a git submodule 2021-12-05 19:35:29 +01:00
utils new standard firmware 2022-11-29 14:51:26 -06:00
watch-library Precision watch update (#152) 2023-01-10 16:56:26 -05:00
.gitignore Add .gitignore for build-sim 2022-11-03 09:32:58 +11:00
.gitmodules add littlefs module 2022-05-05 08:12:16 -05:00
Doxyfile bump library version 2022-05-06 17:12:51 -04:00
LICENSE.md fix typo 2021-08-17 13:59:10 -04:00
make.mk Separate emscripten build directory 2022-11-02 06:18:34 +11:00
README.md Merge pull request #138 from darigovresearch/main 2022-11-22 08:45:53 -06:00
rules.mk Disable all built-in Make rules 2022-10-08 22:23:30 +02:00

The Sensor Watch

The Sensor Watch is a board replacement for the classic Casio F-91W wristwatch. It is powered by a Microchip SAM L22 microcontroller with built-in segment LCD controller. You can write your own programs for the watch using the provided watch library, program the watch over USB using the built-in UF2 bootloader, and then install the board in your existing watch case to run your own software on your wrist.

image

Features:

  • ARM Cortex M0+ microcontroller
  • 32KHz crystal for real-time clock with alarm function
  • Ten digit segment LCD, plus five indicator segments
  • Three interrupt capable buttons
  • Red / green PWMable LED backlight
  • Optional piezo buzzer (requires some light soldering)
  • On-board USB Micro B connector
  • Reset button with double-tap UF2 bootloader
  • Nine-pin flex PCB connector

image

You may have noticed that there are no sensors on this board. That is by design: rather than pick sensors for you, the goal is to add a tiny flexible PCB with the sensors YOU want, and interface them over the nine-pin connector. The connector provides the following options for power and connectivity:

  • 3V power (nominal voltage from a CR2016 coin cell, can drop to ~2.7V)
  • An I²C interface with built-in pull-up resistors
  • Five general purpose IO pins, which can be configured as:
    • Five analog inputs
    • Five interrupt-capable digital inputs, with internal pull-up or pull-down resistors
    • Five digital outputs
    • SPI controller (with one spare analog / GPIO pin leftover)
    • One UART TX/RX pair (with three GPIO leftover)
    • Up to four PWM pins on two independent TC instances
    • Two external wake inputs that can wake from the ultra-low-power BACKUP mode
Pin Digital Interrupt Analog I2C SPI UART PWM Ext. Wake
A0 PB04 EIC/EXTINT[4] ADC/AIN[12]
SCL SCL
SERCOM1[1]
SDA SDA
SERCOM1[0]
A1 PB01 EIC/EXTINT[1] ADC/AIN[9] SCK
SERCOM3[3]
RX
SERCOM3[3]
TC3[1]
A2 PB02 EIC/EXTINT[2] ADC/AIN[10] MOSI
SERCOM3[0]
TX or RX
SERCOM3[0]
TC2[0] RTC/IN[1]
A3 PB03 EIC/EXTINT[3] ADC/AIN[11] CS
SERCOM3[1]
RX
SERCOM3[1]
TC2[1]
A4 PB00 EIC/EXTINT[0] ADC/AIN[8] MISO
SERCOM3[2]
TX or RX
SERCOM3[2]
TC3[0] RTC/IN[0]

These tiny “sensor boards” have a set outline, and the available area for your electronics is quite small (5.7 × 5.7 × 1 mm). Still, this is plenty of room for an environmental sensor, MEMS accelerometer or magnetometer and a couple of decoupling capacitors. Note that you will likely be limited to QFN and LGA type parts; SOICs are too large, and even SSOP packages are generally too thick. You can find reference designs for several sensor boards in the PCB/Sensor Boards directory within this repository.

Getting code on the watch

The watch library in this repository is very work-in-progress, but it should allow you to get started. To create a new project, copy the “starter-project” folder in the apps folder, and write your code in the app.c file.

You will need to install the GNU Arm Embedded Toolchain to build projects for the watch. The watch library has been tested with the 9-2019-q4-major version and the 10.3-2021.07 versions. If you're using Debian or Ubuntu, it should be sufficient to apt install gcc-arm-none-eabi.

To build your project, open your terminal and navigate to the project's make folder, then type make.

To install the project onto your Sensor Watch board, plug the watch into your USB port and double tap the tiny Reset button on the back of the board. You should see the LED light up red and begin pulsing. (If it does not, make sure you didnt plug the board in upside down). Once you see the “WATCHBOOT” drive appear on your desktop, type make install. This will convert your compiled program to a UF2 file, and copy it over to the watch.

Using the Movement framework

If you just want to make minor modifications and use existing code, start with the movement directory. You can build the default watch firmware with:

cd movement/make
make

Then copy movement/make/build/watch.uf2 to your watch. If you'd like to modify which faces are built, see movement_config.h.

You may want to test out changes in the emulator first. To do this, you'll need to install emscripten, then run:

cd movement/make
emmake make
python3 -m http.server -d build-sim

Finally, visit watch.html to see your work.

License

Different components of the project are licensed differently, see LICENSE.md.