Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1515 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
||
5 | * Copyright (C) 2011 Harald Bongartz * |
||
6 | * * |
||
7 | * This program is free software; you can redistribute it and/or modify * |
||
8 | * it under the terms of the GNU General Public License as published by * |
||
9 | * the Free Software Foundation; either version 2 of the License. * |
||
10 | * * |
||
11 | * This program is distributed in the hope that it will be useful, * |
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
14 | * GNU General Public License for more details. * |
||
15 | * * |
||
16 | * You should have received a copy of the GNU General Public License * |
||
17 | * along with this program; if not, write to the * |
||
18 | * Free Software Foundation, Inc., * |
||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
20 | * * |
||
21 | * * |
||
22 | * Credits to: * |
||
23 | * Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
||
24 | * http://www.mikrokopter.de * |
||
25 | * Gregor "killagreg" Stobrawa for his version of the MK code * |
||
26 | * Thomas Kaiser "thkais" for the original project. See * |
||
27 | * http://www.ft-fanpage.de/mikrokopter/ * |
||
28 | * http://forum.mikrokopter.de/topic-4061-1.html * |
||
29 | * Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
||
30 | * http://www.mylifesucks.de/oss/c-osd/ * |
||
31 | * Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
||
32 | *****************************************************************************/ |
||
33 | |||
34 | |||
35 | #include "cpu.h" |
||
36 | #include <avr/io.h> |
||
37 | #include <avr/interrupt.h> |
||
38 | #include <avr/pgmspace.h> |
||
39 | #include <string.h> |
||
40 | #include <util/delay.h> |
||
41 | #include "main.h" |
||
42 | #include "setup.h" |
||
43 | #include "lcd.h" |
||
44 | #include "eeprom.h" |
||
45 | #include "timer.h" |
||
46 | #include "menu.h" |
||
47 | #include "Wi232.h" |
||
48 | #include "bluetooth.h" |
||
49 | #include "connect.h" |
||
50 | #include "lipo.h" |
||
51 | #include "messages.h" |
||
52 | #include "eeprom.h" |
||
53 | |||
54 | |||
55 | uint8_t spalte; |
||
56 | uint8_t mmode; |
||
57 | uint8_t edit; |
||
58 | uint8_t LCD_Orientation; |
||
59 | uint8_t edit = 0; |
||
60 | uint8_t LCD_Change = 0; |
||
61 | uint8_t PKT_Change = 0; |
||
62 | uint8_t Pre; |
||
63 | uint16_t Pre16; |
||
64 | char EditString[21]; |
||
65 | uint8_t bt_name_len; |
||
66 | |||
67 | |||
68 | //-------------------------------------------------------------- |
||
69 | #define ITEMS_PKT 9 |
||
70 | |||
71 | prog_char param_menuitems_pkt[ITEMS_PKT][NUM_LANG][18]= // zeilen,zeichen+1 |
||
72 | // German, English, French, Dutch |
||
73 | { |
||
74 | {"Verbindung zum MK","connection to MK "," connexion a MK " ,"Aansluiting op MK"}, |
||
75 | {"MK LowBat Warnung","MK LowBat warning","MK LowBat Attent", "MK LoBat alarm "}, |
||
76 | {"Anzeige \x1d","Display \x1d","d'affichage \x1d","Display \x1d"}, |
||
77 | {"Wi.232 \x1d","Wi.232 \x1d","Wi.232 \x1d","Wi.232 \x1d"}, |
||
78 | {"BTM-222 \x1d","BTM-222 \x1d","BTM-222 \x1d","BTM-222 \x1d"}, |
||
79 | {"PKT-Akku \x1d","PKT-Accu \x1d","PKT-Accu \x1d","PKT-Accu \x1d"}, |
||
80 | {"PKT Update ","PKT Update ","PKT Mise a jour ","PKT Update "}, |
||
81 | {"Debug PKT ","Debug PKT ","Debug PKT ","Debug PKT "}, |
||
82 | {"EEProm Reset ","EEProm Reset ","EEProm Reinitiali","EEProm Reset "}, |
||
83 | }; |
||
84 | |||
85 | #define ITEMS_LCD 7 |
||
86 | |||
87 | prog_char param_menuitems_lcd[ITEMS_LCD][NUM_LANG][18]= // zeilen,zeichen+1 |
||
88 | // German, English, French, Dutch |
||
89 | { |
||
90 | {"Infos beim Start ","info at startup ","Infor. sur lancer","info bij opstart "}, |
||
91 | {"Sprache ","language ","Langue ","taal "}, |
||
92 | {"Licht aus nach...","light off after ","Lumiere au bout ","licht uit na "}, |
||
93 | {"Helligkeit ","brightness ","luminosite ","helderheid "}, |
||
94 | {"Kontrast ","contrast ","contraste ","contrast "}, |
||
95 | {"Normal/Invers ","normal/inverted ","Normal / inverse ","Normal/inverted "}, |
||
96 | {"Orientierung ","orientation ","orientation ","orientatie "}, |
||
97 | |||
98 | }; |
||
99 | |||
100 | #define ITEMS_WI 8 |
||
101 | |||
102 | prog_char param_menuitems_wi[ITEMS_WI][NUM_LANG][18]= // zeilen,zeichen+1 |
||
103 | // German, English, French, Dutch |
||
104 | { |
||
105 | {"Modul eingebaut? ","module built in? ","Module installé ","Module geinstal.?"}, |
||
106 | {"TX/RX Kanal ","TX/RX Channel ","TX/RX Channel ","TX/RX Channel "}, |
||
107 | {"NetW. Gruppe ","NetW. Group ","NetW. Group ","NetW. Group "}, |
||
108 | {"NetW. Mode ","NetW. Mode ","NetW. Mode ","NetW. Mode "}, |
||
109 | {"TX Timeout ","TX Timeout ","TX Timeout ","TX Timeout "}, |
||
110 | {"TX MTU ","TX MTU ","TX MTU ","TX MTU "}, |
||
111 | {"Initialisieren ","initialize ","initialiser ","Initialize "}, |
||
112 | {"Konfig. mit PC ","config. with PC ","Config. avec PC ","Config. met PC "}, |
||
113 | }; |
||
114 | |||
115 | |||
116 | #define ITEMS_BT 5 |
||
117 | |||
118 | prog_char param_menuitems_bt[ITEMS_BT][NUM_LANG][18]= // zeilen,zeichen+1 |
||
119 | // German, English, French, Dutch |
||
120 | { |
||
121 | {"Modul eingebaut? ","module built in? ","Module installé ","module geïnstall?"}, |
||
122 | {"Name ","name ","Nom ","Naam "}, |
||
123 | {"Pin ","pin ","Pin ","Pin "}, |
||
124 | {"Initialisieren ","initialize ","initialiser ","Initialize "}, |
||
125 | {"Konfig. mit PC ","config. with PC ","Config. avec PC ","Config. met PC "}, |
||
126 | }; |
||
127 | |||
128 | #define ITEMS_Accu 2 |
||
129 | |||
130 | prog_char param_menuitems_Accu[ITEMS_Accu][NUM_LANG][18]= // zeilen,zeichen+1 |
||
131 | // German, English, French, Dutch |
||
132 | { |
||
133 | {"PKT-Akkutyp ","PKT-Accutyp ","PKT-Type de batt.","PKT-batterij type"}, |
||
134 | {"PKT Akku Messung ","PKT AccuMeasure ","batt. de mesure ","PKT batt. meting "}, |
||
135 | }; |
||
136 | |||
137 | //-------------------------------------------------------------- |
||
138 | void Show_Error_HW12(void) |
||
139 | { |
||
140 | lcd_cls(); |
||
141 | lcd_printp_at (0,3,PSTR(" Mit Hardware 1.x "), 2); |
||
142 | lcd_printp_at (0,4,PSTR(" nicht möglich "), 2); |
||
143 | _delay_ms(1000); |
||
144 | |||
145 | } |
||
146 | |||
147 | |||
148 | //-------------------------------------------------------------- |
||
149 | uint8_t Edit_Int10th_Value(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
150 | { |
||
151 | Pre = Value; |
||
152 | lcd_cls(); |
||
153 | // lcd_printp_at (0, 2, Text, 0); |
||
154 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
155 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
156 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
157 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
158 | |||
159 | do |
||
160 | { |
||
161 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (Value < max)) |
||
162 | { |
||
163 | edit = 1; |
||
164 | Value++; |
||
165 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
166 | } |
||
167 | |||
168 | if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Value > min)) |
||
169 | { |
||
170 | edit = 1; |
||
171 | Value--; |
||
172 | write_ndigit_number_u_10th (16, 2,Value, 3, 0); |
||
173 | } |
||
174 | |||
175 | if (get_key_press (1 << KEY_ENTER)) |
||
176 | return Value; |
||
177 | |||
178 | } |
||
179 | while (!get_key_press (1 << KEY_ESC)); |
||
180 | { |
||
181 | get_key_press(KEY_ALL); |
||
182 | edit = 0; |
||
183 | return Pre; |
||
184 | } |
||
185 | } |
||
186 | |||
187 | |||
188 | //-------------------------------------------------------------- |
||
189 | uint8_t Edit_Int_Value(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
190 | { |
||
191 | lcd_cls(); |
||
192 | // lcd_printp_at (0, 2, Text, 0); |
||
193 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
194 | Pre = Value; |
||
195 | write_ndigit_number_u (16, 2, Value, 3, 0); |
||
196 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
197 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
198 | |||
199 | do |
||
200 | { |
||
201 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && (Value < max)) |
||
202 | { |
||
203 | edit = 1; |
||
204 | Value++; |
||
205 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
206 | } |
||
207 | |||
208 | if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && (Value > min)) |
||
209 | { |
||
210 | edit = 1; |
||
211 | Value--; |
||
212 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
213 | } |
||
214 | |||
215 | if (get_key_press (1 << KEY_ENTER)) |
||
216 | return Value; |
||
217 | |||
218 | } |
||
219 | while (!get_key_press (1 << KEY_ESC)); |
||
220 | { |
||
221 | get_key_press(KEY_ALL); |
||
222 | edit = 0; |
||
223 | return Pre; |
||
224 | } |
||
225 | } |
||
226 | #if defined HWVERSION3_9 ||HWVERSION1_3W |
||
227 | //-------------------------------------------------------------- |
||
228 | uint8_t ChangeWi_SV2(uint8_t Value) |
||
229 | { |
||
230 | Pre = Value; |
||
231 | lcd_cls(); |
||
232 | // lcd_printp_at (0, 1, PSTR("Verbinde das PKT mit"), 0); |
||
233 | // lcd_printp_at (0, 2, PSTR("dem MK über:"), 0); |
||
234 | lcd_puts_at(0, 1, strGet(CONNECT1), 0); |
||
235 | lcd_puts_at(0, 2, strGet(CONNECT2), 0); |
||
236 | |||
237 | if(UseWi == false) |
||
238 | { |
||
239 | // lcd_printp_at (0, 0, PSTR("Verbinde das PKT mit "), 0); |
||
240 | // lcd_printp_at (0, 1, PSTR("dem MK über: Kabel, "), 0); |
||
241 | // lcd_printp_at (0, 2, PSTR("da kein Wi.232 Modul "), 0); |
||
242 | // lcd_printp_at (0, 3, PSTR("eingebaut ist. "), 0); |
||
243 | // lcd_printp_at (0, 4, PSTR("Wenn doch, dann bitte"), 0); |
||
244 | // lcd_printp_at (0, 5, PSTR("das Modul zuerst im "), 0); |
||
245 | // lcd_printp_at (0, 6, PSTR("Setupmenü aktivieren."), 0); |
||
246 | lcd_puts_at(0, 1, strGet(CONNECT1), 0); |
||
247 | lcd_puts_at(0, 2, strGet(CONNECT4), 0); |
||
248 | lcd_puts_at(0, 1, strGet(CONNECT5), 0); |
||
249 | lcd_puts_at(0, 2, strGet(CONNECT6), 0); |
||
250 | lcd_puts_at(0, 1, strGet(CONNECT7), 0); |
||
251 | lcd_puts_at(0, 2, strGet(CONNECT8), 0); |
||
252 | lcd_puts_at(0, 1, strGet(CONNECT9), 0); |
||
253 | |||
254 | |||
255 | // lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
256 | lcd_puts_at(12, 7, strGet(ENDE), 0); |
||
257 | while (!get_key_press (1 << KEY_ESC)); |
||
258 | get_key_press(KEY_ALL); |
||
259 | edit = 0; |
||
260 | return Pre; |
||
261 | } |
||
262 | else |
||
263 | { |
||
264 | switch (Value) |
||
265 | { |
||
266 | case 0x0 :lcd_printp_at (14, 2, PSTR("Wi232"), 0); |
||
267 | break; |
||
268 | case 0x1 : lcd_puts_at(14, 2, strGet(KABEL), 0); |
||
269 | |||
270 | //lcd_printp_at (14, 2, PSTR("Kabel"), 0); |
||
271 | |||
272 | break; |
||
273 | break; |
||
274 | } |
||
275 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
276 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
277 | |||
278 | do |
||
279 | { |
||
280 | if(UseWi == true) |
||
281 | { |
||
282 | if ((get_key_press (1 << KEY_PLUS)) && (Value == 0)) |
||
283 | { |
||
284 | edit = 1; |
||
285 | Value = 1; |
||
286 | // lcd_printp_at (14, 2, PSTR("Kabel"), 0); |
||
287 | lcd_puts_at(14, 2, strGet(KABEL), 0); |
||
288 | Change_Output(Uart02FC); |
||
289 | } |
||
290 | |||
291 | if ((get_key_press (1 << KEY_MINUS)) && (Value == 1)) |
||
292 | { |
||
293 | edit = 1; |
||
294 | Value = 0; |
||
295 | lcd_printp_at (14, 2, PSTR("Wi232"), 0); |
||
296 | Change_Output(Uart02Wi); |
||
297 | } |
||
298 | |||
299 | if (get_key_press (1 << KEY_ENTER)) |
||
300 | { |
||
301 | // lcd_printp_at (0, 4, PSTR("Sie müssen das PKT"), 0); |
||
302 | // lcd_printp_at (0, 5, PSTR("jetzt neu starten!"), 0); |
||
303 | lcd_puts_at(0, 4, strGet(CONNECT10), 0); |
||
304 | lcd_puts_at(0, 5, strGet(CONNECT11), 0); |
||
305 | lcd_cls_line (0, 7, 18); |
||
306 | while (!get_key_press (1 << KEY_ENTER)); |
||
307 | return Value; |
||
308 | } |
||
309 | } |
||
310 | } |
||
311 | while (!get_key_press (1 << KEY_ESC)); |
||
312 | } |
||
313 | get_key_press(KEY_ALL); |
||
314 | edit = 0; |
||
315 | return Pre; |
||
316 | } |
||
317 | |||
318 | #endif |
||
319 | //-------------------------------------------------------------- |
||
320 | uint8_t Edit_Wi_NetMode_Value(uint8_t Value) |
||
321 | { |
||
322 | Pre = Value; |
||
323 | lcd_cls(); |
||
324 | // lcd_printp_at (0, 2, PSTR("Wi NetW. Mode:"), 0); |
||
325 | lcd_puts_at(0, 2, strGet(WINETWM), 0); |
||
326 | |||
327 | switch (Value) |
||
328 | { |
||
329 | case 0x0 :lcd_puts_at(15, 2, strGet(SLAVE), 0);//lcd_printp_at (15, 2, PSTR("Slave "), 0); |
||
330 | break; |
||
331 | case 0x1 :lcd_puts_at(15, 2, strGet(NORMAL), 0);//lcd_printp_at (15, 2, PSTR("Normal"), 0); |
||
332 | break; |
||
333 | break; |
||
334 | } |
||
335 | |||
336 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
337 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
338 | |||
339 | do |
||
340 | { |
||
341 | if ((get_key_press (1 << KEY_PLUS)) && (Value == 0)) |
||
342 | { |
||
343 | edit = 1; |
||
344 | Value = NetMode_Normal; |
||
345 | // lcd_printp_at (15, 2, PSTR("Normal"), 0); |
||
346 | lcd_puts_at(15, 2, strGet(NORMAL), 0); |
||
347 | |||
348 | } |
||
349 | |||
350 | if ((get_key_press (1 << KEY_MINUS)) && (Value == 1)) |
||
351 | { |
||
352 | edit = 1; |
||
353 | Value = NetMode_Slave; |
||
354 | // lcd_printp_at (15, 2, PSTR("Slave "), 0); |
||
355 | lcd_puts_at(15, 2, strGet(SLAVE), 0); |
||
356 | } |
||
357 | |||
358 | if (get_key_press (1 << KEY_ENTER)) |
||
359 | return Value; |
||
360 | |||
361 | } |
||
362 | while (!get_key_press (1 << KEY_ESC)); |
||
363 | { |
||
364 | get_key_press(KEY_ALL); |
||
365 | edit = 0; |
||
366 | return Pre; |
||
367 | } |
||
368 | } |
||
369 | |||
370 | |||
371 | //-------------------------------------------------------------- |
||
372 | uint8_t Edit_StartInfo(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
373 | |||
374 | { |
||
375 | Pre = Value; |
||
376 | lcd_cls(); |
||
377 | // lcd_printp_at (0, 2,Text, 0); |
||
378 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
379 | |||
380 | switch (Value) |
||
381 | { |
||
382 | case false :lcd_puts_at(17, 2, strGet(OFF), 0);//lcd_printp_at (17, 2, PSTR("Aus"), 0); |
||
383 | break; |
||
384 | case true :lcd_puts_at(17, 2, strGet(ON), 0);//cd_printp_at (17, 2, PSTR("Ein"), 0); |
||
385 | break; |
||
386 | break; |
||
387 | } |
||
388 | |||
389 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
390 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
391 | |||
392 | do |
||
393 | { |
||
394 | if ((get_key_press (1 << KEY_PLUS)) && (Value == 0)) |
||
395 | { |
||
396 | Value = 1; |
||
397 | // lcd_printp_at (17, 2, PSTR("Ein"), 0); |
||
398 | lcd_puts_at(17, 2, strGet(ON), 0); |
||
399 | } |
||
400 | |||
401 | if ((get_key_press (1 << KEY_MINUS)) && (Value == 1)) |
||
402 | { |
||
403 | Value = 0; |
||
404 | // lcd_printp_at (17, 2, PSTR("Aus"), 0); |
||
405 | lcd_puts_at(17, 2, strGet(OFF), 0); |
||
406 | } |
||
407 | |||
408 | if (get_key_press (1 << KEY_ENTER)) |
||
409 | { |
||
410 | edit = 1; |
||
411 | |||
412 | PKT_StartInfo = Value; |
||
413 | WriteParameter(); |
||
414 | |||
415 | return Value; |
||
416 | } |
||
417 | } |
||
418 | |||
419 | while (!get_key_press (1 << KEY_ESC)); |
||
420 | { |
||
421 | get_key_press(KEY_ALL); |
||
422 | edit = 0; |
||
423 | PKT_StartInfo = Pre; |
||
424 | return Pre; |
||
425 | } |
||
426 | |||
427 | } |
||
428 | |||
429 | //-------------------------------------------------------------- |
||
430 | uint8_t Edit_YesNo(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
431 | |||
432 | { |
||
433 | Pre = Value; |
||
434 | lcd_cls(); |
||
435 | // lcd_printp_at (0, 2,Text, 0); |
||
436 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
437 | |||
438 | switch (Value) |
||
439 | { |
||
440 | case false :lcd_puts_at(17, 2, strGet(NOO), 0);//lcd_printp_at (17, 2, PSTR("Aus"), 0); |
||
441 | break; |
||
442 | case true :lcd_puts_at(17, 2, strGet(YES), 0);//cd_printp_at (17, 2, PSTR("Ein"), 0); |
||
443 | break; |
||
444 | break; |
||
445 | } |
||
446 | |||
447 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
448 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
449 | |||
450 | do |
||
451 | { |
||
452 | if ((get_key_press (1 << KEY_PLUS)) && (Value == 0)) |
||
453 | { |
||
454 | Value = 1; |
||
455 | // lcd_printp_at (17, 2, PSTR("Ein"), 0); |
||
456 | lcd_puts_at(17, 2, strGet(YES), 0); |
||
457 | } |
||
458 | |||
459 | if ((get_key_press (1 << KEY_MINUS)) && (Value == 1)) |
||
460 | { |
||
461 | Value = 0; |
||
462 | // lcd_printp_at (17, 2, PSTR("Aus"), 0); |
||
463 | lcd_puts_at(17, 2, strGet(NOO), 0); |
||
464 | } |
||
465 | |||
466 | if (get_key_press (1 << KEY_ENTER)) |
||
467 | { |
||
468 | edit = 1; |
||
469 | |||
470 | // PKT_StartInfo = Value; |
||
471 | // WriteParameter(); |
||
472 | |||
473 | return Value; |
||
474 | } |
||
475 | } |
||
476 | |||
477 | while (!get_key_press (1 << KEY_ESC)); |
||
478 | { |
||
479 | get_key_press(KEY_ALL); |
||
480 | edit = 0; |
||
481 | // PKT_StartInfo = Pre; |
||
482 | return Pre; |
||
483 | } |
||
484 | |||
485 | } |
||
486 | //-------------------------------------------------------------- |
||
487 | //uint8_t Edit_Language(uint8_t Value, uint8_t min, uint8_t max,const char *Text) |
||
488 | uint8_t Edit_Language(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
489 | { |
||
490 | Pre = Value; |
||
491 | lcd_cls(); |
||
492 | // lcd_printp_at (0, 2, Text, 0); |
||
493 | lcd_puts_at(0, 2,strGet(Text), 0); |
||
494 | switch (Value) |
||
495 | { |
||
496 | case |
||
497 | 0x0 : lcd_puts_at(10, 2, strGet(DEUTSCH), 0);//lcd_printp_at (14, 2, PSTR("Deutsch"), 0); |
||
498 | break; |
||
499 | case 0x1 : lcd_puts_at(10, 2, strGet(ENGLISCH), 0);//lcd_printp_at (14, 2, PSTR("English"), 0); |
||
500 | break; |
||
501 | case 0x2 : lcd_puts_at(10, 2, strGet(FRANCE), 0);//lcd_printp_at (14, 2, PSTR("France "), 0); |
||
502 | break; |
||
503 | case 0x3 : lcd_puts_at(10, 2, strGet(NETHERL), 0);//lcd_printp_at (14, 2, PSTR("Netherl"), 0); |
||
504 | break; |
||
505 | break; |
||
506 | } |
||
507 | |||
508 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
509 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
510 | |||
511 | do |
||
512 | { |
||
513 | if ((get_key_press (1 << KEY_PLUS)) && (Value < max)) |
||
514 | { |
||
515 | edit = 1; |
||
516 | Value++; |
||
517 | //DisplayLanguage = Value; |
||
518 | switch (Value) |
||
519 | { |
||
520 | case 0x0 : lcd_puts_at(10, 2, strGet(DEUTSCH), 0);//lcd_printp_at (14, 2, PSTR("Deutsch"), 0); |
||
521 | break; |
||
522 | case 0x1 : lcd_puts_at(10, 2, strGet(ENGLISCH), 0);//lcd_printp_at (14, 2, PSTR("English"), 0); |
||
523 | break; |
||
524 | case 0x2 : lcd_puts_at(10, 2, strGet(FRANCE), 0);//lcd_printp_at (14, 2, PSTR("France "), 0); |
||
525 | break; |
||
526 | case 0x3 : lcd_puts_at(10, 2, strGet(NETHERL), 0);//lcd_printp_at (14, 2, PSTR("Netherl"), 0); |
||
527 | break; |
||
528 | break; |
||
529 | } |
||
530 | } |
||
531 | |||
532 | if ((get_key_press (1 << KEY_MINUS)) && (Value > min)) |
||
533 | { |
||
534 | edit = 1; |
||
535 | Value--; |
||
536 | //DisplayLanguage = Value; |
||
537 | switch (Value) |
||
538 | { |
||
539 | case 0x0 : lcd_puts_at(10, 2, strGet(DEUTSCH), 0);//lcd_printp_at (14, 2, PSTR("Deutsch"), 0); |
||
540 | break; |
||
541 | case 0x1 : lcd_puts_at(10, 2, strGet(ENGLISCH), 0);//lcd_printp_at (14, 2, PSTR("English"), 0); |
||
542 | break; |
||
543 | case 0x2 : lcd_puts_at(10, 2, strGet(FRANCE), 0);//lcd_printp_at (14, 2, PSTR("France "), 0); |
||
544 | break; |
||
545 | case 0x3 : lcd_puts_at(10, 2, strGet(NETHERL), 0);//lcd_printp_at (14, 2, PSTR("Netherl"), 0); |
||
546 | break; |
||
547 | break; |
||
548 | } |
||
549 | } |
||
550 | |||
551 | if (get_key_press (1 << KEY_ENTER)) |
||
552 | return Value; |
||
553 | |||
554 | } |
||
555 | |||
556 | while (!get_key_press (1 << KEY_ESC)); |
||
557 | { |
||
558 | get_key_press(KEY_ALL); |
||
559 | edit = 0; |
||
560 | return Pre; |
||
561 | } |
||
562 | } |
||
563 | |||
564 | |||
565 | //-------------------------------------------------------------- |
||
566 | uint8_t Edit_Orientation(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
567 | { |
||
568 | Pre = Value; |
||
569 | lcd_cls(); |
||
570 | // lcd_printp_at (0, 2, Text, 0); |
||
571 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
572 | |||
573 | switch (Value) |
||
574 | { |
||
575 | case 0x0 :lcd_puts_at(14, 2, strGet(NORMAL), 0);//lcd_printp_at (14, 2, PSTR("Normal "), 0); |
||
576 | break; |
||
577 | case 0x4 :lcd_puts_at(14, 2, strGet(REVERSE), 0);//lcd_printp_at (14, 2, PSTR("Reverse"), 0); |
||
578 | break; |
||
579 | break; |
||
580 | } |
||
581 | |||
582 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
583 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
584 | |||
585 | do |
||
586 | { |
||
587 | if ((get_key_press (1 << KEY_PLUS)) && (Value == 0)) |
||
588 | { |
||
589 | Value=4; |
||
590 | // lcd_printp_at (14, 2, PSTR("Reverse"), 0); |
||
591 | lcd_puts_at(14, 2, strGet(REVERSE), 0); |
||
592 | } |
||
593 | |||
594 | if ((get_key_press (1 << KEY_MINUS)) && (Value == 4)) |
||
595 | { |
||
596 | Value = 0; |
||
597 | // lcd_printp_at (14, 2, PSTR("Normal "), 0); |
||
598 | lcd_puts_at(14, 2, strGet(NORMAL), 0); |
||
599 | } |
||
600 | |||
601 | if (get_key_press (1 << KEY_ENTER)) |
||
602 | { |
||
603 | edit = 1; |
||
604 | cli(); |
||
605 | clr_A0 (); |
||
606 | |||
607 | if (Value == 0) |
||
608 | { |
||
609 | send_byte (0xA1); // normal |
||
610 | send_byte (0xC0); // normal |
||
611 | } |
||
612 | else |
||
613 | { |
||
614 | send_byte (0xA0); // reverse |
||
615 | send_byte (0xC8); // reverse |
||
616 | } |
||
617 | set_A0 (); |
||
618 | sei(); |
||
619 | LCD_Orientation = Value; |
||
620 | WriteParameter(); |
||
621 | return Value; |
||
622 | } |
||
623 | } |
||
624 | |||
625 | while (!get_key_press (1 << KEY_ESC)); |
||
626 | { |
||
627 | get_key_press(KEY_ALL); |
||
628 | edit = 0; |
||
629 | return Pre; |
||
630 | } |
||
631 | } |
||
632 | |||
633 | |||
634 | //-------------------------------------------------------------- |
||
635 | uint8_t Edit_DisplayMode(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
636 | { |
||
637 | Pre = Value; |
||
638 | lcd_cls(); |
||
639 | //lcd_printp_at (0, 2, Text, 0); |
||
640 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
641 | |||
642 | switch (Value) |
||
643 | { |
||
644 | case 0x0 :lcd_puts_at(14, 2, strGet(NORMAL), 0);//lcd_printp_at (14, 2, PSTR("Normal "), 0); |
||
645 | break; |
||
646 | case 0x4 :lcd_puts_at(14, 2, strGet(REVERSE), 0);//lcd_printp_at (14, 2, PSTR("Reverse"), 0); |
||
647 | break; |
||
648 | break; |
||
649 | } |
||
650 | |||
651 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
652 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
653 | |||
654 | do |
||
655 | { |
||
656 | if ((get_key_press (1 << KEY_PLUS)) && (Value == 0)) |
||
657 | { |
||
658 | Value=4; |
||
659 | // lcd_printp_at (14, 2, PSTR("Inverse"), 0); |
||
660 | lcd_puts_at(14, 2, strGet(REVERSE), 0); |
||
661 | } |
||
662 | |||
663 | if ((get_key_press (1 << KEY_MINUS)) && (Value == 4)) |
||
664 | { |
||
665 | Value=0; |
||
666 | // lcd_printp_at (14, 2, PSTR("Normal "), 0); |
||
667 | lcd_puts_at(14, 2, strGet(NORMAL), 0); |
||
668 | } |
||
669 | |||
670 | if (get_key_press (1 << KEY_ENTER)) |
||
671 | { |
||
672 | edit = 1; |
||
673 | cli(); |
||
674 | clr_A0 (); |
||
675 | |||
676 | if (Value == 0) |
||
677 | send_byte (0xA6); // normal |
||
678 | else |
||
679 | send_byte (0xA7); // inverse |
||
680 | |||
681 | set_A0 (); |
||
682 | sei(); |
||
683 | LCD_DisplayMode = Value; |
||
684 | WriteParameter(); |
||
685 | |||
686 | return Value; |
||
687 | } |
||
688 | } |
||
689 | |||
690 | while (!get_key_press (1 << KEY_ESC)); |
||
691 | { |
||
692 | get_key_press(KEY_ALL); |
||
693 | edit = 0; |
||
694 | LCD_DisplayMode = Pre; |
||
695 | return Pre; |
||
696 | } |
||
697 | } |
||
698 | |||
699 | |||
700 | //-------------------------------------------------------------- |
||
701 | uint8_t Edit_DisplayKontrast(uint8_t Value, uint8_t min, uint8_t max,uint8_t Text) |
||
702 | { |
||
703 | Pre = Value; |
||
704 | lcd_cls(); |
||
705 | // lcd_printp_at (0, 2, Text, 0); |
||
706 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
707 | write_ndigit_number_u (16, 2, Value, 3, 0); |
||
708 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
709 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
710 | |||
711 | do |
||
712 | { |
||
713 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
714 | lcd_frect ((8*0), (8*4), (Value * (16*8) / 64), 6, 1); |
||
715 | |||
716 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && (Value < max)) |
||
717 | { |
||
718 | Value++; |
||
719 | |||
720 | if (Value >= max) |
||
721 | { |
||
722 | Value = max; |
||
723 | BeepTime = 200; |
||
724 | BeepMuster = 0x0080; |
||
725 | } |
||
726 | else |
||
727 | { |
||
728 | cli(); |
||
729 | clr_A0 (); |
||
730 | send_byte (0x81); |
||
731 | send_byte (Value); // Daten zum LCD senden |
||
732 | set_A0 (); |
||
733 | sei(); |
||
734 | } |
||
735 | } |
||
736 | |||
737 | if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && (Value > min)) |
||
738 | { |
||
739 | lcd_frect (((Value - 1) * (16*8) / 64), (8*4), (16*8), 6, 0); |
||
740 | Value--; |
||
741 | |||
742 | if (Value == min) |
||
743 | { |
||
744 | Value = min; |
||
745 | BeepTime = 200; |
||
746 | BeepMuster = 0x0080; |
||
747 | } |
||
748 | else |
||
749 | { |
||
750 | // edit = 1; |
||
751 | cli(); |
||
752 | clr_A0 (); |
||
753 | send_byte (0x81); |
||
754 | send_byte (Value); // Daten zum LCD senden |
||
755 | set_A0 (); |
||
756 | sei(); |
||
757 | } |
||
758 | } |
||
759 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
760 | |||
761 | if (get_key_press (1 << KEY_ENTER)) |
||
762 | { |
||
763 | edit = 1; |
||
764 | LCD_Kontrast = Value; |
||
765 | WriteParameter(); |
||
766 | return Value; |
||
767 | } |
||
768 | } |
||
769 | |||
770 | while (!get_key_press (1 << KEY_ESC)); |
||
771 | { |
||
772 | get_key_press(KEY_ALL); |
||
773 | cli(); |
||
774 | clr_A0 (); |
||
775 | send_byte (0x81); |
||
776 | send_byte (Pre); // Daten zum LCD senden |
||
777 | set_A0 (); |
||
778 | sei(); |
||
779 | edit = 0; |
||
780 | LCD_Kontrast = Pre; |
||
781 | WriteParameter(); |
||
782 | return Pre; |
||
783 | } |
||
784 | } |
||
785 | |||
786 | |||
787 | //-------------------------------------------------------------- |
||
788 | uint8_t Edit_DisplayHelligkeit(uint8_t Value, uint8_t min, uint8_t max, uint8_t Text) |
||
789 | { |
||
790 | float ValCorr = 2.55; // (Value * ValCorr) maximal 255 |
||
791 | Pre = Value; |
||
792 | OCR2A = Value * ValCorr; |
||
793 | |||
794 | lcd_cls(); |
||
795 | // lcd_printp_at (0, 2, Text, 0); |
||
796 | lcd_puts_at(0, 2, strGet(Text), 0); |
||
797 | write_ndigit_number_u (16, 2, Value, 3, 0); |
||
798 | lcd_printp_at (17, 2, PSTR("%"), 0); |
||
799 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
800 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
801 | |||
802 | do |
||
803 | { |
||
804 | write_ndigit_number_u (16, 2,Value, 3, 0); |
||
805 | lcd_frect ((8*0), (8*4), (Value * (16*8) / 100), 6, 1); |
||
806 | |||
807 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) && (Value < max)) |
||
808 | { |
||
809 | Value++; |
||
810 | |||
811 | if (Value >= max) |
||
812 | { |
||
813 | Value = max; |
||
814 | BeepTime = 200; |
||
815 | BeepMuster = 0x0080; |
||
816 | } |
||
817 | else |
||
818 | OCR2A = Value * ValCorr; |
||
819 | |||
820 | } |
||
821 | |||
822 | if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) && (Value > min)) |
||
823 | { |
||
824 | lcd_frect (((Value - 1) * (16*8) / 100), (8*4), (16*8), 6, 0); |
||
825 | Value--; |
||
826 | |||
827 | if (Value == min) |
||
828 | { |
||
829 | Value = min; |
||
830 | BeepTime = 200; |
||
831 | BeepMuster = 0x0080; |
||
832 | } |
||
833 | else |
||
834 | OCR2A = Value * ValCorr; |
||
835 | |||
836 | } |
||
837 | |||
838 | if (get_key_press (1 << KEY_ENTER)) |
||
839 | { |
||
840 | edit = 1; |
||
841 | OCR2A = Value * ValCorr; |
||
842 | LCD_Helligkeit = Value; |
||
843 | WriteParameter(); |
||
844 | return Value; |
||
845 | } |
||
846 | } |
||
847 | |||
848 | while (!get_key_press (1 << KEY_ESC)); |
||
849 | { |
||
850 | get_key_press(KEY_ALL); |
||
851 | edit = 0; |
||
852 | OCR2A = Pre * ValCorr; |
||
853 | LCD_Helligkeit = Pre; |
||
854 | WriteParameter(); |
||
855 | return Pre; |
||
856 | } |
||
857 | } |
||
858 | |||
859 | |||
860 | //-------------------------------------------------------------- |
||
861 | void Reset_EEprom(void) |
||
862 | { |
||
863 | lcd_cls(); |
||
864 | get_key_press(KEY_ALL); |
||
865 | // lcd_printp_at (0, 2, PSTR(" EEProm wirklich"), 0); |
||
866 | // lcd_printp_at (0, 3, PSTR(" löschen?"), 0); |
||
867 | // lcd_printp_at (12, 7, PSTR("Ende OK"), 0); |
||
868 | lcd_puts_at(0, 2, strGet(EEPROM1), 0); |
||
869 | lcd_puts_at(0, 3, strGet(EEPROM2), 0); |
||
870 | lcd_puts_at(12, 7, strGet(ENDOK), 0); |
||
871 | |||
872 | |||
873 | do |
||
874 | { |
||
875 | |||
876 | if (get_key_press (1 << KEY_ENTER)) |
||
877 | { |
||
878 | Delete_EEPROM(); |
||
879 | return; |
||
880 | } |
||
881 | } |
||
882 | while (!get_key_press (1 << KEY_ESC)); |
||
883 | get_key_press(KEY_ALL); |
||
884 | } |
||
885 | |||
886 | |||
887 | //-------------------------------------------------------------- |
||
888 | void PKT_Setup (void) |
||
889 | { |
||
890 | uint8_t ii = 0; |
||
891 | uint8_t Offset = 0; |
||
892 | uint8_t size = 0; |
||
893 | size = ITEMS_PKT; |
||
894 | uint8_t dmode = 0; |
||
895 | uint8_t target_pos = 1; |
||
896 | uint8_t val; |
||
897 | |||
898 | lcd_cls (); |
||
899 | mmode = 0; |
||
900 | edit= 0; |
||
901 | val = 0; |
||
902 | |||
903 | while(1) |
||
904 | { |
||
905 | lcd_cls (); |
||
906 | lcd_printp_at (0, 0, PSTR(" PKT-Setup "), 2); |
||
907 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
908 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
909 | |||
910 | while(1) |
||
911 | { |
||
912 | ii = 0; |
||
913 | |||
914 | if(Offset > 0) |
||
915 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
916 | |||
917 | for(ii = 0;ii < 6 ; ii++) |
||
918 | { |
||
919 | if((ii+Offset) < size) |
||
920 | lcd_printp_at(3,ii+1,param_menuitems_pkt[ii+Offset][DisplayLanguage], 0); |
||
921 | |||
922 | if((ii == 5)&&(ii+Offset < (size-1))) |
||
923 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
924 | |||
925 | } |
||
926 | |||
927 | if(dmode == 0) |
||
928 | { |
||
929 | if(Offset == 0) |
||
930 | { |
||
931 | if(size > 6) |
||
932 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
933 | else |
||
934 | val = menu_choose2 (1, size, target_pos,0,0); |
||
935 | |||
936 | } |
||
937 | else |
||
938 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
939 | |||
940 | } |
||
941 | |||
942 | if(dmode == 1) |
||
943 | { |
||
944 | if(Offset+7 > size) |
||
945 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
946 | else |
||
947 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
948 | |||
949 | } |
||
950 | |||
951 | if(val == 254) |
||
952 | { |
||
953 | Offset++; |
||
954 | dmode = 1; |
||
955 | target_pos = 5; |
||
956 | } |
||
957 | else if(val == 253) |
||
958 | { |
||
959 | Offset--; |
||
960 | dmode = 0; |
||
961 | target_pos = 2; |
||
962 | } |
||
963 | else if(val == 255) |
||
964 | { // Ende mit ESC, speichern |
||
965 | if (edit == 1) |
||
966 | { |
||
967 | WriteParameter(); |
||
968 | return; |
||
969 | } |
||
970 | return; |
||
971 | } |
||
972 | else |
||
973 | break; |
||
974 | } |
||
975 | target_pos = val; |
||
976 | |||
977 | if((val + Offset) == 1) |
||
978 | { |
||
979 | #ifdef HWVERSION3_9 |
||
980 | U02SV2 = ChangeWi_SV2(U02SV2); |
||
981 | |||
982 | if (edit == 1) |
||
983 | PKT_Change = 1; |
||
984 | |||
985 | #else |
||
986 | Show_Error_HW12(); |
||
987 | #endif |
||
988 | } |
||
989 | |||
990 | if((val + Offset) == 2) |
||
991 | MK_LowBat = Edit_Int10th_Value(MK_LowBat,33,247,LOWBAT); |
||
992 | |||
993 | if((val + Offset) == 3) |
||
994 | Display_Setup(); |
||
995 | |||
996 | if((val + Offset) == 4) |
||
997 | { |
||
998 | #if defined HWVERSION3_9 || defined HWVERSION1_2W || defined HWVERSION1_3W |
||
999 | if(UseWi == false) |
||
1000 | // Wi_Use(); |
||
1001 | { |
||
1002 | UseWi = Edit_YesNo(UseWi,0,1,WI2321); |
||
1003 | if (edit==1) |
||
1004 | if (UseWi== true) InitWi232(); |
||
1005 | } |
||
1006 | |||
1007 | else |
||
1008 | Wi_Setup(); |
||
1009 | #else |
||
1010 | Show_Error_HW12(); |
||
1011 | #endif |
||
1012 | } |
||
1013 | |||
1014 | if((val + Offset) == 5) |
||
1015 | { |
||
1016 | #ifdef HWVERSION3_9 |
||
1017 | if(UseBT == 0) |
||
1018 | { |
||
1019 | UseBT = Edit_YesNo(UseBT,0,1,BT1); |
||
1020 | if (edit==1) |
||
1021 | if (UseBT == 1) |
||
1022 | { |
||
1023 | if (bt_init()) BTIsSet = true; else BTIsSet = false; |
||
1024 | WriteParameter(); |
||
1025 | } |
||
1026 | } |
||
1027 | else |
||
1028 | BT_Setup(); |
||
1029 | #else |
||
1030 | Show_Error_HW12(); |
||
1031 | #endif |
||
1032 | } |
||
1033 | |||
1034 | if((val + Offset) == 6) |
||
1035 | #ifdef HWVERSION3_9 |
||
1036 | Accu_Setup(); |
||
1037 | #else |
||
1038 | Show_Error_HW12(); |
||
1039 | #endif |
||
1040 | if((val + Offset) == 7) |
||
1041 | Update_PKT(); |
||
1042 | |||
1043 | if((val + Offset) == 8) |
||
1044 | Debug = Edit_Int_Value(Debug,0,1,DEBUGPKT); |
||
1045 | |||
1046 | if((val + Offset) == 9) |
||
1047 | Reset_EEprom(); |
||
1048 | |||
1049 | } |
||
1050 | } |
||
1051 | |||
1052 | |||
1053 | //-------------------------------------------------------------- |
||
1054 | void Display_Setup (void) |
||
1055 | { |
||
1056 | uint8_t ii = 0; |
||
1057 | uint8_t Offset = 0; |
||
1058 | uint8_t size = 0; |
||
1059 | size = ITEMS_LCD; |
||
1060 | uint8_t dmode = 0; |
||
1061 | uint8_t target_pos = 1; |
||
1062 | uint8_t val; |
||
1063 | |||
1064 | lcd_cls (); |
||
1065 | mmode = 0; |
||
1066 | edit= 0; |
||
1067 | LCD_Change = 0; |
||
1068 | val = 0; |
||
1069 | |||
1070 | while(1) |
||
1071 | { |
||
1072 | lcd_cls (); |
||
1073 | // lcd_printp_at (0, 0, PSTR(" Display Setup "), 2); |
||
1074 | lcd_puts_at(0, 0, strGet(DISPLAY1), 2); |
||
1075 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
1076 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
1077 | |||
1078 | while(1) |
||
1079 | { |
||
1080 | ii = 0; |
||
1081 | |||
1082 | if(Offset > 0) |
||
1083 | lcd_printp_at(1, 1, PSTR("\x12"), 0); |
||
1084 | |||
1085 | for(ii = 0; ii < 6 ; ii++) |
||
1086 | { |
||
1087 | if((ii + Offset) < size) |
||
1088 | lcd_printp_at(3, ii + 1, param_menuitems_lcd[ii + Offset][DisplayLanguage], 0); |
||
1089 | |||
1090 | if((ii == 5)&&(ii+Offset < (size - 1))) |
||
1091 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
1092 | |||
1093 | } |
||
1094 | |||
1095 | if(dmode == 0) |
||
1096 | { |
||
1097 | if(Offset == 0) |
||
1098 | { |
||
1099 | if(size > 6) |
||
1100 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
1101 | else |
||
1102 | val = menu_choose2 (1, size, target_pos,0,0); |
||
1103 | |||
1104 | } |
||
1105 | else |
||
1106 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
1107 | |||
1108 | } |
||
1109 | |||
1110 | if(dmode == 1) |
||
1111 | { |
||
1112 | if(Offset + 7 > size) |
||
1113 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
1114 | else |
||
1115 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
1116 | |||
1117 | } |
||
1118 | |||
1119 | if(val == 254) |
||
1120 | { |
||
1121 | Offset++; |
||
1122 | dmode = 1; |
||
1123 | target_pos = 5; |
||
1124 | } |
||
1125 | else if(val == 253) |
||
1126 | { |
||
1127 | Offset--; |
||
1128 | dmode = 0; |
||
1129 | target_pos = 2; |
||
1130 | } |
||
1131 | else if(val == 255) |
||
1132 | { // Ende mit ESC, speichern |
||
1133 | if (edit == 1) |
||
1134 | { |
||
1135 | WriteParameter(); |
||
1136 | return; |
||
1137 | } |
||
1138 | return; |
||
1139 | } |
||
1140 | else |
||
1141 | break; |
||
1142 | } |
||
1143 | target_pos = val; |
||
1144 | |||
1145 | if((val + Offset) == 1) |
||
1146 | PKT_StartInfo = Edit_StartInfo(PKT_StartInfo,0,2,DISPLAY2); |
||
1147 | |||
1148 | if((val + Offset) == 2) |
||
1149 | DisplayLanguage = Edit_Language(DisplayLanguage,0,3,DISPLAY3); |
||
1150 | // Edit_Language(DisplayLanguage,0,3,DISPLAY3); |
||
1151 | |||
1152 | if((val + Offset) == 3) |
||
1153 | DisplayTimeout = Edit_Int_Value(DisplayTimeout,0,254,DISPLAY4); |
||
1154 | |||
1155 | if((val + Offset) == 4) |
||
1156 | LCD_Helligkeit = Edit_DisplayHelligkeit(LCD_Helligkeit,0,100,DISPLAY5); |
||
1157 | if (edit == 1) |
||
1158 | if(!LCD_Change) |
||
1159 | LCD_Change =1; |
||
1160 | |||
1161 | if((val + Offset) == 5) |
||
1162 | LCD_Kontrast = Edit_DisplayKontrast(LCD_Kontrast,0,63,DISPLAY6); |
||
1163 | if (edit == 1) |
||
1164 | if(!LCD_Change) |
||
1165 | LCD_Change =1; |
||
1166 | |||
1167 | if((val + Offset) == 6) |
||
1168 | { |
||
1169 | LCD_DisplayMode = Edit_DisplayMode(LCD_DisplayMode,0,4,DISPLAY7); |
||
1170 | if (edit == 1) |
||
1171 | if(!LCD_Change) |
||
1172 | LCD_Change =1; |
||
1173 | } |
||
1174 | |||
1175 | if((val + Offset) == 7) |
||
1176 | { |
||
1177 | LCD_Orientation = Edit_Orientation(LCD_Orientation,0,4,DISPLAY8); |
||
1178 | if (edit == 1) |
||
1179 | if(!LCD_Change) |
||
1180 | LCD_Change =1; |
||
1181 | } |
||
1182 | |||
1183 | |||
1184 | |||
1185 | |||
1186 | } |
||
1187 | } |
||
1188 | |||
1189 | #if defined HWVERSION3_9 ||HWVERSION1_3W |
||
1190 | ////-------------------------------------------------------------- |
||
1191 | //void Wi_Use (void) |
||
1192 | //{ |
||
1193 | // Pre = UseWi; |
||
1194 | // |
||
1195 | // lcd_cls (); |
||
1196 | // |
||
1197 | // lcd_cls (); |
||
1198 | //// lcd_printp_at (0, 0, PSTR(" Wi.232 Setup "), 2); |
||
1199 | //// lcd_printp_at (0, 2, PSTR("Ist ein Wi.232-Modul "), 0); |
||
1200 | //// lcd_printp_at (0, 4, PSTR("eingebaut?"), 0); |
||
1201 | // lcd_puts_at(0, 0, strGet(WI2321), 2); |
||
1202 | // lcd_puts_at(0, 2, strGet(WI2322), 0); |
||
1203 | // lcd_puts_at(0, 4, strGet(WI2323), 0); |
||
1204 | //// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
1205 | // lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
1206 | // |
||
1207 | // while(1) |
||
1208 | // { |
||
1209 | // if(UseWi == false) |
||
1210 | //// lcd_printp_at (12, 4, PSTR("Nein"), 0); |
||
1211 | // lcd_puts_at(12, 4, strGet(NOO), 0); |
||
1212 | // else |
||
1213 | // //lcd_printp_at (12, 4, PSTR("Ja "), 0); |
||
1214 | // lcd_puts_at(12, 4, strGet(YES), 0); |
||
1215 | // |
||
1216 | // if(get_key_press (1 << KEY_MINUS)) |
||
1217 | // { |
||
1218 | // UseWi = false; |
||
1219 | // edit = 1; |
||
1220 | // } |
||
1221 | // |
||
1222 | // if(get_key_press (1 << KEY_PLUS)) |
||
1223 | // { |
||
1224 | // UseWi = true; |
||
1225 | // edit = 1; |
||
1226 | // } |
||
1227 | // |
||
1228 | // if(get_key_short (1 << KEY_ENTER)) |
||
1229 | // { |
||
1230 | //// WiIsSet = false; |
||
1231 | //// WriteParameter(); |
||
1232 | //// if(UseWi == true) |
||
1233 | //// Wi_Setup(); |
||
1234 | // return; |
||
1235 | // } |
||
1236 | // |
||
1237 | // if (get_key_press (1 << KEY_ESC)) |
||
1238 | // { |
||
1239 | // get_key_press(KEY_ALL); |
||
1240 | // UseWi = Pre; |
||
1241 | // return; |
||
1242 | // } |
||
1243 | // } |
||
1244 | //} |
||
1245 | |||
1246 | |||
1247 | //-------------------------------------------------------------- |
||
1248 | void Wi_Setup (void) |
||
1249 | { |
||
1250 | uint8_t ii = 0; |
||
1251 | uint8_t Offset = 0; |
||
1252 | uint8_t size = 0; |
||
1253 | size = ITEMS_WI; |
||
1254 | uint8_t dmode = 0; |
||
1255 | uint8_t target_pos = 1; |
||
1256 | uint8_t val = 0; |
||
1257 | |||
1258 | mmode = 0; |
||
1259 | edit = 0; |
||
1260 | // WiIsSet = true; |
||
1261 | |||
1262 | lcd_cls (); |
||
1263 | |||
1264 | while(1) |
||
1265 | { |
||
1266 | lcd_cls (); |
||
1267 | lcd_printp_at (0, 0, PSTR(" Wi.232 Setup "), 2); |
||
1268 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
1269 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
1270 | |||
1271 | while(1) |
||
1272 | { |
||
1273 | ii = 0; |
||
1274 | |||
1275 | if(Offset > 0) |
||
1276 | lcd_printp_at(1, 1, PSTR("\x12"), 0); |
||
1277 | |||
1278 | for(ii = 0; ii < 6; ii++) |
||
1279 | { |
||
1280 | if((ii + Offset) < size) |
||
1281 | lcd_printp_at(3, ii+1, param_menuitems_wi[ii+Offset][DisplayLanguage], 0); |
||
1282 | |||
1283 | if((ii == 5)&&(ii + Offset < (size - 1))) |
||
1284 | lcd_printp_at(1, 6, PSTR("\x13"), 0); |
||
1285 | |||
1286 | } |
||
1287 | |||
1288 | if(dmode == 0) |
||
1289 | { |
||
1290 | if(Offset == 0) |
||
1291 | { |
||
1292 | if(size > 6) |
||
1293 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
1294 | else |
||
1295 | val = menu_choose2 (1, size, target_pos,0,0); |
||
1296 | |||
1297 | } |
||
1298 | else |
||
1299 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
1300 | |||
1301 | } |
||
1302 | |||
1303 | if(dmode == 1) |
||
1304 | { |
||
1305 | if(Offset + 7 > size) |
||
1306 | val = menu_choose2 (2, 6, target_pos, 1, 0); |
||
1307 | else |
||
1308 | val = menu_choose2 (2, 5, target_pos, 1, 1); |
||
1309 | |||
1310 | } |
||
1311 | |||
1312 | if(val == 254) |
||
1313 | { |
||
1314 | Offset++; |
||
1315 | dmode = 1; |
||
1316 | target_pos = 5; |
||
1317 | } |
||
1318 | else if(val == 253) |
||
1319 | { |
||
1320 | Offset--; |
||
1321 | dmode = 0; |
||
1322 | target_pos = 2; |
||
1323 | } |
||
1324 | else if(val == 255) |
||
1325 | { // Ende mit ESC, speichern |
||
1326 | // if (edit == 1) |
||
1327 | // { |
||
1328 | // if (UseWi==true) InitWi232(); |
||
1329 | // WriteParameter(); |
||
1330 | // } |
||
1331 | |||
1332 | return; |
||
1333 | } |
||
1334 | else |
||
1335 | |||
1336 | if (edit == 1) |
||
1337 | { |
||
1338 | if (UseWi==true) InitWi232(); |
||
1339 | WriteParameter(); |
||
1340 | } |
||
1341 | |||
1342 | |||
1343 | |||
1344 | |||
1345 | break; |
||
1346 | } |
||
1347 | target_pos = val; |
||
1348 | |||
1349 | if((val + Offset) == 1) |
||
1350 | { |
||
1351 | UseWi = Edit_YesNo(UseWi,0,1,WI2321); |
||
1352 | } |
||
1353 | |||
1354 | if((val + Offset) == 2) |
||
1355 | { |
||
1356 | WiTXRXChannel = Edit_Int_Value(WiTXRXChannel, 0, 5,WINETWG); |
||
1357 | |||
1358 | } |
||
1359 | |||
1360 | if((val + Offset) == 3) |
||
1361 | { |
||
1362 | WiNetworkGroup = Edit_Int_Value(WiNetworkGroup, 0, 127, WINETWG); |
||
1363 | |||
1364 | |||
1365 | } |
||
1366 | |||
1367 | if((val + Offset) == 4) |
||
1368 | { |
||
1369 | WiNetworkMode = Edit_Wi_NetMode_Value(WiNetworkMode); |
||
1370 | |||
1371 | |||
1372 | } |
||
1373 | |||
1374 | if((val + Offset) == 5) |
||
1375 | { |
||
1376 | WiTXTO = Edit_Int_Value(WiTXTO,0,127,WITIMEOUT); |
||
1377 | |||
1378 | |||
1379 | } |
||
1380 | |||
1381 | if((val + Offset) == 6) |
||
1382 | { |
||
1383 | WiUartMTU = Edit_Int_Value(WiUartMTU,0,127,WIUART); |
||
1384 | |||
1385 | |||
1386 | } |
||
1387 | |||
1388 | if((val + Offset) == 7) |
||
1389 | InitWi232(); |
||
1390 | |||
1391 | if((val + Offset) == 8) |
||
1392 | Port_USB2CFG_Wi(); |
||
1393 | } |
||
1394 | } |
||
1395 | #endif |
||
1396 | |||
1397 | #ifdef HWVERSION3_9 |
||
1398 | //-------------------------------------------------------------- |
||
1399 | // |
||
1400 | uint8_t Edit_String(const char *data, const uint8_t length, uint8_t type, const char *Text) |
||
1401 | { |
||
1402 | uint8_t y = 1; |
||
1403 | uint8_t x = 1; |
||
1404 | uint8_t I = 0; |
||
1405 | |||
1406 | lcd_cls(); |
||
1407 | lcd_printp_at (0, 0, Text, 2); |
||
1408 | |||
1409 | for (uint8_t i = 0; i < length; i++) |
||
1410 | { |
||
1411 | lcd_putc (y++, 3, data[i], 0); |
||
1412 | lcd_printp_at (y++, 3, PSTR(" "), 0); |
||
1413 | |||
1414 | EditString[i] = data[i]; |
||
1415 | } |
||
1416 | |||
1417 | lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1); |
||
1418 | lcd_printp_at (0, 6, PSTR(" C"), 0); |
||
1419 | lcd_printp_at (0, 7, PSTR(" \x17 \x16 \x19 OK"), 0); |
||
1420 | |||
1421 | do |
||
1422 | { |
||
1423 | if (type == 1) // Name |
||
1424 | { |
||
1425 | for (uint8_t i = bt_name_length; i > 0; i--) |
||
1426 | { |
||
1427 | if (EditString[i - 1] != ' ') |
||
1428 | { |
||
1429 | bt_name_len = i; |
||
1430 | break; |
||
1431 | } |
||
1432 | } |
||
1433 | |||
1434 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && EditString[I] < 'z') |
||
1435 | { |
||
1436 | EditString[I]++; |
||
1437 | |||
1438 | if (EditString[I] >= 0x00 && EditString[I] < ' ') |
||
1439 | EditString[I] = ' '; |
||
1440 | |||
1441 | if (EditString[I] > ' ' && EditString[I] < '0') |
||
1442 | EditString[I] = '0'; |
||
1443 | |||
1444 | if (EditString[I] > '9' && EditString[I] < 'A') |
||
1445 | EditString[I] = 'A'; |
||
1446 | |||
1447 | if (EditString[I] > 'Z' && EditString[I] < 'a') |
||
1448 | EditString[I] = 'a'; |
||
1449 | |||
1450 | lcd_putc (x, 3, EditString[I], 0); |
||
1451 | edit = 1; |
||
1452 | } |
||
1453 | |||
1454 | if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && EditString[I] > ' ') |
||
1455 | { |
||
1456 | EditString[I]--; |
||
1457 | |||
1458 | if (EditString[I] < 'a' && EditString[I] > 'Z') |
||
1459 | EditString[I] = 'Z'; |
||
1460 | |||
1461 | if (EditString[I] < 'A' && EditString[I] > '9') |
||
1462 | EditString[I] = '9'; |
||
1463 | |||
1464 | if (EditString[I] < '0' && EditString[I] > ' ') |
||
1465 | EditString[I] = ' '; |
||
1466 | |||
1467 | lcd_putc (x, 3, EditString[I], 0); |
||
1468 | edit = 1; |
||
1469 | } |
||
1470 | } |
||
1471 | else if (type == 2) // PIN |
||
1472 | { |
||
1473 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) && (EditString[I] < '9')) |
||
1474 | { |
||
1475 | EditString[I]++; |
||
1476 | lcd_putc (x, 3, EditString[I], 0); |
||
1477 | edit = 1; |
||
1478 | } |
||
1479 | |||
1480 | if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) && (EditString[I] > '0')) |
||
1481 | { |
||
1482 | EditString[I]--; |
||
1483 | lcd_putc (x, 3, EditString[I], 0); |
||
1484 | edit = 1; |
||
1485 | } |
||
1486 | } |
||
1487 | |||
1488 | if (get_key_long (1 << KEY_ESC)) |
||
1489 | { |
||
1490 | EditString[I] = ' '; // Zeichen l�schen |
||
1491 | lcd_putc (x, 3, EditString[I], 0); |
||
1492 | edit = 1; |
||
1493 | } |
||
1494 | |||
1495 | if (get_key_short (1 << KEY_ESC)) |
||
1496 | { |
||
1497 | if ((x / 2) + 2 > bt_name_length) |
||
1498 | { |
||
1499 | lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 0); |
||
1500 | x = 1; |
||
1501 | lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1); |
||
1502 | I = 0; |
||
1503 | } |
||
1504 | else |
||
1505 | { |
||
1506 | lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 0); |
||
1507 | x++; |
||
1508 | x++; |
||
1509 | lcd_rect ((x*6)-3, (8*3)-2, 10, 10, 1); |
||
1510 | I++; //Zeiger auf Zeichen |
||
1511 | } |
||
1512 | } |
||
1513 | } |
||
1514 | while (!get_key_press (1 << KEY_ENTER)); |
||
1515 | { |
||
1516 | get_key_press(KEY_ALL); |
||
1517 | return 1; |
||
1518 | } |
||
1519 | } |
||
1520 | |||
1521 | |||
1522 | ////-------------------------------------------------------------- |
||
1523 | //void BT_Use (void) |
||
1524 | //{ |
||
1525 | // Pre = UseBT; |
||
1526 | // |
||
1527 | // lcd_cls (); |
||
1528 | // |
||
1529 | // lcd_cls (); |
||
1530 | //// lcd_printp_at (0, 0, PSTR(" BTM-222 Setup "), 2); |
||
1531 | //// lcd_printp_at (0, 2, PSTR("Ist ein BTM-222-Modul"), 0); |
||
1532 | //// lcd_printp_at (0, 4, PSTR("eingebaut?"), 0); |
||
1533 | // lcd_puts_at(0, 0, strGet(BT1), 2); |
||
1534 | // lcd_puts_at(0, 2, strGet(BT2), 0); |
||
1535 | // lcd_puts_at(0, 4, strGet(BT3), 0); |
||
1536 | //// lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
1537 | // lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
1538 | // |
||
1539 | // while(1) |
||
1540 | // { |
||
1541 | // if(UseBT == false) |
||
1542 | //// lcd_printp_at (12, 4, PSTR("Nein"), 0); |
||
1543 | // lcd_puts_at(12, 4, strGet(NOO), 0); |
||
1544 | // else |
||
1545 | //// lcd_printp_at (12, 4, PSTR("Ja "), 0); |
||
1546 | // lcd_puts_at(12, 4, strGet(YES), 0); |
||
1547 | // if(get_key_press (1 << KEY_MINUS)) |
||
1548 | // UseBT = false; |
||
1549 | // |
||
1550 | // if(get_key_press (1 << KEY_PLUS)) |
||
1551 | // UseBT = true; |
||
1552 | // |
||
1553 | // if(get_key_short (1 << KEY_ENTER)) |
||
1554 | // { |
||
1555 | //// BTIsSet = false; |
||
1556 | // WriteParameter(); |
||
1557 | // if(UseBT == true) |
||
1558 | // BT_Setup(); |
||
1559 | // return; |
||
1560 | // } |
||
1561 | // |
||
1562 | // if (get_key_press (1 << KEY_ESC)) |
||
1563 | // { |
||
1564 | // get_key_press(KEY_ALL); |
||
1565 | // UseBT = Pre; |
||
1566 | // return; |
||
1567 | // } |
||
1568 | // } |
||
1569 | //} |
||
1570 | |||
1571 | |||
1572 | //-------------------------------------------------------------- |
||
1573 | // |
||
1574 | void BT_Setup (void) |
||
1575 | { |
||
1576 | uint8_t ii = 0; |
||
1577 | uint8_t Offset = 0; |
||
1578 | uint8_t size = 0; |
||
1579 | size = ITEMS_BT; |
||
1580 | uint8_t dmode = 0; |
||
1581 | uint8_t target_pos = 1; |
||
1582 | uint8_t val; |
||
1583 | char string[20]; |
||
1584 | |||
1585 | mmode = 0; |
||
1586 | edit = 0; |
||
1587 | val = 0; |
||
1588 | // BTIsSet = true; |
||
1589 | |||
1590 | lcd_cls (); |
||
1591 | |||
1592 | while(1) |
||
1593 | { |
||
1594 | lcd_cls (); |
||
1595 | // lcd_printp_at (0, 0, PSTR(" BTM-222 Setup "), 2); |
||
1596 | lcd_puts_at(0, 0, strGet(BT1), 2); |
||
1597 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
1598 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
1599 | |||
1600 | while(1) |
||
1601 | { |
||
1602 | ii = 0; |
||
1603 | |||
1604 | if(Offset > 0) |
||
1605 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
1606 | |||
1607 | for(ii = 0; ii < 6; ii++) |
||
1608 | { |
||
1609 | if((ii + Offset) < size) |
||
1610 | lcd_printp_at(3, ii + 1, param_menuitems_bt[ii+Offset][DisplayLanguage], 0); |
||
1611 | |||
1612 | if((ii == 5) && (ii + Offset < (size - 1))) |
||
1613 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
1614 | |||
1615 | } |
||
1616 | |||
1617 | if(dmode == 0) |
||
1618 | { |
||
1619 | if(Offset == 0) |
||
1620 | { |
||
1621 | if(size > 6) |
||
1622 | val = menu_choose2 (1, 5, target_pos, 0, 1); |
||
1623 | else |
||
1624 | val = menu_choose2 (1, size, target_pos, 0, 0); |
||
1625 | |||
1626 | } |
||
1627 | else |
||
1628 | val = menu_choose2 (2, 5, target_pos, 1, 1); |
||
1629 | |||
1630 | } |
||
1631 | |||
1632 | if(dmode == 1) |
||
1633 | { |
||
1634 | if(Offset + 7 > size) |
||
1635 | val = menu_choose2 (2, 6, target_pos, 1, 0); |
||
1636 | else |
||
1637 | val = menu_choose2 (2, 5, target_pos, 1, 1); |
||
1638 | } |
||
1639 | |||
1640 | if(val == 254) |
||
1641 | { |
||
1642 | Offset++; |
||
1643 | dmode = 1; |
||
1644 | target_pos = 5; |
||
1645 | } |
||
1646 | else if(val == 253) |
||
1647 | { |
||
1648 | Offset--; |
||
1649 | dmode = 0; |
||
1650 | target_pos = 2; |
||
1651 | } |
||
1652 | else if(val == 255) |
||
1653 | { // Ende mit ESC, speichern |
||
1654 | // if (edit == 1) |
||
1655 | // { |
||
1656 | // if (UseBT == 1); |
||
1657 | // if (bt_init()) BTIsSet = true; else BTIsSet = false; |
||
1658 | // WriteParameter(); |
||
1659 | // return; |
||
1660 | // } |
||
1661 | return; |
||
1662 | } |
||
1663 | else |
||
1664 | |||
1665 | if (edit == 1) |
||
1666 | { |
||
1667 | if (UseBT == 1); |
||
1668 | if (bt_init()) BTIsSet = true; else BTIsSet = false; |
||
1669 | WriteParameter(); |
||
1670 | return; |
||
1671 | } |
||
1672 | |||
1673 | |||
1674 | |||
1675 | |||
1676 | break; |
||
1677 | } |
||
1678 | |||
1679 | target_pos = val; |
||
1680 | if((val + Offset) == 1) |
||
1681 | // BT_Use(); |
||
1682 | UseBT = Edit_YesNo(UseBT,0,1,BT1); |
||
1683 | |||
1684 | if((val + Offset) == 2) |
||
1685 | { |
||
1686 | for (uint8_t i = 0; i < bt_name_length; i++) |
||
1687 | { |
||
1688 | string[i] = bt_name[i]; |
||
1689 | } |
||
1690 | string[bt_name_length] = 0; |
||
1691 | Edit_String(string, bt_name_length, 1, PSTR(" Bluetooth Name ")); |
||
1692 | if (edit == 1) |
||
1693 | { |
||
1694 | for (uint8_t i = 0; i < bt_name_len; i++) |
||
1695 | { |
||
1696 | bt_name[i] = EditString[i]; |
||
1697 | WriteParameter(); |
||
1698 | } |
||
1699 | |||
1700 | if (bt_name_len < 10) |
||
1701 | { |
||
1702 | for (uint8_t i = bt_name_len; i < 10; i++) |
||
1703 | { |
||
1704 | bt_name[i] = ' '; |
||
1705 | WriteParameter(); |
||
1706 | } |
||
1707 | } |
||
1708 | } |
||
1709 | } |
||
1710 | |||
1711 | if((val + Offset) == 3) |
||
1712 | { |
||
1713 | for (uint8_t i = 0; i < bt_pin_length; i++) |
||
1714 | { |
||
1715 | string[i] = bt_pin[i]; |
||
1716 | } |
||
1717 | string[bt_pin_length] = 0; |
||
1718 | Edit_String(string, bt_pin_length, 2, PSTR(" Bluetooth Pin ")); |
||
1719 | if (edit == 1) |
||
1720 | { |
||
1721 | for (uint8_t i = 0; i < bt_pin_length; i++) |
||
1722 | { |
||
1723 | bt_pin[i] = EditString[i]; |
||
1724 | WriteParameter(); |
||
1725 | } |
||
1726 | } |
||
1727 | } |
||
1728 | |||
1729 | if((val + Offset) == 4) |
||
1730 | { |
||
1731 | // if (edit == 1) |
||
1732 | // if(BTIsSet) |
||
1733 | // BTIsSet = false; |
||
1734 | |||
1735 | if (bt_init() == true) |
||
1736 | { |
||
1737 | lcd_printp_at (0, 3, PSTR("BT Init ok"), 0); |
||
1738 | WriteBTInitFlag(); |
||
1739 | } |
||
1740 | else |
||
1741 | { |
||
1742 | lcd_printp_at (0, 3, PSTR("BT Init Error"), 0); |
||
1743 | BTIsSet = false; |
||
1744 | BeepTime = 1000; |
||
1745 | BeepMuster = 0x0040; |
||
1746 | } |
||
1747 | } |
||
1748 | |||
1749 | if((val + Offset) == 5) |
||
1750 | Port_FC2CFG_BT(); |
||
1751 | |||
1752 | |||
1753 | } |
||
1754 | } |
||
1755 | |||
1756 | //-------------------------------------------------------------- |
||
1757 | uint8_t Edit_PKT_Accu(uint8_t Value, uint8_t min, uint8_t max) |
||
1758 | { |
||
1759 | Pre = Value; |
||
1760 | lcd_cls(); |
||
1761 | // lcd_printp_at (0, 2, Text, 0); |
||
1762 | lcd_puts_at(0, 2, strGet(LIPO2), 0); |
||
1763 | switch (Value) |
||
1764 | { |
||
1765 | case false :lcd_printp_at (15, 2, PSTR("LiIo"), 0); |
||
1766 | break; |
||
1767 | case true :lcd_printp_at (15, 2, PSTR("LiPo"), 0); |
||
1768 | break; |
||
1769 | break; |
||
1770 | } |
||
1771 | |||
1772 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
1773 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
1774 | |||
1775 | do |
||
1776 | { |
||
1777 | if ((get_key_press (1 << KEY_PLUS)) && (Value == 0)) |
||
1778 | { |
||
1779 | Value = 1; |
||
1780 | lcd_printp_at (15, 2, PSTR("LiPo"), 0); |
||
1781 | } |
||
1782 | |||
1783 | if ((get_key_press (1 << KEY_MINUS)) && (Value == 1)) |
||
1784 | { |
||
1785 | Value = 0; |
||
1786 | lcd_printp_at (15, 2, PSTR("LiIo"), 0); |
||
1787 | } |
||
1788 | |||
1789 | if (get_key_press (1 << KEY_ENTER)) |
||
1790 | { |
||
1791 | edit = 1; |
||
1792 | |||
1793 | PKT_Accutyp = Value; |
||
1794 | // WriteParameter(); |
||
1795 | |||
1796 | return Value; |
||
1797 | } |
||
1798 | } |
||
1799 | |||
1800 | while (!get_key_press (1 << KEY_ESC)); |
||
1801 | { |
||
1802 | get_key_press(KEY_ALL); |
||
1803 | edit = 0; |
||
1804 | PKT_Accutyp = Pre; |
||
1805 | return Pre; |
||
1806 | } |
||
1807 | |||
1808 | } |
||
1809 | |||
1810 | //-------------------------------------------------------------- |
||
1811 | uint16_t Edit_LipoOffset(uint16_t Value, uint16_t min, uint16_t max) |
||
1812 | { |
||
1813 | lcd_cls(); |
||
1814 | // lcd_printp_at (0, 2, Text, 0); |
||
1815 | lcd_puts_at(0, 2, strGet(LIPO3), 0); |
||
1816 | lcd_puts_at(0, 5, strGet(LIPO5), 0); |
||
1817 | lcd_puts_at(0, 6, strGet(LIPO6), 0); |
||
1818 | // lcd_printp_at (0, 3, PSTR("Offset verstellen bis"), 0); |
||
1819 | // lcd_printp_at (0, 4, PSTR("die Spannung passt"), 0); |
||
1820 | Pre16 = Value; |
||
1821 | write_ndigit_number_u (16, 2, Value, 4, 0); |
||
1822 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
1823 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
1824 | |||
1825 | do |
||
1826 | { |
||
1827 | if ((get_key_press (1 << KEY_PLUS) || get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) && (Value < max-10)) |
||
1828 | { |
||
1829 | edit = 1; |
||
1830 | Value = Value +10; |
||
1831 | Lipo_UOffset = Value; |
||
1832 | write_ndigit_number_u (16, 2,Value, 4, 0); |
||
1833 | |||
1834 | } |
||
1835 | |||
1836 | if ((get_key_press (1 << KEY_MINUS) || get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) && (Value > min)) |
||
1837 | { |
||
1838 | edit = 1; |
||
1839 | Value=Value -10; |
||
1840 | Lipo_UOffset = Value; |
||
1841 | write_ndigit_number_u (16, 2,Value, 4, 0); |
||
1842 | } |
||
1843 | |||
1844 | if (get_key_press (1 << KEY_ENTER)) |
||
1845 | return Value; |
||
1846 | show_Lipo(); |
||
1847 | write_ndigit_number_u_100th(8, 3, volt_avg, 0, 0); |
||
1848 | lcd_printp_at(3, 3, PSTR("Volt"), 0); |
||
1849 | |||
1850 | } |
||
1851 | while (!get_key_press (1 << KEY_ESC)); |
||
1852 | { |
||
1853 | get_key_press(KEY_ALL); |
||
1854 | edit = 0; |
||
1855 | Lipo_UOffset = Pre16; |
||
1856 | return Pre16; |
||
1857 | } |
||
1858 | } |
||
1859 | |||
1860 | //-------------------------------------------------------------- |
||
1861 | |||
1862 | |||
1863 | void Accu_Setup (void) |
||
1864 | { |
||
1865 | uint8_t ii = 0; |
||
1866 | uint8_t Offset = 0; |
||
1867 | uint8_t size = 0; |
||
1868 | size = ITEMS_Accu; |
||
1869 | uint8_t dmode = 0; |
||
1870 | uint8_t target_pos = 1; |
||
1871 | uint8_t val; |
||
1872 | |||
1873 | mmode = 0; |
||
1874 | edit = 0; |
||
1875 | val = 0; |
||
1876 | lcd_cls (); |
||
1877 | |||
1878 | while(1) |
||
1879 | { |
||
1880 | lcd_cls (); |
||
1881 | // lcd_printp_at (0, 0, PSTR(" PKT Accu Setup "), 2); |
||
1882 | lcd_puts_at(0, 0, strGet(LIPO1), 2); |
||
1883 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
1884 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
1885 | |||
1886 | while(1) |
||
1887 | { |
||
1888 | ii = 0; |
||
1889 | |||
1890 | if(Offset > 0) |
||
1891 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
1892 | |||
1893 | for(ii = 0; ii < 6; ii++) |
||
1894 | { |
||
1895 | if((ii + Offset) < size) |
||
1896 | lcd_printp_at(3, ii + 1, param_menuitems_Accu[ii+Offset][DisplayLanguage], 0); |
||
1897 | |||
1898 | if((ii == 5) && (ii + Offset < (size - 1))) |
||
1899 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
1900 | |||
1901 | } |
||
1902 | |||
1903 | if(dmode == 0) |
||
1904 | { |
||
1905 | if(Offset == 0) |
||
1906 | { |
||
1907 | if(size > 6) |
||
1908 | val = menu_choose2 (1, 5, target_pos, 0, 1); |
||
1909 | else |
||
1910 | val = menu_choose2 (1, size, target_pos, 0, 0); |
||
1911 | |||
1912 | } |
||
1913 | else |
||
1914 | val = menu_choose2 (2, 5, target_pos, 1, 1); |
||
1915 | |||
1916 | } |
||
1917 | |||
1918 | if(dmode == 1) |
||
1919 | { |
||
1920 | if(Offset + 7 > size) |
||
1921 | val = menu_choose2 (2, 6, target_pos, 1, 0); |
||
1922 | else |
||
1923 | val = menu_choose2 (2, 5, target_pos, 1, 1); |
||
1924 | } |
||
1925 | |||
1926 | if(val == 254) |
||
1927 | { |
||
1928 | Offset++; |
||
1929 | dmode = 1; |
||
1930 | target_pos = 5; |
||
1931 | } |
||
1932 | else if(val == 253) |
||
1933 | { |
||
1934 | Offset--; |
||
1935 | dmode = 0; |
||
1936 | target_pos = 2; |
||
1937 | } |
||
1938 | else if(val == 255) |
||
1939 | { // Ende mit ESC, speichern |
||
1940 | if (edit == 1) |
||
1941 | { |
||
1942 | WriteParameter(); |
||
1943 | |||
1944 | return; |
||
1945 | } |
||
1946 | return; |
||
1947 | } |
||
1948 | else |
||
1949 | break; |
||
1950 | } |
||
1951 | |||
1952 | target_pos = val; |
||
1953 | if((val + Offset) == 1) |
||
1954 | { |
||
1955 | PKT_Accutyp= Edit_PKT_Accu(PKT_Accutyp,0,1); |
||
1956 | if (edit == 1) WriteParameter(); |
||
1957 | } |
||
1958 | |||
1959 | if((val + Offset) == 2) |
||
1960 | { |
||
1961 | Lipo_UOffset = Edit_LipoOffset(Lipo_UOffset,0,9999); |
||
1962 | if (edit == 1) WriteParameter(); |
||
1963 | } |
||
1964 | |||
1965 | } |
||
1966 | } |
||
1967 | |||
1968 | |||
1969 | #endif |