2017-11-14 19:07:10 +00:00
|
|
|
/*! \file apps.h
|
|
|
|
\brief These are functions for working with applications and the task switcher.
|
2017-09-26 15:44:10 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2017-11-14 19:07:10 +00:00
|
|
|
//! Entry in the application table.
|
2017-09-26 15:44:10 +00:00
|
|
|
struct app {
|
2017-10-17 18:37:10 +00:00
|
|
|
char *name; //Shows when entering the app.
|
2017-09-26 15:44:10 +00:00
|
|
|
void (*init)(void); //Called exactly once at startup.
|
|
|
|
void (*draw)(void); //Called four times per second to draw display.
|
2017-11-14 19:07:10 +00:00
|
|
|
|
2017-09-27 20:10:24 +00:00
|
|
|
/* Called once when moving to the next applet. Returns zero (or is
|
|
|
|
NULL) if the application may move on, or returns non-zero if the
|
|
|
|
exit call is intercepted.
|
|
|
|
*/
|
2017-12-03 21:16:41 +00:00
|
|
|
int (*exit)(void);
|
|
|
|
|
2018-01-31 22:45:31 +00:00
|
|
|
/* I/O can work either by interrupts or by polling. The old
|
|
|
|
convention was to call getchar() to poll during the rendering
|
|
|
|
loop if you are checking to see if a button is held down, but to
|
|
|
|
take this interrupt callback when taking number entry, such as in
|
|
|
|
the calculator.
|
2018-01-27 22:08:55 +00:00
|
|
|
|
2018-02-08 22:21:58 +00:00
|
|
|
Called once per unique keypress. Return non-zero to immediately redraw.
|
2018-01-27 22:08:55 +00:00
|
|
|
*/
|
2018-02-08 22:21:58 +00:00
|
|
|
int (*keypress)(char ch);//A keypress has arrived.
|
2018-01-27 22:08:55 +00:00
|
|
|
|
2017-12-03 21:16:41 +00:00
|
|
|
/* Callbacks for packets being sent and received. Set to null if unused. */
|
2017-12-07 18:08:54 +00:00
|
|
|
void (*packetrx)(uint8_t *packet, int len); //A packet has arrived.
|
2017-12-03 21:16:41 +00:00
|
|
|
void (*packettx)(void); //A packet has been sent.
|
2017-09-26 15:44:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-11-14 19:07:10 +00:00
|
|
|
//! Draw the current application.
|
2017-09-26 16:59:02 +00:00
|
|
|
void app_draw();
|
2017-12-03 21:16:41 +00:00
|
|
|
//! Initializes the set of applications.
|
2017-09-26 16:59:02 +00:00
|
|
|
void app_init();
|
2017-11-14 19:07:10 +00:00
|
|
|
//! Move to the next application.
|
2017-09-26 16:59:02 +00:00
|
|
|
void app_next();
|
2017-11-14 19:07:10 +00:00
|
|
|
//! If this is *not* called, the watch forces home after three minutes.
|
2017-09-26 17:25:50 +00:00
|
|
|
void app_cleartimer();
|
2017-11-14 19:07:10 +00:00
|
|
|
//! Drop the power usage and return to the Clock.
|
2017-09-27 20:10:24 +00:00
|
|
|
void app_forcehome();
|
2017-12-07 18:08:54 +00:00
|
|
|
//! Provide an incoming packet.
|
|
|
|
void app_packetrx(uint8_t *packet, int len);
|
2018-01-27 22:08:55 +00:00
|
|
|
|
|
|
|
//! Handles a keypress, if a handler is registered.
|
|
|
|
void app_keypress(char ch);
|
2018-01-28 22:22:54 +00:00
|
|
|
|
|
|
|
//! Sets an app by a pointer to its structure. Used for submenus.
|
|
|
|
void app_set(const struct app *newapplet);
|