Browse code

Rework font code, add new fonts, also proportional, rework watch usage - "SET" button now enters settings mode

Nils Faerber authored on 04/05/2013 19:23:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,168 +0,0 @@
1
-#include "oswald.h"
2
-#include "oswald_hal.h"
3
-#include "oswald_strings.h"
4
-#include "Fonts.h"
5
-
6
-#include "LcdDisplay.h"
7
-
8
-
9
-void DrawLcdLineBresenham(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend)
10
-{
11
-	int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
12
- 
13
-	dx = xend - xstart;
14
-	dy = yend - ystart;
15
- 
16
-	incx = (dx >= 0) ? 1 : -1;
17
-	incy = (dy >= 0) ? 1 : -1;
18
-
19
-	if (dx<0)
20
-		dx = -dx;
21
-	if (dy<0)
22
-		dy = -dy;
23
- 
24
-	if (dx>dy) {
25
-		pdx = incx; pdy = 0;
26
-		ddx=incx; ddy=incy;
27
-		es =dy;   el =dx;
28
-	} else {
29
-		pdx=0;    pdy=incy;
30
-		ddx=incx; ddy=incy;
31
-		es =dx;   el =dy;
32
-	}
33
- 
34
-	x = xstart;
35
-	y = ystart;
36
-	err = el/2;
37
-	hal_lcd_set_pixel(x, y, TRUE);
38
- 
39
-	for (t = 0; t < el; ++t) {
40
-		err -= es; 
41
-		if (err < 0) {
42
-			err += el;
43
-			x += ddx;
44
-			y += ddy;
45
-		} else {
46
-			x += pdx;
47
-			y += pdy;
48
-		}
49
-		hal_lcd_set_pixel(x, y, TRUE);
50
-	}
51
-	// lcd_update_display();
52
-}
53
-
54
-void DrawLcdLineBresenhamWW(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness)
55
-{
56
-	int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
57
- 
58
-	dx = xend - xstart;
59
-	dy = yend - ystart;
60
- 
61
-	incx = (dx >= 0) ? 1 : -1;
62
-	incy = (dy >= 0) ? 1 : -1;
63
-
64
-	if (dx<0)
65
-		dx = -dx;
66
-	if (dy<0)
67
-		dy = -dy;
68
- 
69
-	if (dx>dy) {
70
-		pdx = incx; pdy = 0;
71
-		ddx=incx; ddy=incy;
72
-		es =dy;   el =dx;
73
-	} else {
74
-		pdx=0;    pdy=incy;
75
-		ddx=incx; ddy=incy;
76
-		es =dx;   el =dy;
77
-	}
78
- 
79
-	x = xstart;
80
-	y = ystart;
81
-	err = el/2;
82
-	hal_lcd_set_pixel(x, y, TRUE);
83
-	for (i=1; i<thickness; i++) {
84
-		hal_lcd_set_pixel(x-i, y, TRUE);
85
-		hal_lcd_set_pixel(x+i, y, TRUE);
86
-		hal_lcd_set_pixel(x, y-i, TRUE);
87
-		hal_lcd_set_pixel(x, y+i, TRUE);
88
-	}
89
- 
90
-	for (t = 0; t < el; ++t) {
91
-		err -= es; 
92
-		if (err < 0) {
93
-			err += el;
94
-			x += ddx;
95
-			y += ddy;
96
-		} else {
97
-			x += pdx;
98
-			y += pdy;
99
-		}
100
-		hal_lcd_set_pixel(x, y, TRUE);
101
-		for (i=1; i<thickness; i++) {
102
-			hal_lcd_set_pixel(x-i, y, TRUE);
103
-			hal_lcd_set_pixel(x+i, y, TRUE);
104
-			hal_lcd_set_pixel(x, y-i, TRUE);
105
-			hal_lcd_set_pixel(x, y+i, TRUE);
106
-		}
107
-	}
108
-	// lcd_update_display();
109
-}
110
-
111
-u8t WriteLcdCharacter(const uint8_t x, const uint8_t y, const uint8_t Character)
112
-{
113
-	u8t CharacterHeight = GetCharacterHeight();
114
-	u8t CharacterWidth = GetCharacterWidth(Character);
115
-	u16t bitmap[MAX_FONT_ROWS];
116
-	int lx, ly;
117
-
118
-	GetCharacterBitmap(Character, bitmap);
119
-
120
-	// printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight);
121
-	for (ly=0; ly<CharacterHeight; ly++) {
122
-		for (lx=0; lx<CharacterWidth; lx++) {
123
-			if (bitmap[ly] & (1<<lx)) {
124
-				hal_lcd_set_pixel(lx+x, ly+y, TRUE);
125
-				// printf(".");
126
-			} /*else {
127
-				hal_lcd_set_pixel(lx+x, ly+y, FALSE);
128
-				// printf(" ");
129
-			}*/
130
-		}
131
-		// printf("\n");
132
-	}
133
-	// lcd_update_display();
134
-	return CharacterWidth + GetFontSpacing();
135
-}
136
-
137
-u8t WriteLcdString(const uint8_t x, const uint8_t y, const char *str)
138
-{
139
-	int lx, i, strl;
140
-
141
-	strl = oswald_strlen((char *)str);
142
-	if (strl == 0)
143
-		return 0;
144
-
145
-	lx = x;
146
-	for (i=0; i<strl; i++) {
147
-		lx += WriteLcdCharacter(lx, y, str[i]);
148
-	}
149
-	return lx;
150
-}
151
-
152
-
153
-void WriteLcdNumber(const uint8_t x, const uint8_t y, const int16_t number)
154
-{
155
-	int lx, i, strl;
156
-	char str[8];
157
-
158
-	itoa(number, str, 10);
159
-	strl = oswald_strlen(str);
160
-	if (strl == 0)
161
-		return;
162
-
163
-	lx = x;
164
-	for (i=0; i<strl; i++) {
165
-		lx += WriteLcdCharacter(lx, y, str[i]);
166
-	}
167
-}
168
-
Browse code

