Browse code

Too much to note...

Nils Faerber authored on 05/08/2012 17:07:17
Showing 10 changed files
... ...
@@ -1,9 +1,11 @@
1 1
 #include <time.h>
2 2
 #include <stdio.h>
3 3
 #include <string.h>
4
+#include <math.h>
4 5
 
5 6
 #include "oswald-ui.h"
6 7
 #include "Fonts.h"
8
+
7 9
 #include "LcdDisplay.h"
8 10
 
9 11
 #define NUM_LCD_ROWS  96
... ...
@@ -11,12 +13,113 @@
11 13
 #define MAX_FONT_ROWS ( 19 )
12 14
 
13 15
 
14
-gint WriteLcdCharacter(oswald_ui *ui, gint x, gint y, unsigned char Character)
16
+void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
17
+{
18
+	int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
19
+ 
20
+	dx = xend - xstart;
21
+	dy = yend - ystart;
22
+ 
23
+	incx = (dx >= 0) ? 1 : -1;
24
+	incy = (dy >= 0) ? 1 : -1;
25
+
26
+	if (dx<0)
27
+		dx = -dx;
28
+	if (dy<0)
29
+		dy = -dy;
30
+ 
31
+	if (dx>dy) {
32
+		pdx = incx; pdy = 0;
33
+		ddx=incx; ddy=incy;
34
+		es =dy;   el =dx;
35
+	} else {
36
+		pdx=0;    pdy=incy;
37
+		ddx=incx; ddy=incy;
38
+		es =dx;   el =dy;
39
+	}
40
+ 
41
+	x = xstart;
42
+	y = ystart;
43
+	err = el/2;
44
+	lcd_set_pixel(x, y, TRUE);
45
+ 
46
+	for (t = 0; t < el; ++t) {
47
+		err -= es; 
48
+		if (err < 0) {
49
+			err += el;
50
+			x += ddx;
51
+			y += ddy;
52
+		} else {
53
+			x += pdx;
54
+			y += pdy;
55
+		}
56
+		lcd_set_pixel(x, y, TRUE);
57
+	}
58
+}
59
+
60
+void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness)
61
+{
62
+	int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
63
+ 
64
+	dx = xend - xstart;
65
+	dy = yend - ystart;
66
+ 
67
+	incx = (dx >= 0) ? 1 : -1;
68
+	incy = (dy >= 0) ? 1 : -1;
69
+
70
+	if (dx<0)
71
+		dx = -dx;
72
+	if (dy<0)
73
+		dy = -dy;
74
+ 
75
+	if (dx>dy) {
76
+		pdx = incx; pdy = 0;
77
+		ddx=incx; ddy=incy;
78
+		es =dy;   el =dx;
79
+	} else {
80
+		pdx=0;    pdy=incy;
81
+		ddx=incx; ddy=incy;
82
+		es =dx;   el =dy;
83
+	}
84
+ 
85
+	x = xstart;
86
+	y = ystart;
87
+	err = el/2;
88
+	lcd_set_pixel(x, y, TRUE);
89
+	for (i=1; i<thickness; i++) {
90
+		lcd_set_pixel(x-i, y, TRUE);
91
+		lcd_set_pixel(x+i, y, TRUE);
92
+		lcd_set_pixel(x, y-i, TRUE);
93
+		lcd_set_pixel(x, y+i, TRUE);
94
+	}
95
+ 
96
+	for (t = 0; t < el; ++t) {
97
+		err -= es; 
98
+		if (err < 0) {
99
+			err += el;
100
+			x += ddx;
101
+			y += ddy;
102
+		} else {
103
+			x += pdx;
104
+			y += pdy;
105
+		}
106
+		lcd_set_pixel(x, y, TRUE);
107
+		for (i=1; i<thickness; i++) {
108
+			lcd_set_pixel(x-i, y, TRUE);
109
+			lcd_set_pixel(x+i, y, TRUE);
110
+			lcd_set_pixel(x, y-i, TRUE);
111
+			lcd_set_pixel(x, y+i, TRUE);
112
+		}
113
+	}
114
+}
115
+
116
+
117
+u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
15 118
 {
16
-	gint CharacterHeight = GetCharacterHeight();
17
-	gint CharacterWidth = GetCharacterWidth(Character);
119
+	u8t CharacterHeight = GetCharacterHeight();
120
+	u8t CharacterWidth = GetCharacterWidth(Character);
18 121
 	unsigned int bitmap[MAX_FONT_ROWS];
19
-	gint lx, ly;
122
+	register lx, ly;
20 123
 
21 124
 	GetCharacterBitmap(Character,(unsigned int*)&bitmap);
22 125
 
... ...
@@ -24,10 +127,10 @@ gint WriteLcdCharacter(oswald_ui *ui, gint x, gint y, unsigned char Character)
24 127
 	for (ly=0; ly<CharacterHeight; ly++) {
25 128
 		for (lx=0; lx<CharacterWidth; lx++) {
26 129
 			if (bitmap[ly] & (1<<lx)) {
27
-				set_pixel(ui, lx+x, ly+y, TRUE);
130
+				lcd_set_pixel(lx+x, ly+y, TRUE);
28 131
 				// printf(".");
29 132
 			} else {
30
-				set_pixel(ui, lx+x, ly+y, FALSE);
133
+				lcd_set_pixel(lx+x, ly+y, FALSE);
31 134
 				// printf(" ");
32 135
 			}
33 136
 		}
... ...
@@ -37,37 +140,16 @@ gint WriteLcdCharacter(oswald_ui *ui, gint x, gint y, unsigned char Character)
37 140
 	return CharacterWidth + GetFontSpacing();
38 141
 }
39 142
 
40
-void WriteLcdString(oswald_ui *ui, gint x, gint y, gchar *str)
143
+void WriteLcdString(u8t x, u8t y, u8t *str)
41 144
 {
42
-	gint lx, i;
145
+	register lx, i;
43 146
 
44 147
 	if (str == NULL || strlen(str)==0)
45 148
 		return;
46 149
 
47 150
 	lx = x;
48 151
 	for (i=0; i<strlen(str); i++) {
49
-		lx += WriteLcdCharacter(ui, lx, y, str[i]);
152
+		lx += WriteLcdCharacter(lx, y, str[i]);
50 153
 	}
51 154
 }
52 155
 
53
-
54
-void update_idle_time_date(oswald_ui *ui)
55
-{
56
-	gint gRow = 3;
57
-	gint gColumn = 4;
58
-	static gchar secs = 0;
59
-
60
-	SetFont(MetaWatchTime);
61
-
62
-	//gRow += WriteLcdCharacter(ui, gRow, gColumn, TIME_CHARACTER_SPACE_INDEX);
63
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, 2);
64
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, 3);
65
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, TIME_CHARACTER_COLON_INDEX);
66
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, 1);
67
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, 7);
68
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, TIME_CHARACTER_COLON_INDEX);
69
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, (secs / 10));
70
-	gRow += WriteLcdCharacter(ui, gRow, gColumn, (secs % 10));
71
-	secs = ++secs % 60;
72
-}
73
-
... ...
@@ -3,7 +3,10 @@
3 3
 
