]> git.karo-electronics.de Git - oswald.git/blob - ui/oswald.h
Countless fixes and enhancements
[oswald.git] / ui / oswald.h
1 #ifndef _OSWALD_H
2 #define _OSWALD_H
3
4 #define DEBUG 1
5 #ifdef DEBUG
6 #define dbg_out( args... ) fprintf(stderr, args)
7 #else
8 #define dbg_out( args... ) do {} while (0)
9 #endif
10
11 typedef signed char s8t;
12 typedef unsigned char u8t;
13 typedef signed short s16t;
14 typedef unsigned short u16t;
15 typedef u8t boolean;
16 #ifdef TRUE
17 #undef TRUE
18 #endif
19 #define TRUE 1
20 #ifdef FALSE
21 #undef FALSE
22 #endif
23 #define FALSE 0
24 #ifndef NULL
25 #define NULL 0
26 #endif
27
28 typedef struct {
29         u8t     hour;
30         u8t     minute;
31         u8t     second;
32         u8t     day;
33         u8t     month;
34         u16t    year;
35         boolean clk24hr;
36         boolean day_first;
37 } clock_state;
38
39 typedef enum {
40         IDLE_SCREEN = 0,
41         ACCEL_DISPLAY_SCREEN,
42         MENU_TEST_SCREEN,
43 //      SCREEN2_SCREEN,
44 //      SCREEN3_SCREEN,
45 //      APPLICATION_SCREEN,
46         LAST_SCREEN,            // a marker for the last (not valid) screen)
47         DATETIME_SETTING_SCREEN,
48 } screen_number;
49
50 typedef enum {
51         BUTTON_A = 0,
52         BUTTON_B,
53         BUTTON_C,
54         BUTTON_D,
55         BUTTON_E,
56         BUTTON_F,
57 } watch_button;
58
59 #define EVENT_SCREEN_VISIBLE            (1<<0)          // screen just became visible
60 #define EVENT_SCREEN_DESTROY            (1<<1)          // screen is destroyed
61 #define EVENT_ONE_SEC_TIMER             (1<<2)          // one second timer for reguler clock
62 #define EVENT_HALF_SEC_TIMER            (1<<3)          // half second timer for blinking displays
63 #define EVENT_CS_TIMER                  (1<<4)          // centisecond timer, e.g. for stop watch
64 #define EVENT_USER_BUTTONS              (1<<5)          // button presses
65 #define EVENT_ACCEL_UPDATE              (1<<6)          // accelerometer updates
66 #define EVENT_AMBIENTLIGHT_UPDATE       (1<<7)          // ambient light sensor updates
67 #define EVENT_POWER_CHANGE              (1<<8)          // power source status change
68 #define EVENT_COMMS                     (1<<9)          // communication, like Bluetooth I/O
69
70 typedef struct {
71         u16t event_mask;                                // the event the screen wants to receive
72         void (*event_func)(u16t event, void *data);     // callback for events
73         void *user_data;
74 } watch_screen;
75
76 typedef struct {
77         screen_number   screen_id;
78         watch_screen *screen;           // the current screen
79         boolean pending_idle;
80 } watch_state;
81
82 typedef struct {
83         u8t     x;
84         u8t     y;
85         u8t     z;
86 } accel_data_t;
87
88 #endif
89