Starting to get rid of borrowed code (LcdDisplay, Fonts), integrate new fonts and stuff

Nils Faerber authored on 28/04/2013 22:38:41
Showing 1 changed files
... ...
@@ -6,21 +6,6 @@
6 6
 #include "LcdDisplay.h"
7 7
 
8 8
 
9
-void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp)
10
-{
11
-	uint8_t x, y;
12
-	uint8_t *cb;
13
-
14
-	// we only draw set pixel, unset pixel remain as they are
15
-	for (y=0; y<height; y++) {
16
-		for (x=0; x<width; x++) {
17
-			cb = (uint8_t *)(bmp + (y * ((width / 8)+((width % 8) ? 1:0))) + (x / 8));
18
-			if (*cb & (1 << (x % 8)))
19
-				hal_lcd_set_pixel(xstart + x, ystart + y, TRUE);
20
-		}
21
-	}
22
-}
23
-
24 9
 void DrawLcdLineBresenham(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend)
25 10
 {
26 11
 	int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
Browse code

Lot's of stuff...

Nils Faerber authored on 27/04/2013 20:19:55
Showing 1 changed files
... ...
@@ -5,6 +5,7 @@
5 5
 
6 6
 #include "LcdDisplay.h"
7 7
 
8
+
8 9
 void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp)
9 10
 {
10 11
 	uint8_t x, y;
... ...
@@ -20,7 +21,7 @@ void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_
20 21
 	}
21 22
 }
22 23
 
23
-void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
24
+void DrawLcdLineBresenham(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend)
24 25
 {
25 26
 	int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
26 27
  
... ...
@@ -65,7 +66,7 @@ void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
65 66
 	// lcd_update_display();
66 67
 }
67 68
 
68
-void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness)
69
+void DrawLcdLineBresenhamWW(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness)
69 70
 {
70 71
 	int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
71 72
  
... ...
@@ -122,7 +123,7 @@ void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thic
122 123
 	// lcd_update_display();
123 124
 }
124 125
 
125
-u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
126
+u8t WriteLcdCharacter(const uint8_t x, const uint8_t y, const uint8_t Character)
126 127
 {
127 128
 	u8t CharacterHeight = GetCharacterHeight();
128 129
 	u8t CharacterWidth = GetCharacterWidth(Character);
... ...
@@ -137,10 +138,10 @@ u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
137 138
 			if (bitmap[ly] & (1<<lx)) {
138 139
 				hal_lcd_set_pixel(lx+x, ly+y, TRUE);
139 140
 				// printf(".");
140
-			} else {
141
+			} /*else {
141 142
 				hal_lcd_set_pixel(lx+x, ly+y, FALSE);
142 143
 				// printf(" ");
143
-			}
144
+			}*/
144 145
 		}
145 146
 		// printf("\n");
146 147
 	}
... ...
@@ -148,11 +149,11 @@ u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
148 149
 	return CharacterWidth + GetFontSpacing();
149 150
 }
150 151
 
