Skip to content

Write your own watchface

Szybet edited this page Jan 17, 2025 · 1 revision

Notes:

  • The wiki is bare bones, feel free to ask if something is not clear, then I will improve the wiki

TLDR: Here is a pull request adding a watchface, you can use it as a template of sorts: https://github.com/Szybet/InkWatchy/pull/16

  1. Copy src/ui/watchface/watchfaces/shades_Szybet as a template for you watchface, like src/ui/watchface/watchfaces/myNewWatchface_MyNick and rename the files in the directory accordingly
  2. go to config.h (And later add it to src/defines/templates/gifnoc-template.h too) and add a define for you watchface, next to the other defines of other watchfaces
  3. In your files in your new directory, change the old macro conditions to use your new define
  4. In src/defines/defines.h add your new header file like the other watchfaces are added
  5. rename the const watchfaceDefOne variable name to something new
  6. in src/ui/watchface/watchfaceManagers/wManageAll.cpp add your new watchfaceDef, just like the others are, then add it watchfacesList

Now when flashing and selecting the watchface, it should just show the exact copy of the watchface you copied. Also disabling it should just disable it and still compile.

  1. Modify the functions that are put in your watchfaceDefOne, to know what they are doing, when they are called look up comments in src/ui/watchface/watchfaceManagers/wManageOne.h To know how to do things, look up other watchfaces that are using this "One" mode
  2. If you want to implement watchface modules, it's possible but will require more work, look up inkfield watchface for reference
  3. If you want to use custom resources (Fonts, Images) in your watchface, for images look up resources/tools/images/img/condition and for fonts resources/tools/fonts/condition. It's like that for making it modular, if you disable a watchface and regenerate resources, those that are not needed won't be generated
  4. If you want persistent data between boots (RTC memory, RTC_DATA_ATTR), look up src/hardware/rtcMem/rtcMem.h and add things like the others are there. Why it's like that? To use bit fields to preserve memory (mostly with bools). Moving to this method saved a whole byte - we have only 8 to use

Some possible questions:

The "One" mode is limiting me

It's just one way of doing things, look up src/ui/watchface/watchfaces/analogSharp_Szybet/analogSharp.cpp for something more bare bones and unlimited. Using this mode forces you to add some logic to your watchface. It's present in analogSharp already.

I don't like the structure of either methods

Develop your own, look up src/ui/watchface/watchfaceManagers and in src/ui/watchface/watchfaceManagers/wManageAll.cpp the watchfaceManageAll function. Just create your own "Watchface manager". You can do it in objects and classes, or even do a compatibility layer for watchfaces from other firmwares :D