4 4
 #include "oswald-ui.h"
5 5
 
6
-void update_idle_time_date(oswald_ui *ui);
6
+void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend);
7
+void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness);
8
+u8t WriteLcdCharacter(u8t x, u8t y, u8t Character);
9
+void WriteLcdString(u8t x, u8t y, u8t *str);
7 10
 
8 11
 #endif
9 12
 
... ...
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
2 2
 
3 3
 bin_PROGRAMS = oswald-gui
4 4
 
5
-oswald_gui_SOURCES = oswald-ui.c LcdDisplay.c Fonts.c
5
+oswald_gui_SOURCES = oswald-ui.c LcdDisplay.c Fonts.c oswald_main.c oswald_watch_faces.c
6 6
 oswald_gui_CFLAGS = -g $(GTK_CFLAGS)
7 7
 oswald_gui_LDADD = $(GTK_LIBS)
8 8
 
... ...
@@ -12,50 +12,41 @@
12 12
 
13 13
 #include <gtk/gtk.h>
14 14
 
15
-#include "oswald-ui.h"
16 15
 #include "Fonts.h" // the MetaWatch fonts
16
+#include "oswald_main.h"
17
+
18
+#include "oswald-ui.h"
17 19
 
18 20
 #define BITMAP_WIDTH	192
19 21
 #define BITMAP_HEIGHT	192
20 22
 