151
-u8t WriteLcdString(u8t x, u8t y, char *str)
152
+u8t WriteLcdString(const uint8_t x, const uint8_t y, const char *str)
152 153
 {
153 154
 	int lx, i, strl;
154 155
 
155
-	strl = oswald_strlen(str);
156
+	strl = oswald_strlen((char *)str);
156 157
 	if (strl == 0)
157 158
 		return 0;
158 159
 
... ...
@@ -164,7 +165,7 @@ u8t WriteLcdString(u8t x, u8t y, char *str)
164 165
 }
165 166
 
166 167
 
167
-void WriteLcdNumber(u8t x, u8t y, s16t number)
168
+void WriteLcdNumber(const uint8_t x, const uint8_t y, const int16_t number)
168 169
 {
169 170
 	int lx, i, strl;
170 171
 	char str[8];
Browse code

Bluetooth handling, screen reworks for icons

Nils Faerber authored on 21/04/2013 23:10:13
Showing 1 changed files
... ...
@@ -5,6 +5,21 @@
5 5
 
6 6
 #include "LcdDisplay.h"
7 7
 
8
+void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp)
9
+{
10
+	uint8_t x, y;
11
+	uint8_t *cb;
12
+
13
+	// we only draw set pixel, unset pixel remain as they are
14
+	for (y=0; y<height; y++) {
15
+		for (x=0; x<width; x++) {
16
+			cb = (uint8_t *)(bmp + (y * ((width / 8)+((width % 8) ? 1:0))) + (x / 8));
17
+			if (*cb & (1 << (x % 8)))
18
+				hal_lcd_set_pixel(xstart + x, ystart + y, TRUE);
19
+		}
20
+	}
21
+}
22
+
8 23
 void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
9 24
 {
10 25
 	int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
Browse code

Oh boy... lots of changes, too many to describe

Nils Faerber authored on 21/04/2013 14:26:38
Showing 1 changed files
... ...
@@ -1,4 +1,5 @@
1
-#include "oswald-ui.h"
1
+#include "oswald.h"
2
+#include "oswald_hal.h"
2 3
 #include "oswald_strings.h"
3 4
 #include "Fonts.h"
4 5
 
... ...
@@ -32,7 +33,7 @@ void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
32 33
 	x = xstart;
33 34
 	y = ystart;
34 35
 	err = el/2;
35
-	lcd_set_pixel(x, y, TRUE);
36
+	hal_lcd_set_pixel(x, y, TRUE);
36 37
  
37 38
 	for (t = 0; t < el; ++t) {
38 39
 		err -= es; 
... ...
@@ -44,7 +45,7 @@ void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
44 45
 			x += pdx;
45 46
 			y += pdy;
46 47
 		}
47
-		lcd_set_pixel(x, y, TRUE);
48
+		hal_lcd_set_pixel(x, y, TRUE);
48 49
 	}
49 50
 	// lcd_update_display();
50 51
 }
... ...
@@ -77,12 +78,12 @@ void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thic
77 78
 	x = xstart;
78 79
 	y = ystart;
79 80
 	err = el/2;
80
-	lcd_set_pixel(x, y, TRUE);
81
+	hal_lcd_set_pixel(x, y, TRUE);
81 82
 	for (i=1; i<thickness; i++) {
82
-		lcd_set_pixel(x-i, y, TRUE);
83
-		lcd_set_pixel(x+i, y, TRUE);
84
-		lcd_set_pixel(x, y-i, TRUE);
85
-		lcd_set_pixel(x, y+i, TRUE);
83
+		hal_lcd_set_pixel(x-i, y, TRUE);
84
+		hal_lcd_set_pixel(x+i, y, TRUE);
85
+		hal_lcd_set_pixel(x, y-i, TRUE);
86
+		hal_lcd_set_pixel(x, y+i, TRUE);
86 87
 	}
87 88
  
88 89
 	for (t = 0; t < el; ++t) {
... ...
@@ -95,12 +96,12 @@ void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thic
95 96
 			x += pdx;
96 97
 			y += pdy;
97 98
 		}
98
-		lcd_set_pixel(x, y, TRUE);
99
+		hal_lcd_set_pixel(x, y, TRUE);
99 100
 		for (i=1; i<thickness; i++) {
100
-			lcd_set_pixel(x-i, y, TRUE);
101
-			lcd_set_pixel(x+i, y, TRUE);
102
-			lcd_set_pixel(x, y-i, TRUE);
103
-			lcd_set_pixel(x, y+i, TRUE);
101
+			hal_lcd_set_pixel(x-i, y, TRUE);
102
+			hal_lcd_set_pixel(x+i, y, TRUE);
103
+			hal_lcd_set_pixel(x, y-i, TRUE);
104
+			hal_lcd_set_pixel(x, y+i, TRUE);
104 105
 		}
