Browse code

Some minor improvements.

Nils Faerber authored on 06/07/2013 21:21:35
Showing 5 changed files
... ...
@@ -23,13 +23,14 @@
23 23
 
24 24
 static oswald_ui *ui_g;
25 25
 
26
-void hal_lcd_set_pixel(gint x, gint y, gboolean state)
26
+void hal_lcd_set_pixel(gint x, gint y, uint8_t state)
27 27
 {
28 28
 	gint ix, iy;
29 29
 
30 30
 	ix = x*2;
31 31
 	iy = y*2;
32 32
 
33
+	// we double all pixel to get a bigger picture
33 34
 	gdk_draw_point(GDK_DRAWABLE(ui_g->pixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix, iy);
34 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);
35 36
 	gdk_draw_point(GDK_DRAWABLE(ui_g->pixmap), state ? ui_g->darea->style->black_gc : ui_g->darea->style->white_gc, ix, iy+1);
... ...
@@ -94,7 +94,7 @@ void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t
94 94
 
95 95
 void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness)
96 96
 {
97
-	int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
97
+	int16_t i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
98 98
  
99 99
 	dx = xend - xstart;
100 100
 	dy = yend - ystart;
... ...
@@ -110,17 +110,17 @@ void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8
110 110
 	if (dx>dy) {
111 111
 		pdx = incx;
112 112
 		pdy = 0;
113
-		ddx=incx;
114
-		ddy=incy;
115
-		es =dy;
116
-		el =dx;
113
+		ddx = incx;
114
+		ddy = incy;
115
+		es = dy;
116
+		el = dx;
117 117
 	} else {
118
-		pdx=0;
119
-		pdy=incy;
120
-		ddx=incx;
121
-		ddy=incy;
122
-		es =dx;
123
-		el =dy;
118
+		pdx = 0;
119
+		pdy = incy;
120
+		ddx = incx;
121
+		ddy = incy;
122
+		es = dx;
123
+		el = dy;
124 124
 	}
125 125
  
126 126
 	x = xstart;
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 
11 11
 #define COLOR_WHITE	0
12
-//#define COLOR_BLACK	1
12
+#define COLOR_BLACK	1
13 13
 #define COLOR_XOR	2
14 14
 #define COLOR_INV	3
15 15
 
... ...
@@ -190,8 +190,8 @@ static main_menu_data_t main_menu_screen = {
190 190
 // GRID_Y is +1 since there is one empty row for title icon
191 191
 #define MAIN_MENU_GRID_Y	3
192 192
 #define MAIN_MENU_GRID_SPACING	0
193
-#define MAIN_MENU_OFFSET_X	3
194
-#define MAIN_MENU_OFFSET_Y	10
193
+#define MAIN_MENU_OFFSET_X	6
194
+#define MAIN_MENU_OFFSET_Y	8
195 195
 
196 196
 void draw_main_menu_screen(main_menu_data_t *sdata)
197 197
 {
... ...
@@ -237,6 +237,20 @@ void draw_main_menu_screen(main_menu_data_t *sdata)
237 237
 	hal_lcd_set_pixel(MAIN_MENU_OFFSET_X+23+((pf%MAIN_MENU_GRID_X) * (MAIN_MENU_GRID_PIXEL / MAIN_MENU_GRID_X)) % (MAIN_MENU_GRID_X*(MAIN_MENU_GRID_PIXEL / MAIN_MENU_GRID_X)),
238 238
 		MAIN_MENU_OFFSET_Y+23+((pf/MAIN_MENU_GRID_X) * (MAIN_MENU_GRID_PIXEL / MAIN_MENU_GRID_Y)) % (MAIN_MENU_GRID_Y*(MAIN_MENU_GRID_PIXEL / MAIN_MENU_GRID_Y)), FALSE);
239 239
 
240
+
241
+	// finally a nice border
242
+	oswald_draw_line(3, 0, 95, 0);
243
+	oswald_draw_line(2, 1, 95, 1);
244
+	oswald_draw_line(1, 2, 95, 2);
245
+
246
+	oswald_draw_line(0, 3, 0, 92);
247
+	oswald_draw_line(1, 3, 1, 93);
248
+	oswald_draw_line(2, 3, 2, 94);
249
+
250
+	oswald_draw_line(1, 93, 95, 93);
251
+	oswald_draw_line(2, 94, 95, 94);
252
+	oswald_draw_line(3, 95, 95, 95);
253
+
240 254
 	hal_lcd_update_display();
241 255
 }
242 256
 
... ...
@@ -271,13 +271,22 @@ void DrawLcdDigitalClock(boolean show_seconds)
271 271
 	gRow = 0;
272 272
 	gColumn = 45;
273 273
 	for (i=0; i<strlen(MainMessage); i++) {
274
+		// do not draw a whitespace as first character of a row
274 275
 		if (gRow == 0 && MainMessage[i] == ' ')
275 276
 			continue;
277
+		// interpret new line
278
+		if (MainMessage[i] == '\n') {
279
+			gRow = 0;
280
+			gColumn += 9;
281
+			continue;
282
+		}
276 283
 		gRow += oswald_write_character(gRow, gColumn, FONT_DROID8x12, FALSE, MainMessage[i]);
284
+		// wrap to new line if line is full
277 285
 		if (gRow > 90) {
278 286
 			gRow = 0;
279 287
 			gColumn += 9;
280 288
 		}
289
+		// OK, screen ends, leave the loop, no matter what
281 290
 		if (gColumn > 86)
282 291
 			i = 255;
283 292
 	}