21
-void set_pixel(oswald_ui *ui, gint x, gint y, gboolean state)
23
+static oswald_ui *ui_g;
24
+
25
+void lcd_set_pixel(gint x, gint y, gboolean state)
22 26
 {
23
-	GdkRectangle update_rect;
24 27
 	gint ix, iy;
25 28
 
26 29
 	ix = x*2;
27 30
 	iy = y*2;
28 31
 
29
-	update_rect.x = ix - 5;
30
-	update_rect.y = iy - 5;
31
-	update_rect.width = 10;
32
-	update_rect.height = 10;
33
-
34
-	gdk_draw_point(GDK_DRAWABLE(ui->pixmap), state ? ui->darea->style->black_gc : ui->darea->style->white_gc, ix, iy);
35
-	gdk_draw_point(GDK_DRAWABLE(ui->pixmap), state ? ui->darea->style->black_gc : ui->darea->style->white_gc, ix+1, iy);
36
-	gdk_draw_point(GDK_DRAWABLE(ui->pixmap), state ? ui->darea->style->black_gc : ui->darea->style->white_gc, ix, iy+1);
37
-	gdk_draw_point(GDK_DRAWABLE(ui->pixmap), state ? ui->darea->style->black_gc : ui->darea->style->white_gc, ix+1, iy+1);
32
+	gdk_draw_point(GDK_DRAWABLE(ui_g->pixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix, iy);
33
+	gdk_draw_point(GDK_DRAWABLE(ui_g->pixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix+1, iy);
34
+	gdk_draw_point(GDK_DRAWABLE(ui_g->pixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix, iy+1);
35
+	gdk_draw_point(GDK_DRAWABLE(ui_g->pixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix+1, iy+1);
38 36
 
39
-	gtk_widget_draw (GTK_WIDGET(ui->darea), &update_rect);
37
+	gtk_widget_queue_draw(ui_g->darea);
40 38
 }
41 39
 
42
-void clear_display(oswald_ui *ui)
40
+void lcd_clear_display(void)
43 41
 {
44
-	GdkRectangle update_rect;
45
-
46
-	update_rect.x = 0;
47
-	update_rect.y = 0;
48
-	update_rect.width = BITMAP_WIDTH;
49
-	update_rect.height = BITMAP_HEIGHT;
50
-
51
-	gdk_draw_rectangle (ui->pixmap,
52
-		ui->darea->style->white_gc,
42
+	gdk_draw_rectangle (ui_g->pixmap,
43
+		ui_g->darea->style->white_gc,
53 44
 		TRUE,
54 45
 		0, 0,
55
-		ui->darea->allocation.width,
56
-		ui->darea->allocation.height);
46
+		ui_g->darea->allocation.width,
47
+		ui_g->darea->allocation.height);
57 48
 
58
-	gtk_widget_draw (GTK_WIDGET(ui->darea), &update_rect);
49
+	gtk_widget_queue_draw(ui_g->darea);
59 50
 }
60 51
 
61 52
 static gint
... ...
@@ -95,6 +86,49 @@ expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
95 86
 	return FALSE;
96 87
 }
97 88
 
89
+void button_A_pressed (GtkButton *button, gpointer user_data)
90
+{
91
+	oswald_ui *ui = (oswald_ui *)user_data;
92
+
93
+	g_print("Button-A pressed\n");
94
+	oswald_handle_button_press(BUTTON_A);
95
+}
96
+
97
+void button_B_pressed (GtkButton *button, gpointer user_data)
98
+{
99
+	oswald_ui *ui = (oswald_ui *)user_data;
100
+
101
+	g_print("Button-B pressed\n");
102
+}
103
+
104
+void button_C_pressed (GtkButton *button, gpointer user_data)
105
+{
106
+	oswald_ui *ui = (oswald_ui *)user_data;
107
+
108
+	g_print("Button-C pressed\n");
109
+}
110
+
111
+void button_D_pressed (GtkButton *button, gpointer user_data)
112
+{
113
+	oswald_ui *ui = (oswald_ui *)user_data;
114
+
115
+	g_print("Button-D pressed\n");
116
+}
117
+
118
+void button_E_pressed (GtkButton *button, gpointer user_data)
119
+{
120
+	oswald_ui *ui = (oswald_ui *)user_data;
121
+
122
+	g_print("Button-E pressed\n");
123
+}
124
+
125
+void button_F_pressed (GtkButton *button, gpointer user_data)
126
+{
127
+	oswald_ui *ui = (oswald_ui *)user_data;
128
+
129
+	g_print("Button-F pressed\n");
130
+}
131
+
98 132
 static void create_mainwin(oswald_ui *ui)
99 133
 {
100 134
 	GtkWidget *hb, *vb, *btn;
... ...
@@ -113,12 +147,16 @@ static void create_mainwin(oswald_ui *ui)
113 147
 
114 148
 	btn = gtk_button_new_with_label(" D ");
115 149
 	gtk_box_pack_start (GTK_BOX(vb), btn, FALSE, FALSE, 10);
150
+	g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(button_D_pressed), ui);
116 151
 
117 152
 	btn = gtk_button_new_with_label(" E ");
118 153
 	gtk_box_pack_start (GTK_BOX(vb), btn, FALSE, FALSE, 10);
154
+	g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(button_D_pressed), ui);
119 155
 
120 156
 	btn = gtk_button_new_with_label(" F ");
121 157
 	gtk_box_pack_start (GTK_BOX(vb), btn, FALSE, FALSE, 10);
158
+	g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(button_F_pressed), ui);
159
+
122 160
 
123 161
 	ui->darea = gtk_drawing_area_new ();
124 162
 	gtk_box_pack_start (GTK_BOX(hb), GTK_WIDGET(ui->darea), FALSE, FALSE, 5);
... ...
@@ -140,47 +178,54 @@ static void create_mainwin(oswald_ui *ui)
140 178
 
141 179
 	btn = gtk_button_new_with_label(" A ");
142 180
 	gtk_box_pack_start (GTK_BOX(vb), btn, FALSE, FALSE, 10);
181
+	g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(button_A_pressed), ui);
143 182
 