105 106
 	}
106 107
 	// lcd_update_display();
... ...
@@ -119,10 +120,10 @@ u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
119 120
 	for (ly=0; ly<CharacterHeight; ly++) {
120 121
 		for (lx=0; lx<CharacterWidth; lx++) {
121 122
 			if (bitmap[ly] & (1<<lx)) {
122
-				lcd_set_pixel(lx+x, ly+y, TRUE);
123
+				hal_lcd_set_pixel(lx+x, ly+y, TRUE);
123 124
 				// printf(".");
124 125
 			} else {
125
-				lcd_set_pixel(lx+x, ly+y, FALSE);
126
+				hal_lcd_set_pixel(lx+x, ly+y, FALSE);
126 127
 				// printf(" ");
127 128
 			}
128 129
 		}
... ...
@@ -132,18 +133,19 @@ u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
132 133
 	return CharacterWidth + GetFontSpacing();
133 134
 }
134 135
 
135
-void WriteLcdString(u8t x, u8t y, char *str)
136
+u8t WriteLcdString(u8t x, u8t y, char *str)
136 137
 {
137 138
 	int lx, i, strl;
138 139
 
139 140
 	strl = oswald_strlen(str);
140 141
 	if (strl == 0)
141
-		return;
142
+		return 0;
142 143
 
143 144
 	lx = x;
144 145
 	for (i=0; i<strl; i++) {
145 146
 		lx += WriteLcdCharacter(lx, y, str[i]);
146 147
 	}
148
+	return lx;
147 149
 }
148 150
 
149 151
 
Browse code

Add fixes for it to work properly on microcontroller

Nils Faerber authored on 19/03/2013 19:22:58
Showing 1 changed files
... ...
@@ -4,11 +4,6 @@
4 4
 
5 5
 #include "LcdDisplay.h"
6 6
 
7
-#define NUM_LCD_ROWS  96
8
-#define NUM_LCD_COL_BYTES  ( 12 )
9
-#define MAX_FONT_ROWS ( 19 )
10
-
11
-
12 7
 void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
13 8
 {
14 9
 	int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
... ...
@@ -51,6 +46,7 @@ void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
51 46
 		}
52 47
 		lcd_set_pixel(x, y, TRUE);
53 48
 	}
49
+	// lcd_update_display();
54 50
 }
55 51
 
56 52
 void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness)
... ...
@@ -107,16 +103,17 @@ void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thic
107 103
 			lcd_set_pixel(x, y+i, TRUE);
108 104
 		}
109 105
 	}
106
+	// lcd_update_display();
110 107
 }
111 108
 
112 109
 u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
113 110
 {
114 111
 	u8t CharacterHeight = GetCharacterHeight();
115 112
 	u8t CharacterWidth = GetCharacterWidth(Character);
116
-	unsigned int bitmap[MAX_FONT_ROWS];
117
-	register lx, ly;
113
+	u16t bitmap[MAX_FONT_ROWS];
114
+	int lx, ly;
118 115
 
119
-	GetCharacterBitmap(Character,(unsigned int*)&bitmap);
116
+	GetCharacterBitmap(Character, bitmap);
120 117
 
121 118
 	// printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight);
122 119
 	for (ly=0; ly<CharacterHeight; ly++) {
... ...
@@ -131,13 +128,13 @@ u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
131 128
 		}
132 129
 		// printf("\n");
133 130
 	}
134
-
131
+	// lcd_update_display();
135 132
 	return CharacterWidth + GetFontSpacing();
136 133
 }
137 134
 
138
-void WriteLcdString(u8t x, u8t y, u8t *str)
135
+void WriteLcdString(u8t x, u8t y, char *str)
139 136
 {
140
-	register lx, i, strl;
137
+	int lx, i, strl;
141 138
 
142 139
 	strl = oswald_strlen(str);
143 140
 	if (strl == 0)
... ...
@@ -152,8 +149,8 @@ void WriteLcdString(u8t x, u8t y, u8t *str)
152 149
 
153 150
 void WriteLcdNumber(u8t x, u8t y, s16t number)
154 151
 {
155
-	register lx, i, strl;
156
-	u8t str[8];
152
+	int lx, i, strl;
153
+	char str[8];
157 154
 
158 155
 	itoa(number, str, 10);
159 156
 	strl = oswald_strlen(str);
Browse code

Countless fixes and enhancements

Nils Faerber authored on 12/08/2012 21:14:19
Showing 1 changed files
... ...
@@ -109,7 +109,6 @@ void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thic
109 109
 	}
110 110
 }
