Hanna
Sourcecode Batteriemanagementsystem
lib_gfx_bms.c
gehe zur Dokumentation dieser Datei
1 
14 #include <avr/io.h>
15 #include <stdio.h>
16 #include <gfx.h>
17 #include <sysfont.h>
18 #include <stdio.h>
19 #include <string.h>
20 #include <stddef.h>
21 #include <stdlib.h>
22 #include <avr/io.h>
23 #include <avr/pgmspace.h>
24 #include <lib_gfx_bms.h>
25 
26 /* Include bitmaps */
27 #include "lib_icons.h"
28 
39 void gfx_draw_battery ( uint16_t x, uint16_t y, uint16_t color, uint8_t cross )
40 {
41  // Batterie-Icon, senkrecht, 14x27
42 
43  // Kreuz "durchgestrichen" löschen
44  gfx_draw_line( x - 3, y - 3, x + 14 + 3, y + 27 + 3, GFX_COLOR_WHITE );
45  gfx_draw_line( x - 2, y - 3, x + 14 + 4, y + 27 + 3, GFX_COLOR_WHITE );
46  gfx_draw_line( x + 14 + 2, y - 3, x - 2, y + 27 + 3, GFX_COLOR_WHITE );
47  gfx_draw_line( x + 14 + 3, y - 3, x - 3, y + 27 + 3, GFX_COLOR_WHITE );
48 
49  gfx_draw_filled_rect( x, y + 3, 14, 24, GFX_COLOR_BLACK );
50  gfx_draw_filled_rect( x + 2, y + 5, 10, 20, color );
51  gfx_draw_filled_rect( x + 4, y, 6, 3, GFX_COLOR_BLACK );
52 
53  // Kreuz "durchgestrichen" zeichnen, wenn cross = true
54  if ( cross )
55  {
56  gfx_draw_line( x - 3, y - 3, x + 14 + 3, y + 27 + 3, GFX_COLOR_BLACK );
57  gfx_draw_line( x - 2, y - 3, x + 14 + 4, y + 27 + 3, GFX_COLOR_BLACK );
58  gfx_draw_line( x + 14 + 2, y - 3, x - 2, y + 27 + 3, GFX_COLOR_BLACK );
59  gfx_draw_line( x + 14 + 3, y - 3, x - 3, y + 27 + 3, GFX_COLOR_BLACK );
60  }
61 }
62 
63 
74 void gfx_draw_hor_battery ( uint16_t x, uint16_t y, uint16_t color, uint8_t cross )
75 {
76  // Batterie hor. Icon 62x30
77 
78  // Kreuz "durchgestrichen" löschen
79  gfx_draw_line( x - 3, y - 3, x + 61 + 3, y + 30 + 3, GFX_COLOR_WHITE );
80  gfx_draw_line( x - 2, y - 3, x + 61 + 4, y + 30 + 3, GFX_COLOR_WHITE );
81  gfx_draw_line( x + 61 + 2, y - 3, x - 2, y + 30 + 3, GFX_COLOR_WHITE );
82  gfx_draw_line( x + 61 + 3, y - 3, x - 3, y + 30 + 3, GFX_COLOR_WHITE );
83 
84  gfx_draw_filled_rect( x, y, 58, 30, GFX_COLOR_BLACK );
85  gfx_draw_filled_rect( x + 3, y + 3, 52, 24, color );
86  gfx_draw_filled_rect( x + 59, y + 8, 4, 14, GFX_COLOR_BLACK );
87 
88  // Kreuz "durchgestrichen" zeichnen, wenn cross = true
89  if ( cross )
90  {
91  gfx_draw_line( x - 3, y - 3, x + 61 + 3, y + 30 + 3, GFX_COLOR_BLACK );
92  gfx_draw_line( x - 2, y - 3, x + 61 + 4, y + 30 + 3, GFX_COLOR_BLACK );
93  gfx_draw_line( x + 61 + 2, y - 3, x - 2, y + 30 + 3, GFX_COLOR_BLACK );
94  gfx_draw_line( x + 61 + 3, y - 3, x - 3, y + 30 + 3, GFX_COLOR_BLACK );
95  }
96 }
97 
106 void gfx_draw_soh ( uint16_t x, uint16_t y )
107 {
108  // State of Health Icon, 26x52
109  gfx_draw_filled_rect( x, y + 4, 26, 48, GFX_COLOR_BLACK );
110 // gfx_draw_rect( x + 2, y + 6, 22, 44, GFX_COLOR_BLACK );
111  gfx_draw_filled_rect( x + 3, y + 7, 20, 42, GFX_COLOR_BLUE );
112  gfx_draw_filled_rect( x + 7, y, 12, 4, GFX_COLOR_BLACK );
113 
114  gfx_draw_bitmap( &ico_aeskulap, x + 6, y + 11 );
115 
116 }
117 
127 void gfx_draw_soc ( uint16_t x, uint16_t y, uint8_t charge )
128 {
129  // Ladezustand Icon 62x30
130  uint16_t color_charge1, color_charge2, color_charge3, color_charge4;
131 
132  // Kreuz "durchgestrichen" löschen
133  gfx_draw_line( x - 4, y - 3, x + 61 + 2, y + 30 + 3, GFX_COLOR_WHITE );
134  gfx_draw_line( x - 3, y - 3, x + 61 + 3, y + 30 + 3, GFX_COLOR_WHITE );
135  gfx_draw_line( x - 2, y - 3, x + 61 + 4, y + 30 + 3, GFX_COLOR_WHITE );
136  gfx_draw_line( x + 61 + 4, y - 3, x - 2, y + 30 + 3, GFX_COLOR_WHITE );
137  gfx_draw_line( x + 61 + 2, y - 3, x - 4, y + 30 + 3, GFX_COLOR_WHITE );
138  gfx_draw_line( x + 61 + 3, y - 3, x - 3, y + 30 + 3, GFX_COLOR_WHITE );
139 
140  gfx_draw_filled_rect( x, y, 58, 30, GFX_COLOR_BLACK );
141  gfx_draw_filled_rect( x + 59, y + 8, 4, 14, GFX_COLOR_BLACK );
142 
143  // Farben für die Segmente festlegen
144  switch (charge)
145  {
146  case GFX_CHARGE_FULL:
147  color_charge1 = GFX_COLOR_GREEN;
148  color_charge2 = GFX_COLOR_GREEN;
149  color_charge3 = GFX_COLOR_GREEN;
150  color_charge4 = GFX_COLOR_GREEN;
151  break;
152  case GFX_CHARGE_3_4:
153  color_charge1 = GFX_COLOR_GREEN;
154  color_charge2 = GFX_COLOR_GREEN;
155  color_charge3 = GFX_COLOR_GREEN;
156  color_charge4 = GFX_COLOR_LT_GRAY;
157  break;
158  case GFX_CHARGE_2_4:
159  color_charge1 = GFX_COLOR_GREEN;
160  color_charge2 = GFX_COLOR_GREEN;
161  color_charge3 = GFX_COLOR_LT_GRAY;
162  color_charge4 = GFX_COLOR_LT_GRAY;
163  break;
164  case GFX_CHARGE_1_4:
165  color_charge1 = GFX_COLOR_GREEN;
166  color_charge2 = GFX_COLOR_LT_GRAY;
167  color_charge3 = GFX_COLOR_LT_GRAY;
168  color_charge4 = GFX_COLOR_LT_GRAY;
169  break;
170  case GFX_CHARGE_WARN:
171  color_charge1 = GFX_COLOR_YELLOW;
172  color_charge2 = GFX_COLOR_LT_GRAY;
173  color_charge3 = GFX_COLOR_LT_GRAY;
174  color_charge4 = GFX_COLOR_LT_GRAY;
175  break;
176  case GFX_CHARGE_CRIT:
177  color_charge1 = GFX_COLOR_RED;
178  color_charge2 = GFX_COLOR_LT_GRAY;
179  color_charge3 = GFX_COLOR_LT_GRAY;
180  color_charge4 = GFX_COLOR_LT_GRAY;
181  break;
182  case GFX_CHARGE_EMPTY:
183  color_charge1 = GFX_COLOR_RED;
184  color_charge2 = GFX_COLOR_RED;
185  color_charge3 = GFX_COLOR_RED;
186  color_charge4 = GFX_COLOR_RED;
187  break;
188  default:
189  break;
190  }
191 
192  // Segmente farblich darstellen
193  gfx_draw_filled_rect( x + 2, y + 2, 12, 26, color_charge1 );
194  gfx_draw_filled_rect( x + 16, y + 2, 12, 26, color_charge2 );
195  gfx_draw_filled_rect( x + 30, y + 2, 12, 26, color_charge3 );
196  gfx_draw_filled_rect( x + 44, y + 2, 12, 26, color_charge4 );
197 
198  // Kreuz mit schwarzen Linien
199  if ( charge == GFX_CHARGE_EMPTY )
200  {
201  gfx_draw_line( x - 4, y - 3, x + 61 + 2, y + 30 + 3, GFX_COLOR_BLACK );
202  gfx_draw_line( x - 3, y - 3, x + 61 + 3, y + 30 + 3, GFX_COLOR_BLACK );
203  gfx_draw_line( x - 2, y - 3, x + 61 + 4, y + 30 + 3, GFX_COLOR_BLACK );
204  gfx_draw_line( x + 61 + 4, y - 3, x - 2, y + 30 + 3, GFX_COLOR_BLACK );
205  gfx_draw_line( x + 61 + 2, y - 3, x - 4, y + 30 + 3, GFX_COLOR_BLACK );
206  gfx_draw_line( x + 61 + 3, y - 3, x - 3, y + 30 + 3, GFX_COLOR_BLACK );
207  }
208 
209 }
210 
219 void gfx_draw_warning ( uint16_t x, uint16_t y )
220 {
221  // Warning Icon 34x34
222  uint8_t radius = 17;
223 
224  gfx_draw_filled_circle( x + radius, y + radius, radius, GFX_COLOR_RED, GFX_WHOLE );
225  gfx_draw_filled_rect( x + 15, y + 5, 5, 15, GFX_COLOR_WHITE );
226  gfx_draw_filled_rect( x + 15, y + 25, 5, 5, GFX_COLOR_WHITE );
227 
228 }
229 
237 void gfx_draw_time ( uint16_t x, uint16_t y )
238 {
239  // Time Icon, 34x34
240  uint8_t radius = 17;
241 
242  gfx_draw_filled_circle( x + radius, y + radius, radius, GFX_COLOR_BLACK, GFX_WHOLE );
243  gfx_draw_filled_circle( x + radius, y + radius, radius - 4, GFX_COLOR_WHITE, GFX_WHOLE );
244  gfx_draw_filled_rect( x + 15, y + 9, 4, 8, GFX_COLOR_BLACK );
245  gfx_draw_line( x + 18, y + 17, x + 27, y + 20, GFX_COLOR_BLACK );
246  gfx_draw_line( x + 17, y + 17, x + 26, y + 20, GFX_COLOR_BLACK );
247  gfx_draw_line( x + 16, y + 17, x + 25, y + 20, GFX_COLOR_BLACK );
248  gfx_draw_line( x + 15, y + 17, x + 24, y + 20, GFX_COLOR_BLACK );
249 
250 }
251 
261 void gfx_draw_temperatur ( uint16_t x, uint16_t y, uint16_t color )
262 {
263  // Temperature Icon, 24x45
264  uint8_t radius1 = 12;
265  uint8_t radius2 = 7;
266 
267  gfx_draw_filled_circle( x + radius1, y + 34, radius1, GFX_COLOR_BLACK, GFX_WHOLE );
268  gfx_draw_filled_circle( x + radius1, y + 34, radius1 - 3, GFX_COLOR_WHITE, GFX_WHOLE );
269 
270  gfx_draw_filled_circle( x + radius1, y + radius2, radius2, GFX_COLOR_BLACK, GFX_WHOLE );
271  gfx_draw_filled_circle( x + radius1, y + radius2, radius2 - 3, GFX_COLOR_WHITE, GFX_WHOLE );
272 
273  gfx_draw_filled_rect( x + 8, y + radius2, 9, 26, GFX_COLOR_WHITE ); // Hintergrund Temperatursäule
274  gfx_draw_filled_rect( x + 5, y + radius2, 3, 18, GFX_COLOR_BLACK ); // Linker Rand
275  gfx_draw_filled_rect( x + 17, y + radius2, 3, 18, GFX_COLOR_BLACK ); // Rechter Rand
276  gfx_draw_filled_rect( x + 10, y + 17, 5, 17, color ); // Temperatursäule
277 
278  gfx_draw_filled_circle( x + radius1, y + 34, radius1 - 6, color, GFX_WHOLE ); // Kugel Flüssigkeit
279 
280  gfx_draw_filled_rect( x + 1, y + 6, 5, 2, GFX_COLOR_BLACK ); // Skalenstriche
281  gfx_draw_filled_rect( x + 1, y + 10, 5, 2, GFX_COLOR_BLACK ); // Skalenstriche
282  gfx_draw_filled_rect( x + 1, y + 14, 5, 2, GFX_COLOR_BLACK ); // Skalenstriche
283  gfx_draw_filled_rect( x + 1, y + 18, 5, 2, GFX_COLOR_BLACK ); // Skalenstriche
284 }
285 
294 void gfx_draw_current ( uint16_t x, uint16_t y )
295 {
296  // Strom Icon, 44x38
297  uint8_t radius = 7;
298  gfx_draw_bitmap( &ico_dreieck_gelb, x, y );
299 
300  // Dreieckslinien
301 
302  gfx_draw_line( x + 22, y + 4, x + 4, y + 35, GFX_COLOR_BLACK );
303  gfx_draw_line( x + 4, y + 35, x + 40, y + 35, GFX_COLOR_BLACK );
304  gfx_draw_line( x + 40, y + 35, x + 22, y + 4, GFX_COLOR_BLACK );
305 
306  gfx_draw_line( x + 22, y + 5, x + 5, y + 34, GFX_COLOR_BLACK );
307  gfx_draw_line( x + 5, y + 34, x + 39, y + 34, GFX_COLOR_BLACK );
308  gfx_draw_line( x + 39, y + 34, x + 22, y + 5, GFX_COLOR_BLACK );
309 
310  gfx_draw_line( x + 22, y + 6, x + 6, y + 33, GFX_COLOR_BLACK );
311  gfx_draw_line( x + 38, y + 33, x + 22, y + 6, GFX_COLOR_BLACK );
312 
313  // Stecker
314  gfx_draw_filled_rect( x + 21, y + 15, 3, 7, GFX_COLOR_BLACK ); // Kabel
315  gfx_draw_filled_circle( x + 22, y + 20 + radius, radius, GFX_COLOR_BLACK, GFX_TOPHALF ); // Steckergehäuse
316  gfx_draw_filled_rect( x + 18, y + 20 + radius, 3, 5, GFX_COLOR_BLACK ); // Kontakt
317  gfx_draw_filled_rect( x + 24, y + 20 + radius, 3, 5, GFX_COLOR_BLACK ); // Kontakt
318 
319 }
320 
329 void gfx_draw_voltage ( uint16_t x, uint16_t y )
330 {
331  // Spannung Icon, 44x38
332  gfx_draw_bitmap( &ico_dreieck_gelb, x, y );
333 
334  // Dreieckslinien
335 
336  gfx_draw_line( x + 22, y + 4, x + 4, y + 35, GFX_COLOR_BLACK );
337  gfx_draw_line( x + 4, y + 35, x + 40, y + 35, GFX_COLOR_BLACK );
338  gfx_draw_line( x + 40, y + 35, x + 22, y + 4, GFX_COLOR_BLACK );
339 
340  gfx_draw_line( x + 22, y + 5, x + 5, y + 34, GFX_COLOR_BLACK );
341  gfx_draw_line( x + 5, y + 34, x + 39, y + 34, GFX_COLOR_BLACK );
342  gfx_draw_line( x + 39, y + 34, x + 22, y + 5, GFX_COLOR_BLACK );
343 
344  gfx_draw_line( x + 22, y + 6, x + 6, y + 33, GFX_COLOR_BLACK );
345  gfx_draw_line( x + 38, y + 33, x + 22, y + 6, GFX_COLOR_BLACK );
346 
347  // Blitz
348  gfx_draw_line( x + 21, y + 11, x + 16, y + 25, GFX_COLOR_BLACK );
349  gfx_draw_line( x + 22, y + 11, x + 16, y + 25, GFX_COLOR_BLACK );
350  gfx_draw_line( x + 23, y + 11, x + 17, y + 25, GFX_COLOR_BLACK );
351 
352  gfx_draw_line( x + 16, y + 25, x + 24, y + 17, GFX_COLOR_BLACK );
353  gfx_draw_line( x + 17, y + 25, x + 25, y + 17, GFX_COLOR_BLACK );
354  gfx_draw_line( x + 17, y + 25, x + 26, y + 17, GFX_COLOR_BLACK );
355 
356  gfx_draw_line( x + 24, y + 17, x + 21, y + 28, GFX_COLOR_BLACK );
357  gfx_draw_line( x + 25, y + 17, x + 22, y + 28, GFX_COLOR_BLACK );
358  gfx_draw_line( x + 26, y + 17, x + 22, y + 29, GFX_COLOR_BLACK );
359 
360  gfx_draw_line( x + 19, y + 27, x + 26, y + 28, GFX_COLOR_BLACK );
361  gfx_draw_line( x + 20, y + 28, x + 25, y + 29, GFX_COLOR_BLACK );
362  gfx_draw_line( x + 21, y + 29, x + 24, y + 30, GFX_COLOR_BLACK );
363  gfx_draw_line( x + 22, y + 30, x + 23, y + 31, GFX_COLOR_BLACK );
364  gfx_draw_line( x + 22, y + 31, x + 22, y + 32, GFX_COLOR_BLACK );
365 
366 }
367 
void gfx_draw_soh(uint16_t x, uint16_t y)
Zeichnet das SOH-Symbol.
Definition: lib_gfx_bms.c:106
void gfx_draw_time(uint16_t x, uint16_t y)
Zeichnet Uhr als Zeitsymbol - derzeit nicht eingesetzt.
Definition: lib_gfx_bms.c:237
void gfx_draw_voltage(uint16_t x, uint16_t y)
Zeichnet ein gelbes Warndreieck mit einem Blitz.
Definition: lib_gfx_bms.c:329
void gfx_draw_warning(uint16_t x, uint16_t y)
Zeichnet ein Ausrufezeichen als Warnungssymbol.
Definition: lib_gfx_bms.c:219
void gfx_draw_soc(uint16_t x, uint16_t y, uint8_t charge)
Zeichnet das SOC-Symbol, eine horizontale Batterie mit gefüllten Segmenten und verschiedenen Farben...
Definition: lib_gfx_bms.c:127
void gfx_draw_current(uint16_t x, uint16_t y)
Zeichnet ein gelbes Warndreieck mit einem Stecker.
Definition: lib_gfx_bms.c:294
Standardheader.
Graphical System Font system.
#define GFX_TOPHALF
Definition: gfx.h:163
#define gfx_draw_line(x1, y1, x2, y2, color)
Definition: gfx_ili9341.h:164
void gfx_draw_hor_battery(uint16_t x, uint16_t y, uint16_t color, uint8_t cross)
Zeichnet eine große horizontale Batterie.
Definition: lib_gfx_bms.c:74
#define gfx_draw_filled_circle(x, y, radius, color, quadrant_mask)
Definition: gfx_ili9341.h:192
#define GFX_WHOLE
Definition: gfx.h:172
Graphical library API header file.
void gfx_draw_battery(uint16_t x, uint16_t y, uint16_t color, uint8_t cross)
Zeichnet eine kleine vertikale Batterie.
Definition: lib_gfx_bms.c:39
#define gfx_draw_filled_rect(x, y, width, height, color)
Definition: gfx_ili9341.h:178
Standardheader.
void gfx_draw_temperatur(uint16_t x, uint16_t y, uint16_t color)
Zeichnet ein Thermometer, die Quecksilbersäule in unterschiedlichen Farben.
Definition: lib_gfx_bms.c:261
#define gfx_draw_bitmap(bmp, x, y)
Definition: gfx_ili9341.h:232