]> git.karo-electronics.de Git - oswald.git/blob - ui/oswald.h
Oh boy... lots of changes, too many to describe
[oswald.git] / ui / oswald.h
1 #ifndef _OSWALD_H
2 #define _OSWALD_H
3 #include <stdint.h>
4
5 //#define DEBUG 1
6 #ifdef DEBUG
7 #define dbg_out( args... ) fprintf(stderr, args)
8 #else
9 #define dbg_out( args... ) do {} while (0)
10 #endif
11
12 typedef signed char s8t;
13 typedef unsigned char u8t;
14 typedef signed short s16t;
15 typedef unsigned short u16t;
16 typedef u8t boolean;
17 #ifdef TRUE
18 #undef TRUE
19 #endif
20 #define TRUE 1
21 #ifdef FALSE
22 #undef FALSE
23 #endif
24 #define FALSE 0
25 #ifndef NULL
26 #define NULL 0
27 #endif
28
29 typedef struct {
30         u8t     hour;
31         u8t     minute;
32         u8t     second;
33         u8t     day;
34         u8t     wday; // day in week, 0=sunday, 1=monday,...
35         u8t     month;
36         u16t    year;
37         boolean clk24hr;
38         boolean day_first;
39 } clock_state;
40
41 #define WDAY_SUNDAY     (1 << 0)
42 #define WDAY_MONDAY     (1 << 1)
43 #define WDAY_TUESDAY    (1 << 2)
44 #define WDAY_WEDNESDAY  (1 << 3)
45 #define WDAY_THURSDAY   (1 << 4)
46 #define WDAY_FRIDAY     (1 << 5)
47 #define WDAY_SATURDAY   (1 << 6)
48 typedef struct {
49         u8t     hour;
50         u8t     minute;
51         u8t     wday; // bitfield 0 to 6, 1=sunday, 2=monday, 4=tuesday...
52 } alarm_clk;
53
54 typedef enum {
55         IDLE_SCREEN = 0,
56         ALARM_SETUP_SCREEN,
57         STOP_WATCH_SCREEN,
58         ACCEL_DISPLAY_SCREEN,
59         MENU_TEST_SCREEN,
60 //      APPLICATION_SCREEN,
61         LAST_SCREEN,            // a marker for the last (not valid) screen)
62         DATETIME_SETTING_SCREEN,
63         ALARM_SCREEN,
64         SCREENS_END,
65 } screen_number;
66
67 typedef enum {
68         BUTTON_A = 0,
69         BUTTON_B,
70         BUTTON_C,
71         BUTTON_D,
72         BUTTON_E,
73         BUTTON_F,
74 } watch_button;
75
76 #define EVENT_SCREEN_VISIBLE            (1<<0)          // screen just became visible
77 #define EVENT_SCREEN_DESTROY            (1<<1)          // screen is destroyed
78 #define EVENT_ONE_SEC_TIMER             (1<<2)          // one second timer for reguler clock
79 #define EVENT_HALF_SEC_TIMER            (1<<3)          // half second timer for blinking displays
80 #define EVENT_CS_TIMER                  (1<<4)          // centisecond timer, e.g. for stop watch
81 #define EVENT_USER_BUTTONS              (1<<5)          // button presses
82 #define EVENT_ACCEL_UPDATE              (1<<6)          // accelerometer updates
83 #define EVENT_AMBIENTLIGHT_UPDATE       (1<<7)          // ambient light sensor updates
84 #define EVENT_POWER_CHANGE              (1<<8)          // power source status change
85 #define EVENT_COMMS                     (1<<9)          // communication, like Bluetooth I/O
86 #define EVENT_POWER_STATE               (1<<10)         // power source changed or similar
87
88
89 typedef struct {
90         u16t event_mask;                                // the event the screen wants to receive
91         void (*event_func)(u16t event, void *data);     // callback for events
92         void *user_data;
93 } watch_screen;
94
95 typedef struct {
96         screen_number   screen_id;
97         watch_screen *screen;           // the current screen
98         boolean pending_idle;
99 } watch_state;
100
101 typedef struct {
102         u8t     x;
103         u8t     y;
104         u8t     z;
105 } accel_data_t;
106
107 #define POWER_SOURCE_BATTERY    0
108 #define POWER_SOURCE_EXTERNAL   1
109
110 #define POWER_CHARGER_DONE      0
111 #define POWER_CHARGER_PRECHARGE 1
112 #define POWER_CHARGER_CHARGING  2
113 #define POWER_CHARGER_UNK       3
114
115 typedef struct {
116         u8t     source;
117         u8t     charge_state;
118         u8t     percent;
119         u16t    level;
120 } power_state;
121
122 typedef enum {
123         BLUETOOTH_OFF = 0,
124         BLUETOOTH_ON,
125         BLUETOOTH_CONNECTED,
126         BLUETOOTH_ILL
127 } bluetooth_state;
128
129 #endif