#ifndef _WATCHOS2_h #define _WATCHOS2_h #include #include "watchos_config.h" #include "watchos_consts.h" #include "watchos_hw.h" #include "watchos_types.h" #include "Event.h" #include "EventListener.h" #include "Kernel.h" #include "Task.h" #include "IRunnable.h" #include "IDrawable.h" /// /// General watchos interface for use in code /// class watchos { private: /// /// kernel() only ever instantiates one instance of the kernel, this is that instance. /// static Kernel* s_kernel; public: /// /// Call from your .ino's setup() method after registering tasks and modules /// /// /// This will check the wake-up reason and determine whether we need to initialize tasks, /// and finally call start() on all registered tasks. /// static void setup(); /// /// Call from your .ino's tick() method /// /// /// Give's the kernel a chance to run any tasks that need it /// static void tick(); /// /// Initialize the system /// /// /// Currently initializes the serial interface and Wire library /// static void initialize(); /// /// Fetch an instance of the kernel /// /// The same instance of the kernel with every call static Kernel* kernel(); /// /// Trigger a kernel panic /// /// /// Prints the passed formatted string then either: /// if WATCHOS_DEBUG is set: goes into an infinite loop to wait for reset /// if WATCHOS_DEBUG is not set: resets the system after a few seconds /// static void panic(char* fmt...); /// /// Print debugging output /// /// /// Only when WATCHOS_DEBUG is set, will print the passed formatted string to /// the serial console. /// static void debug(char* fmt...); /// /// Fetch an instance of an event by handle /// static Event* event(kernel_handle_t event); /// /// Fetch an instance of a task by handle /// static Task* task(kernel_handle_t task); /// /// Fetch an instance of a task by a well-known handle /// static Task* module(well_known_handle_t handle); /// /// Increase the reference count for the passed handle /// static void reference(kernel_handle_t handle); /// /// Decrease the reference count for the passed handle /// static void release(kernel_handle_t handle); /// /// Register a new task with the kernel /// /// an instance of a task /// handle for the newly registered task static kernel_handle_t run(Task* task); /// /// Subscribe a task to a set of events /// /// task to receive events; must implement EventListener /// bitmask of which well known handles / modules we should receive events from /// bitmask of which events we should receive /// handle for the event subscription; release to unsubscribe static kernel_handle_t subscribe(Task* task, well_known_handle_t source_mask, uint16_t event_mask); }; #endif