1、#EMBEDDEDOSSUMMITBuilding an Open Source Smartwatch Using ZephyrJakob K What is ZSWatch Background Details Hardware Software AppsWhat is the talk about Embedded Developer at u-blox for 6 years.Currently working with Zephyr/nRF Connect on Nordic MCUs Always have some hobby project running.Often with
2、ESP32.3D printing.Mechanics.About me I call it ZSWatch(Zephyr Smart Watch)Naming inspired from the ZMK project(Zephyr Mechanical Keyboard)Hardware PCB(KiCAD)Mechanical casing(CAD)Dock Full BOM Software Application built on Zephyr AppsWhat is ZSWatch Open Source Smart WatchFirst some backgroundWhy bu
3、ild a Smart Watch?1.Wife gets pregnant.2.Everyone keeps telling you this is the end of all your hobby projects.3.Slight panic.4.Come up with a master plan.1.Smart Watch.2.Endless of possible features.5.Lots of late nights.6.9 Months later.There is a baby.AND an Open Source Smartwatch.Why Zephyr for
4、ZSWatch?BLE Low Power Avoid re-inventing the wheel*Big ecosystem Nordic+Zephyr obvious choice*Ignore we are building a Smart Watch from scratch:DMCU and environment requirements Can say ZSWatch is truly 100%Open Source Use of Zephyr Open Source BLE Controller From lowest layer BLE to the highest-lev
5、el application,the source is all there and openExtra bonuses by using ZephyrThe HardwareZephyr affected component selection Optimize hardware selection for quick bring-up.No time to write drivers from scratch.Limited time to debug.Browsing in https:/ to select sensors.Limited time 99%60 mA full brig
6、htness,30 mA 50%-LinearHandling low power Putting display in sleep Cutting power to the displayDepending on CONFIG_DISPLAY_FAST_WAKEUPHandling low powerProblemAvoiding unnecessary wakeupsReplace many different k_work_reschedule with oneOften periodic tasks are not strict on timingSolution Split peri
7、odic tasks into fixed intervals Fast,Medium,Slow Periods(e.g.100ms,1000ms,5000ms)Will cover most usesHandling low powerImplementation Use ZBUS Runtime Observers One ZBUS channel per period(Fast,Medium,Slow Periods,etc.)Wrap zbus_chan_add/rm_obs Only wakup with k_work_reschedule when observers are pr
8、esent for the period.Handling low powerDisplay+Touch in sleepDisabling 3V3 regulatorDisplay in RST Touch onWakeup timeInstant pretty much1sNot testedCurrent consumption1.5mA*10uA-(20uA expected)Battery life(30%bri.)typical use display on 3%*(BLE included in estimates)8 days28 days-NotesHopefully imp
9、roved with SW fixAllow wakeup from touch(double tap,screen gesture etc.)in addition*Lacking documentation of expected power consumption,1.5mA feels a lot for sleep mode of display.Hopefully missed something.*From my usage statisticsUser Interface Fantastic UI Library Open source Flexible and support
10、s anything needed Supports desktop simulators Handles user input Physical buttons Touch(through Zephyr LVGL kscan port)LVGLZSWatch“Applications”Basic idea of“Apps”Lets create an app,we will call it“ZDS app”Show the Zephyr Project Logo When screen or a button is clicked,rotate the logo1.Find an icon,
11、resize to 32x32 pixel2.Find Zephyr project logo,resize to 240 x240 pixels3.Convert them to c array using https:/lvgl.io/tools/imageconverter4.Put in ZSWatch images folderLets create an app,we will call it“ZDS app”applications/zds_app/CmakeLists.txt ZDS AppZDS Appapplications/zds_app/CmakeLists.txt z
12、ds_app.c ZDS AppZDS Appapplications/zds_app/CmakeLists.txt zds_app.c zds_ui.h.ZDS AppZDS Appapplications/zds_app/CmakeLists.txt zds_app.c zds_ui.c zds_ui.cZDS AppZDS AppReacting on events from the systemExtending the appHandling low powerExtending the app Zephyr native-posix port and SDL for UI hci_
13、usb sample on a supported dev kit Took less than 4 hours,amazing!Application changes Working BLE Small change in display_sdl.c SDL_RenderSetLogicalSize(upscaling 240 x240 pixels)Avoids time wasted on flashing Allows contribution without HWRunning on LinuxDock Exposes pins from watch SWD VCC GND 1 GP
14、IO On board debugger Only distributed by me(license)Option without debugger(TODO)Casing-still WIP Hard to find low profile connector to dock Buttons not 100%Not optimal yet 3D printed Works by emulating another supported watch in the Gadgetbridge.Gadgetbridge have lots of features I have not yet add
15、edGadgetbridge-Android appHow much will it set you back?ZSWatch$Components(w/o heart-rate sensor)65-70PCB+Assembly(50 pieces)30(from 1 offer)Display14Battery3Vibration motor1Total118$BOMDock as breakout board only(No J-Link OB)$Components(USB-C,regulators etc.only)3-4PCBCheapWhats next for ZSWatch?Z
16、ephyr LVGL port needs some performance improvements Double buffering not done correctly Native Posix port improvementsTry out new Zephyr“Sensing Subsystem”Watch face implementation reworkMore power consumption worknPM1100 PMIC Should give space for an external flashnRF54H20?Some ideas Not possible without a big ecosystem such as Zephyr With lots of resources Samples etc.Should have done the Posix port long time ago Thought it would be more work than it wasConclusionsSkip the display and vibration motor and you have a quite nice low power but powerful sensor board!BonusesFind everything at