144 183
 	btn = gtk_button_new_with_label(" B ");
145 184
 	gtk_box_pack_start (GTK_BOX(vb), btn, FALSE, FALSE, 10);
185
+	g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(button_B_pressed), ui);
146 186
 
147 187
 	btn = gtk_button_new_with_label(" C ");
148 188
 	gtk_box_pack_start (GTK_BOX(vb), btn, FALSE, FALSE, 10);
189
+	g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(button_C_pressed), ui);
149 190
 
150 191
 	gtk_widget_show_all(ui->mainwin);
151 192
 }
152 193
 
153
-gboolean app_tmo_handler (gpointer userdata)
194
+gboolean one_second_tmo_handler (gpointer userdata)
154 195
 {
155 196
 	oswald_ui *ui = (oswald_ui *)userdata;
156 197
 
157
-	// fprintf(stderr, "tmo...\n");
198
+	oswald_one_second_tick();
158 199
 
159
-	if (ui->OnIdleScreen) {
160
-		update_idle_time_date(ui);
161
-#if 0
162
-	} else {
163
-		// go back to idle screen after IDLE_TIMEOUT seconds
164
-		if ((time(NULL) - ui->idle_tmo) > ui->conf.idle_tmo /*IDLE_TIMEOUT*/)
165
-			create_main_screen(ui);
166
-#endif
167
-	}
200
+	return TRUE;
201
+}
168 202
 
203
+gboolean app_idle_handler (gpointer user_data)
204
+{
205
+	g_print("i");
169 206
 	return TRUE;
170 207
 }
171 208
 
172 209
 int main(int argc , char ** argv)