111 111
 
112
-
113 112
 u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
114 113
 {
115 114
 	u8t CharacterHeight = GetCharacterHeight();
... ...
@@ -150,3 +149,20 @@ void WriteLcdString(u8t x, u8t y, u8t *str)
150 149
 	}
151 150
 }
152 151
 
152
+
153
+void WriteLcdNumber(u8t x, u8t y, s16t number)
154
+{
155
+	register lx, i, strl;
156
+	u8t str[8];
157
+
158
+	itoa(number, str, 10);
159
+	strl = oswald_strlen(str);
160
+	if (strl == 0)
161
+		return;
162
+
163
+	lx = x;
164
+	for (i=0; i<strl; i++) {
165
+		lx += WriteLcdCharacter(lx, y, str[i]);
166
+	}
167
+}
168
+
Browse code

Add support for more screens

Nils Faerber authored on 06/08/2012 14:12:20
Showing 1 changed files
... ...
@@ -1,9 +1,5 @@
1
-#include <time.h>
2
-#include <stdio.h>
3
-#include <string.h>
4
-#include <math.h>
5
-
6 1
 #include "oswald-ui.h"
2
+#include "oswald_strings.h"
7 3
 #include "Fonts.h"
8 4
 
9 5
 #include "LcdDisplay.h"
... ...
@@ -142,13 +138,14 @@ u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
142 138
 
143 139
 void WriteLcdString(u8t x, u8t y, u8t *str)
144 140
 {
145
-	register lx, i;
141
+	register lx, i, strl;
146 142
 
147
-	if (str == NULL || strlen(str)==0)
143
+	strl = oswald_strlen(str);
144
+	if (strl == 0)
148 145
 		return;
149 146
 
150 147
 	lx = x;
151
-	for (i=0; i<strlen(str); i++) {
148
+	for (i=0; i<strl; i++) {
152 149
 		lx += WriteLcdCharacter(lx, y, str[i]);
153 150
 	}
154 151
 }
Browse code

Too much to note...

Nils Faerber authored on 05/08/2012 17:07:17
Showing 1 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
-
Browse code

Add MetaWatch Fonts package, LcdDisplay and start demo

Nils Faerber authored on 31/07/2012 21:42:03
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,73 @@
1
+#include <time.h>
2
+#include <stdio.h>
3
+#include <string.h>
4
+
5
+#include "oswald-ui.h"
6
+#include "Fonts.h"
7
+#include "LcdDisplay.h"
8
+
9
+#define NUM_LCD_ROWS  96
10
+#define NUM_LCD_COL_BYTES  ( 12 )
11
+#define MAX_FONT_ROWS ( 19 )
12
+
13
+
14
+gint WriteLcdCharacter(oswald_ui *ui, gint x, gint y, unsigned char Character)
15
+{
16
+	gint CharacterHeight = GetCharacterHeight();
17
+	gint CharacterWidth = GetCharacterWidth(Character);
18
+	unsigned int bitmap[MAX_FONT_ROWS];
19
+	gint lx, ly;
20
+
21
+	GetCharacterBitmap(Character,(unsigned int*)&bitmap);
22
+
23
+	// printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight);
24
+	for (ly=0; ly<CharacterHeight; ly++) {
25
+		for (lx=0; lx<CharacterWidth; lx++) {
26
+			if (bitmap[ly] & (1<<lx)) {
27
+				set_pixel(ui, lx+x, ly+y, TRUE);
28
+				// printf(".");
29
+			} else {
30
+				set_pixel(ui, lx+x, ly+y, FALSE);
31
+				// printf(" ");
32
+			}
33
+		}
34
+		// printf("\n");
35
+	}
36
+
37
+	return CharacterWidth + GetFontSpacing();
38
+}
39
+
40
+void WriteLcdString(oswald_ui *ui, gint x, gint y, gchar *str)
41
+{
42
+	gint lx, i;
43
+
44
+	if (str == NULL || strlen(str)==0)
45
+		return;
46
+
47
+	lx = x;
48
+	for (i=0; i<strlen(str); i++) {
49
+		lx += WriteLcdCharacter(ui, lx, y, str[i]);
50
+	}
51
+}
52
+
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
+