atctwo / watch-II

Firmware for my custom smart-ish-watch, mark II
MIT License
1 stars 0 forks source link

move system functions to watch2 class #5

Open atctwo opened 4 years ago

atctwo commented 4 years ago

at the moment, all the system functions are defined in one file (watch2.ino), and things are specifically targeted to the esp32. at some point, the functions should be moved to a class system. for example: image

when compiling the watch firmware, the user can change what class is instantiated (by changing one line of code) to target different systems

atctwo commented 4 years ago

my concern is how to support different devices that do one function, but have different libraries. for example, one board may have an mpu6050 and another may have an icm-20948. apps would be written to support a library for one device, but probably not both. there isn't really an easy way to provide a device agnostic peripheral library (like drivers on an operating system)

for now, all of the system functions and global variables have been moved to a dedicated namespace called watch2 (in commits e23c7825933bb45143cc10d945009c2260a3aef0 and 4c1a18fd564713461ae7b4715f465ce7659611d1). they can be accessed thusly: watch2::switchState(2);

atctwo commented 4 years ago

instead of doing the inheritance thing, i could adapt an approach like the ones that libretro and littlevgl take. the watch2 system could be platform agnostic, and there could be ports that provide platform specific stuff. instead of creating a subclass that inherits from the watch2 thing, the main file could include the watch2 system, and pass functions to it (more like littlevgl)