Hanna
Sourcecode Batteriemanagementsystem
screens_gfx.c
gehe zur Dokumentation dieser Datei
1 
14 #include <avr/io.h>
15 #include <stdio.h>
16 #include <stdbool.h>
17 
18 #include "screens_gfx.h"
19 #include "BMS-Basic.h"
20 
21 scr_betrieb_t scr_betrieb;
22 scr_info_t scr_akku_info[8];
23 scr_laden_t scr_laden;
24 scr_warning_t scr_akku_warning;
25 uint8_t screen_flag = 0;
26 uint8_t warnung_flag = 0;
27 int8_t auswahl_nr = 0;
28 auswahl_t auswahl_batterie[8];
29 uint8_t screen_return = SCREEN_FLAG_BETRIEB;
30 bool msgbox_notaus = false;
31 
56 {
57  char text[9];
58 
59  // Bildschirm löschen
60  if ( !(screen_flag == SCREEN_FLAG_BETRIEB) )
61  {
62  gfx_draw_filled_rect( 0, 0, gfx_get_width (), gfx_get_height (), GFX_COLOR_WHITE );
63  }
64 
65  screen_flag = SCREEN_FLAG_BETRIEB;
66 
67  // Kopfzeile, 50px hoch
68  gfx_draw_bitmap( &ico_batman, 2, (50 - ico_batman.height) / 2 );
69 
70  // Verbraucher
71  if ( icon.verbraucher )
72  gfx_draw_bitmap( &ico_verbraucher_an, 120 - ico_verbraucher_an.width / 2 + 4, (50 - ico_verbraucher_an.height) / 2 );
73  else
74  gfx_draw_bitmap( &ico_verbraucher_aus, 120 - ico_verbraucher_aus.width / 2 + 4, (50 - ico_verbraucher_aus.height) / 2 );
75 
76  // Warnung
77  if ( icon.warnung )
78  gfx_draw_warning ( 240 - 15 - 34, (50 - 34) / 2 ); // Warning Icon, 34x34
79  else
80  gfx_draw_filled_rect( 240 - 15 - 36, (50 - 36) / 2, 36, 39, GFX_COLOR_WHITE );
81 
82  // Säulenüberschrift, 20px hoch
83  gfx_draw_string_aligned ( "Saule 1", BETRIEB_SPALTE_2, BETRIEB_TEXTZEILE + (20 - bpmono_10x16.height) / 2, &bpmono_10x16,
85  gfx_draw_string_aligned ( "Saule 2", BETRIEB_SPALTE_3, BETRIEB_TEXTZEILE + (20 - bpmono_10x16.height) / 2, &bpmono_10x16,
87 
88  // Batteriereihe 1, 40px hoch
89  gfx_draw_string_aligned ( "1", BETRIEB_SPALTE_1, BETRIEB_BATZEILE_1 + 12, &big_font_16x16,
90  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 70 + (40-16)/2 = 82
91 
92  gfx_draw_battery ( BETRIEB_SPALTE_2 - 7, BETRIEB_BATZEILE_1 + 7, icon.battery_color[0], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 77
93  gfx_draw_battery ( BETRIEB_SPALTE_3 - 7, BETRIEB_BATZEILE_1 + 7, icon.battery_color[4], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 77
94 
95  sprintf ( text, "%5.2fV", icon.bat_voltage[0] ); // Text 6x7; Spannung Spalte 1
96  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_2 + 15, BETRIEB_BATZEILE_1 + 17, &basic_6x7,
97  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
98 
99  sprintf ( text, "%5.2fV", icon.bat_voltage[4] ); // Text 6x7; Spannung Spalte 2
100  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_3 + 15, BETRIEB_BATZEILE_1 + 17, &basic_6x7,
101  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
102 
103  // Batteriereihe 2, 40px hoch
104  gfx_draw_string_aligned ( "2", BETRIEB_SPALTE_1, BETRIEB_BATZEILE_2 + 12, &big_font_16x16,
105  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 110 + (40-16)/2 = 122
106 
107  gfx_draw_battery ( BETRIEB_SPALTE_2 - 7, BETRIEB_BATZEILE_2 + 7, icon.battery_color[1], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 117
108  gfx_draw_battery ( BETRIEB_SPALTE_3 - 7, BETRIEB_BATZEILE_2 + 7, icon.battery_color[5], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 117
109 
110  sprintf ( text, "%5.2fV", icon.bat_voltage[1] ); // Text 6x7; Spannung Spalte 1
111  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_2 + 15, BETRIEB_BATZEILE_2 + 17, &basic_6x7,
112  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
113 
114  sprintf ( text, "%5.2fV", icon.bat_voltage[5] ); // Text 6x7; Spannung Spalte 2
115  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_3 + 15, BETRIEB_BATZEILE_2 + 17, &basic_6x7,
116  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
117 
118  // Batteriereihe 3, 40px hoch
119  gfx_draw_string_aligned ( "3", BETRIEB_SPALTE_1, BETRIEB_BATZEILE_3 + 12, &big_font_16x16,
120  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 150 + (40-16)/2 = 162
121 
122  gfx_draw_battery ( BETRIEB_SPALTE_2 - 7, BETRIEB_BATZEILE_3 + 7, icon.battery_color[2], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 157
123  gfx_draw_battery ( BETRIEB_SPALTE_3 - 7, BETRIEB_BATZEILE_3 + 7, icon.battery_color[6], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 157
124 
125  sprintf ( text, "%5.2fV", icon.bat_voltage[2] ); // Text 6x7; Spannung Spalte 1
126  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_2 + 15, BETRIEB_BATZEILE_3 + 17, &basic_6x7,
127  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
128 
129  sprintf ( text, "%5.2fV", icon.bat_voltage[6] ); // Text 6x7; Spannung Spalte 2
130  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_3 + 15, BETRIEB_BATZEILE_3 + 17, &basic_6x7,
131  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
132 
133  // Batteriereihe 4, 40px hoch
134  gfx_draw_string_aligned ( "4", BETRIEB_SPALTE_1, BETRIEB_BATZEILE_4 + 12, &big_font_16x16,
135  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 190 + (40-16)/2 = 202
136 
137  gfx_draw_battery ( BETRIEB_SPALTE_2 - 7, BETRIEB_BATZEILE_4 + 7, icon.battery_color[3], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 197
138  gfx_draw_battery ( BETRIEB_SPALTE_3 - 7, BETRIEB_BATZEILE_4 + 7, icon.battery_color[7], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 197
139 
140  sprintf ( text, "%5.2fV", icon.bat_voltage[3] ); // Text 6x7; Spannung Spalte 1
141  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_2 + 15, BETRIEB_BATZEILE_4 + 17, &basic_6x7,
142  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
143 
144  sprintf ( text, "%5.2fV", icon.bat_voltage[7] ); // Text 6x7; Spannung Spalte 2
145  gfx_draw_string_aligned ( text, BETRIEB_SPALTE_3 + 15, BETRIEB_BATZEILE_4 + 17, &basic_6x7,
146  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
147 
148  // Ventilatorzeile, 40px hoch
149  if ( icon.vent1 )
150  gfx_draw_bitmap( &ico_vent_an, BETRIEB_SPALTE_2-ico_vent_an.width/2, BETRIEB_VENTZEILE + (40-ico_vent_an.height)/2 );
151  else
152  gfx_draw_bitmap( &ico_vent_aus, BETRIEB_SPALTE_2-ico_vent_aus.width/2, BETRIEB_VENTZEILE + (40-ico_vent_aus.height)/2 );
153 
154  if ( icon.vent2 )
155  gfx_draw_bitmap( &ico_vent_an, BETRIEB_SPALTE_3-ico_vent_an.width/2, BETRIEB_VENTZEILE + (40-ico_vent_an.height)/2 );
156  else
157  gfx_draw_bitmap( &ico_vent_aus, BETRIEB_SPALTE_3-ico_vent_aus.width/2, BETRIEB_VENTZEILE + (40-ico_vent_aus.height)/2 );
158 
159  // Fußzeile, 50px hoch
160  sprintf ( text, "%5imA", icon.mAmp );
161  gfx_draw_current ( 5, BETRIEB_FUSSZEILE + (50 - ico_dreieck_gelb.height) / 2 );
162  gfx_draw_string_aligned ( text, 50, BETRIEB_FUSSZEILE + (50 - bpmono_10x16.height) / 2, &bpmono_10x16,
163  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
164 
165  sprintf ( text, "%4.2f V", icon.volt );
166  gfx_draw_voltage ( 120, BETRIEB_FUSSZEILE + (50 - ico_dreieck_gelb.height) / 2 );
167  gfx_draw_string_aligned ( text, 167, BETRIEB_FUSSZEILE + (50 - bpmono_10x16.height) / 2, &bpmono_10x16,
168  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
169 
170 // gfx_draw_time ( 230, BETRIEB_FUSSZEILE + (50 - 34) / 2 );
171 // gfx_draw_string_aligned ( "24,30 h", 2* ico_dreieck_gelb.width + 190, BETRIEB_FUSSZEILE + (50 - bpmono_10x16.height) / 2, &bpmono_10x16,
172 // GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT );
173 
174  // Wenn Notaus ausgelöst wurde wird eine Messagebox auf jedem Screen angezeigt, bis die Meldung mit einer Taste quittiert wurde.
175  if ( msgbox_notaus ) message_notaus ();
176 
177 }
178 
199 {
200  char text[9];
201 
202 // Bildschirm löschen
203  if ( !(screen_flag == SCREEN_FLAG_AKKU_INFO) )
204  {
205  gfx_draw_filled_rect( 0, 0, gfx_get_width (), gfx_get_height (), GFX_COLOR_WHITE );
206  }
207 
208  screen_flag = SCREEN_FLAG_AKKU_INFO;
209 
210 // Kopfzeile, 48px hoch
211  gfx_draw_bitmap( &ico_batman, 2, (46 - ico_batman.height) / 2 );
212 
213  gfx_draw_hor_battery ( 120 - 60 / 2, (46 - 30) / 2, icon.top_bat_color, icon.top_bat_cross );
214 
215  gfx_draw_string_aligned ( icon.name, 230, (AKKU_VENTZEILE - big_font_16x16.height) / 2, &big_font_16x16,
216  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_RIGHT, TEXT_ALIGN_LEFT );
217 
218 // Verbraucher und Ventilator, 43px
219  if ( icon.verbraucher )
220  gfx_draw_bitmap( &ico_verbraucher_an, AKKU_SPALTE_1 - ico_verbraucher_an.width / 2, AKKU_VENTZEILE + (42 - ico_verbraucher_an.height) / 2 );
221  else
222  gfx_draw_bitmap( &ico_verbraucher_aus, AKKU_SPALTE_1 - ico_verbraucher_aus.width / 2, AKKU_VENTZEILE + (42 - ico_verbraucher_aus.height) / 2 );
223 
224  if ( icon.vent )
225  gfx_draw_bitmap( &ico_vent_an, AKKU_SPALTE_2 + 30 - ico_vent_an.width/2, AKKU_VENTZEILE + (42 - ico_vent_an.height) / 2 );
226  else
227  gfx_draw_bitmap( &ico_vent_aus, AKKU_SPALTE_2 + 30 - ico_vent_aus.width/2, AKKU_VENTZEILE + (42 - ico_vent_aus.height) / 2 );
228 
229 // SOC, 40px hoch
230  sprintf ( text, " %3i%%", icon.soc );
231  gfx_draw_soc ( AKKU_SPALTE_1 - 60 / 2, AKKU_SOCZEILE + (40 - 30) / 2, icon.soc_color );
232  gfx_draw_string_aligned ( text, AKKU_SPALTE_2 - 20, AKKU_SOCZEILE + (40 - big_font_16x16.height) / 2, &big_font_16x16,
233  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
234 
235 // Temperatur, 50px hoch
236  sprintf ( text, " %2i'C", icon.temperatur );
237  gfx_draw_temperatur ( AKKU_SPALTE_1 - 24 / 2, AKKU_TEMPZEILE + (50 - 40) / 2, icon.temp_color );
238  gfx_draw_string_aligned ( text, AKKU_SPALTE_2 - 20, AKKU_TEMPZEILE + (50 - big_font_16x16.height) / 2, &big_font_16x16,
239  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
240 
241 // Strom, 45px hoch
242  sprintf ( text, "%5imA", icon.mAmp );
243  gfx_draw_current ( AKKU_SPALTE_1 - ico_dreieck_gelb.width / 2, AKKU_STROMZEILE + (45 - ico_dreieck_gelb.height) / 2 );
244  gfx_draw_string_aligned ( text, AKKU_SPALTE_2 - 20, AKKU_STROMZEILE + (45 - big_font_16x16.height) / 2, &big_font_16x16,
245  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
246 
247 // Spannung, 45px hoch
248  sprintf ( text, " %4.2fV", icon.volt );
249  gfx_draw_voltage ( AKKU_SPALTE_1 - ico_dreieck_gelb.width / 2, AKKU_VOLTZEILE + (45 - ico_dreieck_gelb.height) / 2 );
250  gfx_draw_string_aligned ( text, AKKU_SPALTE_2 - 20, AKKU_VOLTZEILE + (45 - big_font_16x16.height) / 2, &big_font_16x16,
251  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
252 
253 // SOH, 53px hoch
254  sprintf ( text, " %3i%%", icon.soh );
255  gfx_draw_soh ( AKKU_SPALTE_1 - 26 / 2, AKKU_SOHZEILE + (53 - 52) / 2 );
256  gfx_draw_string_aligned ( text, AKKU_SPALTE_2 - 20, AKKU_SOHZEILE + (53 - big_font_16x16.height) / 2, &big_font_16x16,
257  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
258 
259  // Wenn Notaus ausgelöst wurde wird eine Messagebox auf jedem Screen angezeigt, bis die Meldung mit einer Taste quittiert wurde.
260  if ( msgbox_notaus ) message_notaus ();
261 
262 }
263 
285 {
286  char text[9];
287 
288  // Bildschirm löschen
289  if ( !(screen_flag == SCREEN_FLAG_LADEN) )
290  {
291  gfx_draw_filled_rect( 0, 0, gfx_get_width (), gfx_get_height (), GFX_COLOR_WHITE );
292  }
293 
294  screen_flag = SCREEN_FLAG_LADEN;
295 
296  // Kopfzeile, 50px hoch
297  gfx_draw_bitmap( &ico_batman, 2, (50 - ico_batman.height) / 2 );
298 
299  gfx_draw_soc ( 120 - 60 / 2, (50 - 30) / 2, icon.soc_color );
300 
301  // Säulenüberschrift, 20px hoch
302  gfx_draw_string_aligned ( "Saule 1", LADEN_SPALTE_2, LADEN_TEXTZEILE + (20 - bpmono_10x16.height) / 2, &bpmono_10x16,
304  gfx_draw_string_aligned ( "Saule 2", LADEN_SPALTE_3, LADEN_TEXTZEILE + (20 - bpmono_10x16.height) / 2, &bpmono_10x16,
306 
307  // Batteriereihe 1, 40px hoch
308  gfx_draw_string_aligned ( "1", LADEN_SPALTE_1, LADEN_BATZEILE_1 + 12, &big_font_16x16,
309  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 70 + (40-16)/2 = 82
310 
311  gfx_draw_battery ( LADEN_SPALTE_2 - 7, LADEN_BATZEILE_1 + 7, icon.battery_color[0], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 77
312  gfx_draw_battery ( LADEN_SPALTE_3 - 7, LADEN_BATZEILE_1 + 7, icon.battery_color[4], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 77
313 
314  sprintf ( text, "%5imA", icon.mAmp[0] ); // Text 6x7; Stromstärke Spalte 1
315  gfx_draw_string_aligned ( text, LADEN_SPALTE_2 + 15, LADEN_BATZEILE_1 + 17, &basic_6x7,
316  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
317 
318  sprintf ( text, "%5imA", icon.mAmp[4] ); // Text 6x7; Stromstärke Spalte 2
319  gfx_draw_string_aligned ( text, LADEN_SPALTE_3 + 15, LADEN_BATZEILE_1 + 17, &basic_6x7,
320  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
321 
322  // Batteriereihe 2, 40px hoch
323  gfx_draw_string_aligned ( "2", LADEN_SPALTE_1, LADEN_BATZEILE_2 + 12, &big_font_16x16,
324  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 110 + (40-16)/2 = 122
325 
326  gfx_draw_battery ( LADEN_SPALTE_2 - 7, LADEN_BATZEILE_2 + 7, icon.battery_color[1], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 117
327  gfx_draw_battery ( LADEN_SPALTE_3 - 7, LADEN_BATZEILE_2 + 7, icon.battery_color[5], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 117
328 
329  sprintf ( text, "%5imA", icon.mAmp[1] ); // Text 6x7; Stromstärke Spalte 1
330  gfx_draw_string_aligned ( text, LADEN_SPALTE_2 + 15, LADEN_BATZEILE_2 + 17, &basic_6x7,
331  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
332 
333  sprintf ( text, "%5imA", icon.mAmp[5] ); // Text 6x7; Stromstärke Spalte 2
334  gfx_draw_string_aligned ( text, LADEN_SPALTE_3 + 15, LADEN_BATZEILE_2 + 17, &basic_6x7,
335  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
336 
337  // Batteriereihe 3, 40px hoch
338  gfx_draw_string_aligned ( "3", LADEN_SPALTE_1, LADEN_BATZEILE_3 + 12, &big_font_16x16,
339  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 150 + (40-16)/2 = 162
340 
341  gfx_draw_battery ( LADEN_SPALTE_2 - 7, LADEN_BATZEILE_3 + 7, icon.battery_color[2], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 157
342  gfx_draw_battery ( LADEN_SPALTE_3 - 7, LADEN_BATZEILE_3 + 7, icon.battery_color[6], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 157
343 
344  sprintf ( text, "%5imA", icon.mAmp[2] ); // Text 6x7; Stromstärke Spalte 1
345  gfx_draw_string_aligned ( text, LADEN_SPALTE_2 + 15, LADEN_BATZEILE_3 + 17, &basic_6x7,
346  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
347 
348  sprintf ( text, "%5imA", icon.mAmp[6] ); // Text 6x7; Stromstärke Spalte 2
349  gfx_draw_string_aligned ( text, LADEN_SPALTE_3 + 15, LADEN_BATZEILE_3 + 17, &basic_6x7,
350  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
351 
352  // Batteriereihe 4, 40px hoch
353  gfx_draw_string_aligned ( "4", LADEN_SPALTE_1, LADEN_BATZEILE_4 + 12, &big_font_16x16,
354  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_LEFT ); // Text 16x16; X-Pos. 30; YPos. 190 + (40-16)/2 = 202
355 
356  gfx_draw_battery ( LADEN_SPALTE_2 - 7, LADEN_BATZEILE_4 + 7, icon.battery_color[3], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 80 - 14/2 = 73; YPos. 70 + (40-27)/2 = 197
357  gfx_draw_battery ( LADEN_SPALTE_3 - 7, LADEN_BATZEILE_4 + 7, icon.battery_color[7], GFX_BAT_NO_CROSS ); // Batterie-Icon 14x27; X-Pos. 170 - 14/2 = 163; YPos. 70 + (40-27)/2 = 197
358 
359  sprintf ( text, "%5imA", icon.mAmp[3] ); // Text 6x7; Stromstärke Spalte 1
360  gfx_draw_string_aligned ( text, LADEN_SPALTE_2 + 15, LADEN_BATZEILE_4 + 17, &basic_6x7,
361  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
362 
363  sprintf ( text, "%5imA", icon.mAmp[7] ); // Text 6x7; Stromstärke Spalte 2
364  gfx_draw_string_aligned ( text, LADEN_SPALTE_3 + 15, LADEN_BATZEILE_4 + 17, &basic_6x7,
365  GFX_COLOR_WHITE, GFX_COLOR_BLACK, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
366 
367  // Ventilatorzeile, 40px hoch
368  if ( icon.vent1 )
369  gfx_draw_bitmap( &ico_vent_an, LADEN_SPALTE_2-ico_vent_an.width/2, LADEN_VENTZEILE + (40-ico_vent_an.height)/2 );
370  else
371  gfx_draw_bitmap( &ico_vent_aus, LADEN_SPALTE_2-ico_vent_aus.width/2, LADEN_VENTZEILE + (40-ico_vent_aus.height)/2 );
372 
373  if ( icon.vent2 )
374  gfx_draw_bitmap( &ico_vent_an, LADEN_SPALTE_3-ico_vent_an.width/2, LADEN_VENTZEILE + (40-ico_vent_an.height)/2 );
375  else
376  gfx_draw_bitmap( &ico_vent_aus, LADEN_SPALTE_3-ico_vent_aus.width/2, LADEN_VENTZEILE + (40-ico_vent_aus.height)/2 );
377 
378  // Wenn Notaus ausgelöst wurde wird eine Messagebox auf jedem Screen angezeigt, bis die Meldung mit einer Taste quittiert wurde.
379  if ( msgbox_notaus ) message_notaus ();
380 
381 }
382 
401 {
402  char text[9];
403  uint16_t color;
404 
405  screen_flag = SCREEN_FLAG_WARNUNG;
406 
407 // Bildschirm löschen
408  gfx_draw_filled_rect( 0, 0, gfx_get_width (), gfx_get_height (), GFX_COLOR_WHITE );
409 
410 // Kopfzeile, 50px hoch
411  gfx_draw_bitmap( &ico_batman, 2, (50 - ico_batman.height) / 2 );
412 
413  gfx_draw_warning ( 120 - 34 / 2, (50 - 34) / 2 ); // Warning Icon, 34x34
414 
415  gfx_draw_string_aligned ( icon.name, 230, (50 - big_font_16x16.height) / 2, &big_font_16x16,
416  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_RIGHT, TEXT_ALIGN_LEFT );
417 
418 // SOC, 60px hoch
419  if ( icon.soc )
420  {
421  sprintf ( text, "< Ckrit " );
422  color = GFX_COLOR_RED;
423  }
424  else
425  {
426  sprintf ( text, " OK " );
427  color = GFX_COLOR_GREEN;
428  }
429  gfx_draw_soc ( WARN_SPALTE_1 - 60 / 2, WARN_SOCZEILE + (60 - 30) / 2, icon.soc_color );
430  gfx_draw_string_aligned ( text, WARN_SPALTE_2, WARN_SOCZEILE + (60 - big_font_16x16.height) / 2, &big_font_16x16,
431  GFX_COLOR_WHITE, color, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
432 
433 // Temperatur, 70px hoch
434  if ( icon.temperatur == 2 )
435  {
436  sprintf ( text, "> Tkrit " );
437  color = GFX_COLOR_RED;
438  }
439  else if ( icon.temperatur == 1 )
440  {
441  sprintf ( text, "> Tupper" );
442  color = GFX_COLOR_BLACK;
443  }
444  else
445  {
446  sprintf ( text, " OK " );
447  color = GFX_COLOR_BLACK;
448  }
449  gfx_draw_temperatur ( WARN_SPALTE_1 - 24 / 2, WARN_TEMPZEILE + (70 - 45) / 2, icon.temp_color );
450  gfx_draw_string_aligned ( text, WARN_SPALTE_2, WARN_TEMPZEILE + (70 - big_font_16x16.height) / 2, &big_font_16x16,
451  GFX_COLOR_WHITE, color, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
452 
453 // Spannung, 60px hoch
454  if ( icon.volt )
455  {
456  sprintf ( text, "< Vmin " );
457  color = GFX_COLOR_RED;
458  }
459  else
460  {
461  sprintf ( text, " OK " );
462  color = GFX_COLOR_BLACK;
463  }
464  gfx_draw_voltage ( WARN_SPALTE_1 - ico_dreieck_gelb.width / 2, WARN_VOLTZEILE + (60 - ico_dreieck_gelb.height) / 2 );
465  gfx_draw_string_aligned ( text, WARN_SPALTE_2, WARN_VOLTZEILE + (60 - big_font_16x16.height) / 2, &big_font_16x16,
466  GFX_COLOR_WHITE, color, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
467 
468 // SOH, 60px hoch
469  if ( icon.soh )
470  {
471  sprintf ( text, "< Min " );
472  color = GFX_COLOR_RED;
473  }
474  else
475  {
476  sprintf ( text, " OK " );
477  color = GFX_COLOR_BLACK;
478  }
479  gfx_draw_soh ( WARN_SPALTE_1 - 26 / 2, WARN_SOHZEILE + (60 - 52) / 2 );
480  gfx_draw_string_aligned ( text, WARN_SPALTE_2, WARN_SOHZEILE + (60 - big_font_16x16.height) / 2, &big_font_16x16,
481  GFX_COLOR_WHITE, color, TEXT_POS_LEFT, TEXT_ALIGN_LEFT );
482 
483 // Warnhinweis, 40px hoch
484  gfx_draw_filled_rect( 0, WARN_HINWEIS, gfx_get_width (), gfx_get_height () - WARN_HINWEIS, GFX_COLOR_RED );
485 
486  gfx_draw_string_aligned ( "WARNUNG", 120, WARN_HINWEIS + (40 - big_font_16x16.height) / 2, &big_font_16x16,
488 
489  // Wenn Notaus ausgelöst wurde wird eine Messagebox auf jedem Screen angezeigt, bis die Meldung mit einer Taste quittiert wurde.
490  if ( msgbox_notaus ) message_notaus ();
491 
492 }
493 
507 void screen_home ( void )
508 {
509  screen_flag = SCREEN_FLAG_HOME;
510  if ( PORTD_IN & LADE_POWER_IN_INT_bm )
511  laden = true;
512  else
513  laden = false;
514  // Bildschirm löschen
515  gfx_draw_filled_rect( 0, 0, gfx_get_width (), gfx_get_height (), GFX_COLOR_DK_BLUE );
516  gfx_draw_filled_rect( 0, 0, gfx_get_width (), 42, GFX_COLOR_WHITE );
517 
518  // Kopfzeile, 48px hoch
519  gfx_draw_bitmap( &ico_batman, 2, (46 - ico_batman.height) / 2 );
520 
521  gfx_draw_string_aligned ( "BATMAN", 120, 13, &big_font_16x16,
522  GFX_COLOR_TRANSPARENT, GFX_COLOR_BLACK, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER );
523 
524  gfx_draw_filled_rect( 45, 100, 150, 26, GFX_COLOR_YELLOW );
525  gfx_draw_string_aligned ( "LEERLAUF", 120, 105, &big_font_16x16,
526  GFX_COLOR_YELLOW, GFX_COLOR_DK_BLUE, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER );
527 
528  gfx_draw_filled_rect( 45, 150, 150, 26, GFX_COLOR_YELLOW );
529  gfx_draw_string_aligned ( "BETRIEB", 120, 155, &big_font_16x16,
530  GFX_COLOR_YELLOW, GFX_COLOR_DK_BLUE, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER );
531 
532  if ( laden )
533  {
534  gfx_draw_filled_rect( 45, 200, 150, 26, GFX_COLOR_YELLOW );
535  gfx_draw_string_aligned ( "LADEN", 120, 205, &big_font_16x16,
536  GFX_COLOR_YELLOW, GFX_COLOR_DK_BLUE, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER );
537  }
538 
539 // Warnhinweis, 40px hoch
540  gfx_draw_filled_rect( 0, WARN_HINWEIS, gfx_get_width (), gfx_get_height () - WARN_HINWEIS, GFX_COLOR_WHITE );
541 
542  gfx_draw_string_aligned ( "HOME", 120, WARN_HINWEIS + (40 - big_font_16x16.height) / 2, &big_font_16x16,
544 
545  // Wenn Notaus ausgelöst wurde wird eine Messagebox auf jedem Screen angezeigt, bis die Meldung mit einer Taste quittiert wurde.
546  if ( msgbox_notaus ) message_notaus ();
547 
548 }
549 
557 void message_notaus ( void )
558 {
559  gfx_draw_filled_rect( 20, 130, 201, 61, GFX_COLOR_RED );
560  gfx_draw_rect( 23, 133, 195, 55, GFX_COLOR_WHITE );
561  gfx_draw_rect( 24, 134, 193, 53, GFX_COLOR_WHITE );
562 
563  gfx_draw_string_aligned ( "N O T A U S", 120, 152, &big_font_16x16,
564  GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, TEXT_POS_CENTER_X, TEXT_ALIGN_CENTER );
565 }
566 
570 void screen_init ( void )
571 {
572  auswahl_nr = -1;
573 
574  auswahl_batterie[0].x = BETRIEB_SPALTE_2 - 17;
575  auswahl_batterie[0].y = BETRIEB_BATZEILE_1 + 20;
576 
577  auswahl_batterie[1].x = BETRIEB_SPALTE_2 - 17;
578  auswahl_batterie[1].y = BETRIEB_BATZEILE_2 + 20;
579 
580  auswahl_batterie[2].x = BETRIEB_SPALTE_2 - 17;
581  auswahl_batterie[2].y = BETRIEB_BATZEILE_3 + 20;
582 
583  auswahl_batterie[3].x = BETRIEB_SPALTE_2 - 17;
584  auswahl_batterie[3].y = BETRIEB_BATZEILE_4 + 20;
585 
586  auswahl_batterie[4].x = BETRIEB_SPALTE_3 - 17;
587  auswahl_batterie[4].y = BETRIEB_BATZEILE_1 + 20;
588 
589  auswahl_batterie[5].x = BETRIEB_SPALTE_3 - 17;
590  auswahl_batterie[5].y = BETRIEB_BATZEILE_2 + 20;
591 
592  auswahl_batterie[6].x = BETRIEB_SPALTE_3 - 17;
593  auswahl_batterie[6].y = BETRIEB_BATZEILE_3 + 20;
594 
595  auswahl_batterie[7].x = BETRIEB_SPALTE_3 - 17;
596  auswahl_batterie[7].y = BETRIEB_BATZEILE_4 + 20;
597 
598 }
599 
void gfx_draw_soh(uint16_t x, uint16_t y)
Zeichnet das SOH-Symbol.
Definition: lib_gfx_bms.c:106
void gfx_draw_voltage(uint16_t x, uint16_t y)
Zeichnet ein gelbes Warndreieck mit einem Blitz.
Definition: lib_gfx_bms.c:329
uint8_t height
Definition: gfx_text.h:127
void gfx_draw_warning(uint16_t x, uint16_t y)
Zeichnet ein Ausrufezeichen als Warnungssymbol.
Definition: lib_gfx_bms.c:219
struct font basic_6x7
Initialise font BPMONO 10x14.
Definition: sysfont.c:374
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
Variablentyp zur Darstellung des Laden-Screen.
Definition: screens_gfx.h:144
struct font big_font_16x16
Initialise font BPMONO 10x16.
Definition: sysfont.c:910
void screen_akku_warnung(scr_warning_t icon)
Der Warnung-Screen.
Definition: screens_gfx.c:400
bool verbraucher
Verbraucher ein- oder ausgeschaltet.
Definition: screens_gfx.h:105
#define GFX_COLOR_TRANSPARENT
Value used as input to font functions to give a transparent background region.
Definition: gfx_ili9341.h:73
void screen_akku_info(scr_info_t icon)
Der Infoscreen.
Definition: screens_gfx.c:198
void gfx_draw_current(uint16_t x, uint16_t y)
Zeichnet ein gelbes Warndreieck mit einem Stecker.
Definition: lib_gfx_bms.c:294
void screen_laden(scr_laden_t icon)
Der Ladescreen.
Definition: screens_gfx.c:284
void screen_betrieb(scr_betrieb_t icon)
Der Standard Betriebsscreen.
Definition: screens_gfx.c:55
void screen_init(void)
Koordinaten für die Markierung ausgewählter Zeilen wird initialisiert.
Definition: screens_gfx.c:570
#define gfx_draw_rect(x, y, width, height, color)
Definition: gfx_ili9341.h:171
Standard Header Datei, Definition der Batteriekonstanten und Grenzwerte.
void message_notaus(void)
Messagebox mit Text NOTAUS.
Definition: screens_gfx.c:557
gfx_coord_t height
Definition: gfx_generic.h:87
Variablentyp zur Darstellung des Info-Screen.
Definition: screens_gfx.h:121
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
void screen_home(void)
Der Home-Screen.
Definition: screens_gfx.c:507
Variablentyp zur Darstellung des Betriebs-Screen.
Definition: screens_gfx.h:103
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
struct font bpmono_10x16
Initialise font BPMONO 10x16.
Definition: sysfont.c:255
#define gfx_draw_filled_rect(x, y, width, height, color)
Definition: gfx_ili9341.h:178
gfx_coord_t width
Definition: gfx_generic.h:85
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
Standardheader und Positionen der Zeilen und Spalten auf den jeweiligen Screens.
Variablentyp zur Darstellung des Warnung-Screen.
Definition: screens_gfx.h:159
void gfx_draw_string_aligned(const char *str, gfx_coord_t x, gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color, enum gfx_text_position text_pos, enum gfx_text_alignment text_align)
Draws an aligned string to the display.
Definition: gfx_text.c:295
#define gfx_draw_bitmap(bmp, x, y)
Definition: gfx_ili9341.h:232