X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;ds=sidebyside;f=ui%2Foswald.h;h=dd61eed982df7c264859e9f459bf68b9f37af42f;hb=8d5205584b7db9a3edd298af2d2061f7f3f66403;hp=c49acec24f7b33f4548b7e6b9210da25b78b06f2;hpb=019424a494c8312fd8bac9eb89839aea943f4d88;p=oswald.git diff --git a/ui/oswald.h b/ui/oswald.h index c49acec..dd61eed 100644 --- a/ui/oswald.h +++ b/ui/oswald.h @@ -1,18 +1,19 @@ #ifndef _OSWALD_H #define _OSWALD_H +#include +#include +#include -#define DEBUG 1 +#define OSWALD_VERSION "v0.3" + +//#define DEBUG 1 #ifdef DEBUG #define dbg_out( args... ) fprintf(stderr, args) #else #define dbg_out( args... ) do {} while (0) #endif -typedef signed char s8t; -typedef unsigned char u8t; -typedef signed short s16t; -typedef unsigned short u16t; -typedef u8t boolean; +typedef uint8_t boolean; #ifdef TRUE #undef TRUE #endif @@ -26,23 +27,46 @@ typedef u8t boolean; #endif typedef struct { - u8t hour; - u8t minute; - u8t second; - u8t day; - u8t month; - u8t year; + uint8_t hour; + uint8_t minute; + uint8_t second; + uint8_t day; + uint8_t wday; // day in week, 0=sunday, 1=monday,... + uint8_t month; + uint16_t year; + boolean clk24hr; + boolean day_first; } clock_state; +#define WDAY_SUNDAY (1 << 0) +#define WDAY_MONDAY (1 << 1) +#define WDAY_TUESDAY (1 << 2) +#define WDAY_WEDNESDAY (1 << 3) +#define WDAY_THURSDAY (1 << 4) +#define WDAY_FRIDAY (1 << 5) +#define WDAY_SATURDAY (1 << 6) +typedef struct { + uint8_t hour; + uint8_t minute; + uint8_t wday; // bitfield 0 to 6, 1=sunday, 2=monday, 4=tuesday... +} alarm_clk; + typedef enum { IDLE_SCREEN = 0, + MAIN_MENU_SCREEN, + ALARM_SETUP_SCREEN, + STOP_WATCH_SCREEN, + BLUETOOTH_SCREEN, ACCEL_DISPLAY_SCREEN, - DATETIME_SETTING_SCREEN, - MENU_TEST_SCREEN, -// SCREEN2_SCREEN, -// SCREEN3_SCREEN, -// APPLICATION_SCREEN, + MESSAGES_SCREEN, + INFO_SCREEN, LAST_SCREEN, // a marker for the last (not valid) screen) + MESSAGE_SCREEN, + MENU_TEST_SCREEN, + APPLICATION_SCREEN, + DATETIME_SETTING_SCREEN, + ALARM_SCREEN, + SCREENS_END, } screen_number; typedef enum { @@ -56,30 +80,60 @@ typedef enum { #define EVENT_SCREEN_VISIBLE (1<<0) // screen just became visible #define EVENT_SCREEN_DESTROY (1<<1) // screen is destroyed -#define EVENT_ONE_SEC_TIMER (1<<2) -#define EVENT_MS_TIMER (1<<3) -#define EVENT_USER_BUTTONS (1<<4) -#define EVENT_ACCEL_UPDATE (1<<5) -#define EVENT_AMBIENTLIGHT_UPDATE (1<<6) -#define EVENT_POWER_CHANGE (1<<7) -#define EVENT_COMMS (1<<8) +#define EVENT_ONE_SEC_TIMER (1<<2) // one second timer for reguler clock +#define EVENT_HALF_SEC_TIMER (1<<3) // half second timer for blinking displays +#define EVENT_CS_TIMER (1<<4) // centisecond timer, e.g. for stop watch +#define EVENT_USER_BUTTONS (1<<5) // button presses +#define EVENT_ACCEL_UPDATE (1<<6) // accelerometer updates +#define EVENT_AMBIENTLIGHT_UPDATE (1<<7) // ambient light sensor updates +#define EVENT_POWER_CHANGE (1<<8) // power source status change +#define EVENT_COMMS (1<<9) // communication, like Bluetooth I/O +#define EVENT_POWER_STATE (1<<10) // power source changed or similar + +typedef enum { + EVENT_RET_UNHANDLED = 0, + EVENT_RET_HANDLED, + EVENT_RET_ERR +} event_ret_t; typedef struct { - u16t event_mask; // the event the screen wants to receive - void (*event_func)(u16t event, void *data); // callback for events -// void (*button_func)(watch_button button); // handles button presses -// void (*screendraw_func)(void); // callback for screen update -// void *user_data; + uint16_t event_mask; // the event the screen wants to receive + event_ret_t (*event_func)(uint16_t event, void *data); // callback for events + void *user_data; } watch_screen; typedef struct { screen_number screen_id; - // void (*draw_watchface_func)(boolean show_seconds); - boolean idle_show_seconds; watch_screen *screen; // the current screen - // void (*user_button_func)(watch_button button); - // void (*user_screendraw_func)(void); + boolean pending_idle; } watch_state; -#endif +typedef struct { + int8_t x; + int8_t y; + int8_t z; +} accel_data_t; + +#define POWER_SOURCE_BATTERY 0 +#define POWER_SOURCE_EXTERNAL 1 +#define POWER_CHARGER_DONE 0 +#define POWER_CHARGER_PRECHARGE 1 +#define POWER_CHARGER_CHARGING 2 +#define POWER_CHARGER_UNK 3 + +typedef struct { + uint8_t source; + uint8_t charge_state; + uint8_t percent; + uint16_t level; +} power_state; + +typedef enum { + BLUETOOTH_OFF = 0, + BLUETOOTH_ON, + BLUETOOTH_CONNECTED, + BLUETOOTH_ILL +} bluetooth_state; + +#endif