173 210
 {
174 211
 	oswald_ui ui;
212
+	time_t mt;
213
+	struct tm mtime;
214
+
215
+	ui_g = &ui;
216
+
217
+	mt = time(NULL);
218
+	localtime_r(&mt, &mtime);
175 219
 
176 220
 	gtk_init (&argc, &argv);
177 221
 
178 222
 	create_mainwin(&ui);
179 223
 
180
-	//set_pixel(&ui, 48, 48, TRUE);
181
-	// demo_time(&ui);
182
-	ui.OnIdleScreen = TRUE;
183
-	g_timeout_add_seconds(1, app_tmo_handler, &ui);
224
+	oswald_init();
225
+	oswald_set_time(mtime.tm_hour, mtime.tm_min, mtime.tm_sec);
226
+
227
+	g_timeout_add_seconds(1, one_second_tmo_handler, &ui);
228
+	// g_idle_add(app_idle_handler, &ui);
184 229
 
185 230
 	gtk_main ();
186 231
 	return 0;
... ...
@@ -3,14 +3,16 @@
3 3
 
4 4
 #include <gtk/gtk.h>
5 5
 
6
+#include "oswald.h"
7
+
6 8
 typedef struct {
7 9
 	GtkWidget *mainwin;
8 10
 	GtkWidget *darea;
9 11
 	GdkPixmap *pixmap;
10
-	gboolean OnIdleScreen;
11 12
 } oswald_ui;
12 13
 
13
-void set_pixel(oswald_ui *ui, gint x, gint y, gboolean state);
14
+void lcd_set_pixel(gint x, gint y, gboolean state);
15
+void lcd_clear_display(void);
14 16
 
15 17
 #endif
16 18
 
17 19
new file mode 100644
... ...
@@ -0,0 +1,50 @@
1
+#ifndef _OSWALD_H
2
+#define _OSWALD_H
3
+
4
+typedef signed char s8t;
5
+typedef unsigned char u8t;
6
+typedef u8t boolean;
7
+#ifdef TRUE
8
+#undef TRUE
9
+#endif
10
+#define TRUE 1
11
+#ifdef FALSE
12
+#undef FALSE
13
+#endif
14
+#define FALSE 0
15
+#ifndef NULL
16
+#define NULL 0
17
+#endif
18
+
19
+typedef struct {
20
+	u8t	hour;
21
+	u8t	minute;
22
+	u8t	second;
23
+	u8t	day;
24
+	u8t	month;
25
+	u8t	year;
26
+} clock_state;
27
+
28
+typedef enum {
29
+	IDLE_SCREEN = 0,
30
+	APPLICATION_SCREEN,
31
+} screen_number;
32
+
33
+typedef enum {
34
+	BUTTON_A = 0,
35
+	BUTTON_B,
36
+	BUTTON_C,
37
+	BUTTON_D,
38
+	BUTTON_E,
39
+	BUTTON_F,
40
+} watch_button;
41
+
42
+typedef struct {
43
+	screen_number	screen;
44
+	void (*idle_draw_func)(boolean show_seconds);
45
+	boolean idle_show_seconds;
46
+} watch_state;
47
+
48
+
49
+#endif
50
+
0 51
new file mode 100644
... ...
@@ -0,0 +1,80 @@
1
+#include "oswald.h"
2
+#include "oswald_watch_faces.h"
3
+
4
+#include "oswald_main.h"
5
+
6
+/*
7
+ * some variable defining our curent state
8
+ * these are globals in order to avoid having to pass pointers
9
+ * through function calls thus saving stack space
10
+ */
11
+clock_state OswaldClk;
12
+watch_state OswaldState;
13
+
14
+void update_screen(void)
15
+{
16
+	switch (OswaldState.screen) {
17
+		case IDLE_SCREEN:
18
+			if (OswaldState.idle_draw_func != NULL)
19
+				OswaldState.idle_draw_func(OswaldState.idle_show_seconds);
20
+			break;
21
+		case APPLICATION_SCREEN:
22
+			break;
23
+		deafault:
24
+			break;
25
+	};
26
+}
27
+
28
+void oswald_change_to_screen(screen_number screen)
29
+{
30
+	// we spare the update if no change
31
+	if (OswaldState.screen != screen) {
32
+		OswaldState.screen = screen;
33
+		update_screen();
34
+	}
35
+}
36
+
37
+void oswald_set_time(u8t hour, u8t minute, u8t second)
38
+{
39
+	OswaldClk.hour = hour;
40
+	OswaldClk.minute = minute;
41
+	OswaldClk.second = second;
42
+}
43
+
44
+static void update_clock_state (void)
45
+{
46
+	OswaldClk.second += 1;
47
+	if (OswaldClk.second > 59) {
48
+		OswaldClk.second = 0;
49
+		OswaldClk.minute += 1;
50
+	} else
51
+		return;
52
+	if (OswaldClk.minute > 59) {
53
+		OswaldClk.minute = 0;
54
+		OswaldClk.hour += 1;
55
+	} else
56
+		return;
57
+	if (OswaldClk.hour > 23) {
58
+		OswaldClk.hour = 0;
59
+		// day++
60
+	} else
61
+		return;
62
+}
63
+
64
+void oswald_one_second_tick(void)
65
+{
66
+	update_clock_state();
67
+	update_screen();
68
+}
69
+
70
+void oswald_handle_button_press(watch_button button)
71
+{
72
+}
73
+
74
+void oswald_init(void)
75
+{
76
+	OswaldState.screen = IDLE_SCREEN;
77
+	OswaldState.idle_draw_func = DrawLcdDigitalClock;
78
+	OswaldState.idle_show_seconds = FALSE;
79
+}
80
+
0 81
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+#ifndef _OSWALD_MAIN_H
2
+#define _OSWALD_MAIN_H
3
+
4
+#include "oswald.h"
5
+
6
+extern clock_state OswaldClk;
7
+extern watch_state OswaldState;
8
+
9
+/* gets triggered by OS timer function */
10
+void oswald_one_second_tick();
11
+void oswald_set_time(u8t hour, u8t minute, u8t second);
12
+
13
+void oswald_handle_button_press(watch_button button);
14
+void oswald_init(void);
15
+
16
+#endif
17
+
0 18
new file mode 100644
... ...
@@ -0,0 +1,88 @@
1
+#include <math.h>
2
+
3
+#include "oswald.h"
4
+#include "oswald_main.h"
5
+#include "oswald-ui.h"
6
+#include "Fonts.h"
7
+#include "LcdDisplay.h"
8
+
9
+#include "oswald_watch_faces.h"
10
+
11
+void DrawLcdAnaClock(boolean show_seconds)
12
+{
13
+	unsigned char *bbuf;
14
+	char daystr[5];
15
+	int len;
16
+	register i, x, y, x2, y2;
17
+	double tmp, mf;
18
+	s8t hour, minute, seconds;
19
+
20
+	hour = OswaldClk.hour;
21
+	minute = OswaldClk.minute;
22
+	seconds = OswaldClk.second;
23
+
24
+	hour -= 3;
25
+	mf = (1. / 59.) * (double)minute;
26
+	minute -= 15;
27
+	seconds -= 15;
28
+
29
+	lcd_clear_display();
30
+
31
+	// plot(R*cos(360° * i/N), R*sin(360° * i/N))
32
+	for (i=0; i<12; i++) {
33
+		tmp = 48. + (43. * cos(((2. * M_PI) / 12.) * (double)i));
34
+		x =  tmp;
35
+		tmp = 48 + (43. * sin(((2. * M_PI) / 12.) * (double)i));
36
+		y =  tmp;
37
+		tmp = 48. + (48. * cos(((2. * M_PI) / 12.) * (double)i));
38
+		x2 =  tmp;
39
+		tmp = 48 + (48. * sin(((2. * M_PI) / 12.) * (double)i));
40
+		y2 =  tmp;
41
+		DrawLcdLineBresenhamWW(x, y, x2, y2, 2);
42
+	};
43
+	// Hour
44
+	tmp = 48. + (30. * cos(((2. * M_PI) / 12.) * ((double)hour + mf)));
45
+	x =  tmp;
46
+	tmp = 48 + (30. * sin(((2. * M_PI) / 12.) * ((double)hour + mf)));
47
+	y =  tmp;
48
+	DrawLcdLineBresenhamWW(48, 48, x, y, 2);
49
+	// Minute
50
+	tmp = 48. + (40. * cos(((2. * M_PI) / 60.) * (double)minute));
51
+	x =  tmp;
52
+	tmp = 48 + (40. * sin(((2. * M_PI) / 60.) * (double)minute));
53
+	y =  tmp;
54
+	DrawLcdLineBresenhamWW(48, 48, x, y, 2);
55
+	if (show_seconds) {
56
+		// Seconds
57
+		tmp = 48. + (40. * cos(((2. * M_PI) / 60.) * (double)seconds));
58
+		x =  tmp;
59
+		tmp = 48 + (40. * sin(((2. * M_PI) / 60.) * (double)seconds));
60
+		y =  tmp;
61
+		DrawLcdLineBresenham(48, 48, x, y);
62
+	};
63
+
64
+	//snprintf(daystr, 5, "%d", day);
65
+	// mw_buf_print(mwbuf, 74, 45, daystr, 0, MW_WHITE, MW_BLACK);
66
+}
67
+
68
+void DrawLcdDigitalClock(boolean show_seconds)
69
+{
70
+	gint gRow = 3;
71
+	gint gColumn = 4;
72
+
73
+	SetFont(MetaWatchTime);
74
+
75
+	lcd_clear_display();
76
+	//gRow += WriteLcdCharacter(ui, gRow, gColumn, TIME_CHARACTER_SPACE_INDEX);
77
+	gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.hour / 10));
78
+	gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.hour % 10));
79
+	gRow += WriteLcdCharacter(gRow, gColumn, TIME_CHARACTER_COLON_INDEX);
80
+	gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.minute / 10));
81
+	gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.minute % 10));
82
+	if (show_seconds) {
83
+		gRow += WriteLcdCharacter(gRow, gColumn, TIME_CHARACTER_COLON_INDEX);
84
+		gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.second / 10));
85
+		gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.second % 10));
86
+	};
87
+}
88
+
0 89
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+#ifndef _OSWALD_WATCH_FACES_H
2
+#define _OSWALD_WATCH_FACES_H
3
+
4
+void DrawLcdAnaClock(boolean show_seconds);
5
+void DrawLcdDigitalClock(boolean show_seconds);
6
+
7
+#endif
8
+