Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1517 | - | 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/pgmspace.h> |
||
38 | #include <util/delay.h> |
||
39 | #include <string.h> |
||
40 | #include <stdlib.h> |
||
41 | |||
42 | #include "main.h" |
||
43 | #include "lcd.h" |
||
44 | #include "timer.h" |
||
45 | #include "usart.h" |
||
46 | #include "mk-data-structs.h" |
||
47 | #include "parameter.h" |
||
48 | #include "menu.h" |
||
49 | #include "eeprom.h" |
||
50 | #include "parameter_names.h" |
||
51 | #include "messages.h" |
||
52 | |||
53 | #define TIMEOUT 500 // 5 sec |
||
54 | |||
55 | uint8_t display_settings_menu (void); |
||
56 | uint8_t display_param_menu (uint8_t); |
||
57 | uint8_t load_setting (uint8_t); |
||
58 | uint8_t write_setting (uint8_t); |
||
59 | uint8_t display_section_menu(void); |
||
60 | void edit_param(uint8_t); |
||
61 | void copy_setting(void); |
||
62 | |||
63 | |||
64 | mk_param_struct_t *mk_param_struct; |
||
65 | |||
66 | uint8_t ii; |
||
67 | volatile uint8_t offset = 0; |
||
68 | volatile uint8_t dmode = 0; |
||
69 | volatile uint8_t target_pos = 1; |
||
70 | volatile uint8_t offset2 = 0; |
||
71 | volatile uint8_t pmode = 0; |
||
72 | volatile uint8_t target_pos2 = 1; |
||
73 | volatile uint8_t setting = 0; |
||
74 | uint8_t changes = 0; |
||
75 | |||
76 | #define OFFSETOF(type, field) ((unsigned int) &(((type *) 0)->field)) |
||
77 | |||
78 | #define MKOSO(field) (uint8_t)OFFSETOF(mk_param_struct_t, field) |
||
79 | |||
1547 | - | 80 | |
81 | |||
1517 | - | 82 | //-------------------------------------------------------------- |
83 | // Group, Typ, Min, Max, Struct-Name(Value), Default1, Default2, Default3+4+5, |
||
84 | // 0 1 2 3 4 5 6 7 |
||
85 | // ||| |
||
86 | // Typ == (0 ohne Poti, 1 mit Poti, 2 bitfield, 3 serCh, 4 LEDmask, 5 Angle, 6 Empfaenger), |
||
87 | // |
||
88 | prog_uchar param_config[8*PARAM_COUNT]= |
||
89 | { |
||
90 | // group 0 (kanaele) 1-15 |
||
91 | |||
92 | 0,0,1,12, MKOSO(Kanalbelegung)+2 , 1,1,1, // gas |
||
93 | 0,0,1,12, MKOSO(Kanalbelegung)+3 , 4,4,4, // gier |
||
94 | 0,0,1,12, MKOSO(Kanalbelegung)+0 , 3,3,3, // nick |
||
95 | 0,0,1,12, MKOSO(Kanalbelegung)+1 , 2,2,2, // roll |
||
96 | 0,3,1,25, MKOSO(Kanalbelegung)+4 , 5,5,5, // poti1 |
||
97 | 0,3,1,25, MKOSO(Kanalbelegung)+5 , 6,6,6, // poti2 |
||
98 | 0,3,1,25, MKOSO(Kanalbelegung)+6 , 7,7,7, // poti3 |
||
99 | 0,3,1,25, MKOSO(Kanalbelegung)+7 , 8,8,8, // poti4 |
||
100 | 0,3,1,25, MKOSO(Kanalbelegung)+8 , 9,9,9, // poti5 |
||
101 | 0,3,1,25, MKOSO(Kanalbelegung)+9 , 10,10,10, // poti6 |
||
102 | 0,3,1,25, MKOSO(Kanalbelegung)+10, 11,11,11, // poti7 |
||
103 | 0,3,1,25, MKOSO(Kanalbelegung)+11, 12,12,12, // poti8 |
||
104 | 0,0,0,12, MKOSO(MotorSafetySwitch), 0,0,0, // Motor Sicherungsswitch |
||
105 | 0,2,0,0x04, MKOSO(ExtraConfig), 0,0,0, // erweiterte signal pruefung |
||
106 | 0,6,0,6, MKOSO(Receiver), 1,1,1, |
||
107 | |||
108 | |||
109 | // group 1 (main) 16-23 |
||
110 | |||
111 | 1,2,0,0x01, MKOSO(GlobalConfig), 0,0,0, // hoehenregler |
||
112 | 1,2,0,0x20, MKOSO(GlobalConfig), 1,1,1, // gps |
||
113 | 1,2,0,0x08, MKOSO(GlobalConfig), 1,1,1, // kompass |
||
114 | 1,2,0,0x10, MKOSO(GlobalConfig), 0,0,0, // feste ausrichtung |
||
115 | 1,2,0,0x04, MKOSO(ExtraConfig), 0,0,0, // erweiterte signal pruefung |
||
116 | 1,2,0,0x40, MKOSO(GlobalConfig), 1,1,1, // achsentkopplung |
||
117 | 1,2,0,0x80, MKOSO(GlobalConfig), 0,0,0, // drehratenbregrenzung |
||
118 | 1,2,0,0x04, MKOSO(GlobalConfig), 0,0,0, // heading hold |
||
119 | |||
120 | |||
121 | |||
122 | // group 2 (stick) 24-27 |
||
123 | |||
124 | 2,0,0,20, MKOSO(Stick_P), 10,8,6, |
||
125 | 2,0,0,20, MKOSO(Stick_D), 16,16,10, |
||
126 | 2,1,0,255, MKOSO(StickGier_P), 6,6,4, |
||
127 | 2,1,0,255, MKOSO(ExternalControl), 0,0,0, |
||
128 | |||
129 | |||
130 | // group3 : looping 28-36 |
||
131 | |||
132 | 3,2,0,0x01, MKOSO(BitConfig), 0,0,0, // oben |
||
133 | 3,2,0,0x02, MKOSO(BitConfig), 0,0,0, // unten |
||
134 | 3,2,0,0x04, MKOSO(BitConfig), 0,0,0, // links |
||
135 | 3,2,0,0x08, MKOSO(BitConfig), 0,0,0, // rechts |
||
136 | 3,1,0,255, MKOSO(LoopGasLimit), 50,50,50, |
||
137 | 3,0,0,247, MKOSO(LoopThreshold), 90,90,90, |
||
138 | 3,0,0,247, MKOSO(LoopHysterese), 50,50,50, |
||
139 | 3,0,0,247, MKOSO(WinkelUmschlagNick), 78,78,78, |
||
140 | 3,0,0,247, MKOSO(WinkelUmschlagRoll), 78,78,78, |
||
141 | |||
142 | |||
143 | // group 4 (hoehe) 37-50 |
||
144 | |||
145 | 4,2,0,0x01, MKOSO(GlobalConfig), 0,0,0, // hoehenrelger |
||
146 | 4,2,0,0x01, MKOSO(ExtraConfig), 0,0,0, // vario oder hoeenbergenzung |
||
147 | 4,2,0,0x02, MKOSO(GlobalConfig), 1,1,1, // hoehenschalter |
||
148 | 4,2,0,0x02, MKOSO(ExtraConfig), 1,1,1, // variobeep |
||
149 | 4,1,0,255, MKOSO(MaxHoehe), 255,255,255, |
||
150 | 4,0,0,247, MKOSO(Hoehe_MinGas), 30,30,30, |
||
151 | 4,1,0,255, MKOSO(Hoehe_P), 15,15,15, |
||
152 | 4,1,0,255, MKOSO(Luftdruck_D), 30,30,30, |
||
153 | 4,1,0,255, MKOSO(Hoehe_ACC_Wirkung), 0,0,0, |
||
154 | 4,1,0,255, MKOSO(MaxAltitude), 150,150,150, |
||
155 | 4,0,0,247, MKOSO(Hoehe_Verstaerkung), 15,15,15, |
||
156 | 4,0,0,247, MKOSO(Hoehe_HoverBand), 8,8,8, |
||
157 | 4,1,0,255, MKOSO(Hoehe_GPS_Z), 64,64,64, |
||
158 | 4,0,0,160, MKOSO(Hoehe_StickNeutralPoint), 0,0,0, |
||
159 | |||
160 | |||
161 | // group 5 : kamera 51-66 |
||
162 | |||
163 | 5,1,0,255, MKOSO(ServoNickControl), 128,128,128, |
||
164 | 5,0,0,247, MKOSO(ServoNickComp), 50,50,50, |
||
165 | 5,2,0,0x01, MKOSO(ServoCompInvert), 0,0,0, // nick |
||
166 | 5,0,0,247, MKOSO(ServoNickMin), 15,15,15, |
||
167 | 5,0,0,247, MKOSO(ServoNickMax), 230,230,230, |
||
168 | 5,1,0,255, MKOSO(ServoRollControl), 128,128,128, |
||
169 | 5,0,0,247, MKOSO(ServoRollComp), 85,85,85, |
||
170 | 5,2,0,0x02, MKOSO(ServoCompInvert), 0,0,0, // roll |
||
171 | 5,0,0,247, MKOSO(ServoRollMin), 70,70,70, |
||
172 | 5,0,0,247, MKOSO(ServoRollMax), 220,220,220, |
||
173 | 5,0,2,8, MKOSO(ServoNickRefresh), 4,4,4, |
||
174 | 5,0,0,247, MKOSO(ServoManualControlSpeed), 60,60,60, |
||
175 | 5,5,0,247, MKOSO(CamOrientation), 0,0,0, |
||
176 | 5,1,0,255, MKOSO(Servo3), 125,125,125, |
||
177 | 5,1,0,255, MKOSO(Servo4), 125,125,125, |
||
178 | 5,1,0,255, MKOSO(Servo5), 125,125,125, |
||
179 | |||
180 | |||
181 | // group 6 : navictrl 67-85 |
||
182 | |||
183 | 6,2,0,0x20, MKOSO(GlobalConfig), 1,1,1, // gps |
||
184 | 6,1,0,255, MKOSO(NaviGpsModeControl), 254,254,254, |
||
185 | 6,1,0,255, MKOSO(NaviGpsGain), 100,100,100, |
||
186 | 6,0,0,247, MKOSO(NaviStickThreshold), 8,8,8, |
||
187 | 6,0,0,247, MKOSO(NaviGpsMinSat), 6,6,6, |
||
188 | 6,1,0,255, MKOSO(NaviGpsP), 90,90,90, |
||
189 | 6,1,0,255, MKOSO(NaviGpsI), 90,90,90, |
||
190 | 6,1,0,255, MKOSO(NaviGpsD), 90,90,90, |
||
191 | 6,1,0,255, MKOSO(NaviGpsPLimit), 75,75,75, |
||
192 | 6,1,0,255, MKOSO(NaviGpsILimit), 85,85,85, |
||
193 | 6,1,0,255, MKOSO(NaviGpsDLimit), 75,75,75, |
||
194 | 6,1,0,255, MKOSO(NaviGpsACC), 0,0,0, |
||
195 | 6,1,0,255, MKOSO(NaviWindCorrection), 90,90,90, |
||
196 | 6,1,0,255, MKOSO(NaviAccCompensation), 42,42,42, |
||
197 | 6,1,0,255, MKOSO(NaviOperatingRadius), 245,245,245, |
||
198 | 6,1,0,255, MKOSO(NaviAngleLimitation), 140,140,140, |
||
199 | 6,0,0,247, MKOSO(NaviPH_LoginTime), 5,5,5, |
||
200 | 6,2,0,0x20, MKOSO(ExtraConfig), 0,0,0, // dynamic ph |
||
201 | 6,0,0,247, MKOSO(ComingHomeAltitude), 0,0,0, |
||
202 | |||
203 | |||
204 | // group 7 : ausgaenge 86-95 |
||
205 | |||
206 | 7,4,0,255, MKOSO(J16Bitmask), 95,95,95, |
||
207 | 7,1,0,255, MKOSO(J16Timing), 20,20,20, |
||
208 | 7,2,0,0x20, MKOSO(BitConfig), 0,0,0, // Motor_Off_Led1 |
||
209 | 7,2,0,0x10, MKOSO(BitConfig), 1,1,1, // Motor_Blink1 |
||
210 | 7,4,0,255, MKOSO(J17Bitmask), 243,243,243, |
||
211 | 7,1,0,255, MKOSO(J17Timing), 20,20,20, |
||
212 | 7,2,0,0x40, MKOSO(BitConfig), 0,0,0, // Motor_Off_Led2 |
||
213 | 7,2,0,0x80, MKOSO(BitConfig), 1,1,1, // Motor_Blink2 |
||
214 | 7,4,0,255, MKOSO(WARN_J16_Bitmask), 170,170,170, |
||
215 | 7,4,0,255, MKOSO(WARN_J17_Bitmask), 170,170,170, |
||
216 | |||
217 | |||
218 | // group 8 : versch. 96-107 |
||
219 | |||
220 | 8,0,0,247, MKOSO(Gas_Min), 8,8,8, |
||
221 | 8,0,0,247, MKOSO(Gas_Max), 230,230,230, |
||
222 | 8,1,0,255, MKOSO(KompassWirkung), 64,64,64, |
||
223 | 8,1,0,255, MKOSO(CareFreeModeControl), 0,0,0, // Carefree |
||
224 | 8,2,0,0x40, MKOSO(ExtraConfig), 0,0,0, // teachable Carefree |
||
225 | 8,0,0,247, MKOSO(UnterspannungsWarnung), 33,33,33, |
||
226 | 8,2,0,0x08, MKOSO(ExtraConfig), 0,0,0, // Voltage referenz |
||
227 | 8,0,0,247, MKOSO(NotGasZeit), 90,90,90, |
||
228 | 8,0,0,247, MKOSO(NotGas), 45,45,45, |
||
229 | 8,0,0,247, MKOSO(FailSafeTime), 0,0,0, |
||
230 | 8,2,0,0x80, MKOSO(ExtraConfig), 0,0,0, // Ignore Compass Error |
||
231 | 8,2,0,0x10, MKOSO(ExtraConfig), 0,0,0, // Kein Summer ohne Sender beim Start |
||
232 | |||
233 | |||
234 | // group 9 : gyro 108-120 |
||
235 | |||
236 | 9,1,0,255, MKOSO(Gyro_P), 90,100,100, |
||
237 | 9,1,0,255, MKOSO(Gyro_I), 120,120,120, |
||
238 | 9,1,0,255, MKOSO(Gyro_D), 10,10,10, |
||
239 | 9,1,0,255, MKOSO(Gyro_Gier_P), 90,100,100, |
||
240 | 9,1,0,255, MKOSO(Gyro_Gier_I), 120,120,120, |
||
241 | 9,1,0,255, MKOSO(DynamicStability), 70,70,70, |
||
242 | 9,2,0,0x80, MKOSO(GlobalConfig), 0,0,0, // drehratenbregrenzung |
||
243 | 9,0,0,247, MKOSO(GyroAccFaktor), 27,27,27, |
||
244 | 9,0,0,247, MKOSO(GyroAccAbgleich), 32,32,32, |
||
245 | 9,1,0,255, MKOSO(I_Faktor), 16,16,16, |
||
246 | 9,0,0,247, MKOSO(Driftkomp), 0,0,0, |
||
247 | 9,0,0,16, MKOSO(Gyro_Stability), 6,6,6, |
||
248 | 9,0,0,247, MKOSO(MotorSmooth), 0,0,0, |
||
249 | |||
250 | |||
251 | // group 10: benutzer 121-128 |
||
252 | |||
253 | 10,1,0,255, MKOSO(UserParam1), 0,0,0, |
||
254 | 10,1,0,255, MKOSO(UserParam2), 0,0,0, |
||
255 | 10,1,0,255, MKOSO(UserParam3), 0,0,0, |
||
256 | 10,1,0,255, MKOSO(UserParam4), 0,0,0, |
||
257 | 10,1,0,255, MKOSO(UserParam5), 0,0,0, |
||
258 | 10,1,0,255, MKOSO(UserParam6), 0,0,0, |
||
259 | 10,1,0,255, MKOSO(UserParam7), 0,0,0, |
||
260 | 10,1,0,255, MKOSO(UserParam8), 0,0,0, |
||
261 | |||
262 | |||
263 | // group 11: achskoppl 129-132 |
||
264 | |||
265 | 11,2,0,0x40, MKOSO(GlobalConfig), 0,0,0, // achsentkopplung |
||
266 | 11,1,0,255, MKOSO(AchsKopplung1), 90,90,90, |
||
267 | 11,1,0,255, MKOSO(AchsKopplung2), 55,55,55, |
||
268 | 11,1,0,255, MKOSO(CouplingYawCorrection), 70,70,70, |
||
269 | |||
270 | |||
271 | // group 12: mixer 133 |
||
272 | |||
273 | 12,5,0,23,MKOSO(OrientationAngle), 0,0,0, |
||
274 | |||
275 | // group 13 (easy-setup) 134-144 |
||
276 | |||
277 | 13,2,0,0x01, MKOSO(GlobalConfig), 0,0,0, // hoehenrelger |
||
278 | 13,1,0,255, MKOSO(MaxHoehe), 255,255,255, |
||
279 | 13,0,0,160, MKOSO(Hoehe_StickNeutralPoint), 0,0,0, |
||
280 | 13,2,0,0x20, MKOSO(GlobalConfig), 1,1,1, // gps |
||
281 | 13,1,0,255, MKOSO(NaviGpsModeControl), 254,254,254, |
||
282 | 13,2,0,0x20, MKOSO(ExtraConfig), 0,0,0, // dynamic ph |
||
283 | 13,0,0,247, MKOSO(ComingHomeAltitude), 0,0,0, |
||
284 | 13,1,0,255, MKOSO(CareFreeModeControl), 0,0,0, // Carefree |
||
285 | 13,2,0,0x40, MKOSO(ExtraConfig), 0,0,0, // teachable Carefree |
||
286 | 13,0,0,12, MKOSO(MotorSafetySwitch), 0,0,0, // Motor Sicherungsswitch |
||
287 | 13,5,0,23, MKOSO(OrientationAngle), 0,0,0, |
||
288 | |||
289 | }; |
||
290 | |||
291 | |||
292 | //-------------------------------------------------------------- |
||
293 | #define ITEMS_RX 7 |
||
294 | |||
295 | prog_char param_items_rx[ITEMS_RX][17]= // zeilen,zeichen+1 |
||
296 | { |
||
297 | "PPM ", |
||
298 | "Spektrum ", |
||
299 | "Spektrum HiRes ", |
||
300 | "Spektrum LoRes ", |
||
301 | "Jeti ", |
||
302 | "ACT DSL ", |
||
303 | "HOTT ", |
||
304 | }; |
||
305 | |||
306 | |||
1547 | - | 307 | |
308 | |||
309 | |||
1517 | - | 310 | //-------------------------------------------------------------- |
311 | void edit_parameter(void) |
||
312 | { |
||
313 | SwitchToFC(); |
||
314 | |||
315 | |||
316 | // uint8_t setting; |
||
317 | |||
318 | |||
319 | setting = display_settings_menu(); |
||
320 | |||
321 | if(setting == 255) |
||
322 | return; |
||
323 | |||
324 | if(setting == 6) |
||
325 | { |
||
326 | copy_setting(); |
||
327 | return; |
||
328 | } |
||
329 | |||
330 | lcd_cls(); |
||
331 | // lcd_printp_at (0, 0, PSTR(" Setting x "), 2); |
||
332 | lcd_puts_at(0, 0, strGet(PARA_SETTINGS), 2); |
||
333 | lcd_putc (9, 0, (setting + 48), 2); // ASCII ab 48 (hex 30) beginnt 0 - 9 |
||
334 | // lcd_printp_at (3, 2, PSTR("ändern"), 0); |
||
335 | // lcd_printp_at (3, 3, PSTR("aktivieren"), 0); |
||
336 | lcd_puts_at(3, 2, strGet(PARA_CHANGE), 0); |
||
337 | lcd_puts_at(3, 3, strGet(PARA_AKTIVI), 0); |
||
338 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
339 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
340 | uint8_t val = menu_choose2 (2, 3, 2, 0, 0); |
||
341 | if (val == 255) |
||
342 | return; |
||
343 | if(val == 3) |
||
344 | { |
||
345 | load_setting(setting); |
||
346 | uint8_t setting_written = write_setting(setting); |
||
347 | if(setting_written == setting) |
||
348 | { |
||
349 | lcd_cls_line (0,2,21); |
||
350 | lcd_cls_line (0,3,21); |
||
351 | // lcd_printp_at (11, 0, PSTR("aktiviert"), 0); |
||
352 | lcd_puts_at(11, 0, strGet(PARA_AKTIV), 0); |
||
353 | } |
||
354 | else |
||
355 | { |
||
356 | lcd_cls_line (0,2,21); |
||
357 | lcd_cls_line (0,3,21); |
||
358 | // lcd_printp_at (0, 4, PSTR("Error"), 0); |
||
359 | lcd_puts_at(0, 4, strGet(FEHLER), 0); |
||
360 | } |
||
361 | _delay_ms(2000); |
||
362 | return; |
||
363 | } |
||
364 | |||
365 | if(setting == 255) |
||
366 | return; |
||
367 | |||
368 | uint8_t setting_loaded = load_setting(setting); |
||
369 | if(setting_loaded == 255) |
||
370 | return; |
||
371 | |||
372 | offset = 0; |
||
373 | dmode = 0; |
||
374 | target_pos = 1; |
||
375 | changes =0; |
||
376 | uint8_t group =0; |
||
377 | |||
378 | do |
||
379 | { |
||
380 | group = display_section_menu(); |
||
381 | if(group != 255) |
||
382 | { |
||
383 | offset2 = 0; |
||
384 | pmode = 0; |
||
385 | target_pos2 = 1; |
||
386 | uint8_t param; |
||
387 | do |
||
388 | { |
||
389 | param = display_param_menu(group); |
||
390 | if(param != 255) |
||
391 | { |
||
392 | edit_param(param); |
||
393 | } |
||
394 | } |
||
395 | while(param != 255); |
||
396 | } |
||
397 | } |
||
398 | while(group != 255); |
||
399 | |||
400 | if(changes == 1) |
||
401 | { |
||
402 | lcd_cls(); |
||
403 | // lcd_printp_at (0, 0, PSTR(" Setting x speichern?"), 2); |
||
404 | lcd_puts_at(0, 0, strGet(PARA_SAVESETT), 2); |
||
405 | lcd_putc (9, 0, (setting + 48), 2); // ASCII ab 48 (hex 30) beginnt 0 - 9 |
||
406 | write_ndigit_number_u(9, 0, setting, 1, 0); |
||
407 | // lcd_printp_at (3, 2, PSTR("Ja"), 0); |
||
408 | // lcd_printp_at (3, 3, PSTR("Nein"), 0); |
||
409 | |||
410 | lcd_puts_at(3, 2, strGet(YES), 0); |
||
411 | lcd_puts_at(3, 3, strGet(NOO), 0); |
||
412 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
413 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
414 | uint8_t val = menu_choose2 (2, 3, 2, 0, 0); |
||
415 | if(val == 2) |
||
416 | { |
||
417 | uint8_t setting_written = write_setting(setting); |
||
418 | if(setting_written == setting) |
||
419 | { |
||
420 | // lcd_printp_at (3, 4, PSTR("Gespeichert und"), 0); |
||
421 | lcd_puts_at(3, 4, strGet(PARA_SETTSAVED), 0); |
||
422 | // lcd_printp_at (3, 5, PSTR("Aktiviert"), 0); |
||
423 | lcd_puts_at(3, 5, strGet(PARA_AKTIV), 0); |
||
424 | } |
||
425 | else |
||
426 | { |
||
427 | // lcd_printp_at (0, 4, PSTR("Error"), 0); |
||
428 | lcd_puts_at(0, 4, strGet(FEHLER), 0); |
||
429 | } |
||
430 | timer = 100; |
||
431 | while (timer > 0); |
||
432 | |||
433 | } |
||
434 | } |
||
435 | } |
||
436 | |||
437 | |||
438 | //-------------------------------------------------------------- |
||
439 | void copy_setting(void) |
||
440 | { |
||
441 | uint8_t fromsetting = 3; |
||
442 | uint8_t tosetting = 5; |
||
443 | |||
444 | lcd_cls(); |
||
445 | |||
446 | // lcd_printp_at (0, 1, PSTR("Kopiere Setting"), 0); |
||
447 | // lcd_printp_at (0, 3, PSTR("von x nach y"), 0); |
||
448 | // lcd_printp_at (0, 7, PSTR("von nach Ende OK"), 0); |
||
449 | |||
450 | lcd_puts_at(0, 1, strGet(PARA_COPY), 0); |
||
451 | lcd_puts_at(0, 3, strGet(PARA_FROMTO), 0); |
||
452 | lcd_puts_at(0, 7, strGet(PARA_ENDE), 0); |
||
453 | |||
454 | do |
||
455 | { |
||
456 | write_ndigit_number_u(5,3,fromsetting, 1,0); |
||
457 | write_ndigit_number_u(14,3,tosetting, 1,0); |
||
458 | |||
459 | if(get_key_press (1 << KEY_MINUS)) |
||
460 | { |
||
461 | fromsetting++; |
||
462 | if(fromsetting == 6) fromsetting = 1; |
||
463 | } |
||
464 | if(get_key_press (1 << KEY_PLUS)) |
||
465 | { |
||
466 | tosetting++; |
||
467 | if(tosetting == 6) tosetting = 1; |
||
468 | } |
||
469 | if(get_key_press (1 << KEY_ENTER)) |
||
470 | { |
||
471 | lcd_printp_at (0, 5, PSTR("Wirklich Kopieren?"), 0); |
||
472 | lcd_puts_at(0, 5, strGet(PARA_COPYQ), 0); |
||
473 | // lcd_printp_at (0, 7, PSTR(" Ende OK"), 0); |
||
474 | lcd_puts_at(12, 7, strGet(KEYLINE4), 0); |
||
475 | do |
||
476 | { |
||
477 | if(get_key_press (1 << KEY_ENTER)) |
||
478 | { |
||
479 | uint8_t loaded = load_setting(fromsetting); |
||
480 | if(loaded == fromsetting) |
||
481 | { |
||
482 | uint8_t written = write_setting(tosetting); |
||
483 | if(written == tosetting) |
||
484 | { |
||
485 | lcd_printp_at (0, 5, PSTR("Kopiert und Aktiviert"), 0); |
||
486 | lcd_puts_at(0, 5, strGet(PARA_COPYACTIV), 0); |
||
487 | } |
||
488 | else |
||
489 | { |
||
490 | // lcd_printp_at (0, 5, PSTR("Fehler"), 0); |
||
491 | lcd_puts_at(0, 5, strGet(FEHLER), 0); |
||
492 | lcd_cls_line (6, 5, 14); |
||
493 | } |
||
494 | } |
||
495 | else |
||
496 | { |
||
497 | // lcd_printp_at (0, 5, PSTR("Fehler"), 0); |
||
498 | lcd_puts_at(0, 5, strGet(FEHLER), 0); |
||
499 | lcd_cls_line (6, 5, 14); |
||
500 | } |
||
501 | timer = 100; |
||
502 | while (timer > 0); |
||
503 | return; |
||
504 | } |
||
505 | } |
||
506 | while (!get_key_press (1 << KEY_ESC)); |
||
507 | get_key_press(KEY_ALL); |
||
508 | lcd_cls_line (0, 5, 21); |
||
509 | // lcd_printp_at (0, 7, PSTR("von nach Ende OK"), 0); |
||
510 | lcd_puts_at(0, 7, strGet(PARA_ENDE), 0); |
||
511 | } |
||
512 | } |
||
513 | while (!get_key_press (1 << KEY_ESC)); |
||
514 | get_key_press(KEY_ALL); |
||
515 | } |
||
516 | |||
517 | |||
518 | //-------------------------------------------------------------- |
||
519 | void edit_param(uint8_t param) |
||
520 | { |
||
521 | lcd_cls(); |
||
522 | uint8_t type = pgm_read_byte(param_config+(8*param)+1); |
||
523 | // lcd_printp_at (0, 0, PSTR(" Ändere Setting: "), 2); |
||
524 | lcd_puts_at(0, 0, strGet(PARA_CHANGESETT), 2); |
||
525 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
526 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
527 | |||
528 | if(type != 6) |
||
529 | lcd_printp_at(0,2,param_names[param][DisplayLanguage], 0); |
||
530 | |||
531 | |||
532 | //------------------------------------------------------- |
||
533 | if(type == 0) // ohne poti |
||
534 | { |
||
535 | lcd_printp_at (4, 4, PSTR("( - ) (d: )"), 0); |
||
536 | lcd_printp_at (12, 6, PSTR("Std."), 0); |
||
537 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
538 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
539 | |||
540 | uint8_t min = pgm_read_byte(param_config+(8*param)+2); |
||
541 | uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
||
542 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
543 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
||
544 | uint8_t newvalue = value; |
||
545 | |||
546 | write_ndigit_number_u (5, 4, min, 3, 0); |
||
547 | write_ndigit_number_u (9, 4, max, 3, 0); |
||
548 | write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
||
549 | |||
550 | do |
||
551 | { |
||
552 | write_ndigit_number_u (0, 4, newvalue, 3, 0); |
||
553 | lcd_frect ((8*0), (8*5), (newvalue * (16*8) / max), 6, 1); |
||
554 | |||
555 | if(max >= 50) |
||
556 | { |
||
557 | if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) |
||
558 | { |
||
559 | if((newvalue+1) <= max) |
||
560 | newvalue++; |
||
561 | } |
||
562 | |||
563 | if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) |
||
564 | { |
||
565 | if((newvalue-1) >= min) |
||
566 | { |
||
567 | lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
||
568 | // lcd_frect ((newvalue * (16*8) / max), (8*5), ((16*8) / max), 6, 0); |
||
569 | newvalue--; |
||
570 | } |
||
571 | } |
||
572 | } |
||
573 | else |
||
574 | { |
||
575 | if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) |
||
576 | { |
||
577 | if((newvalue+1) <= max) |
||
578 | newvalue++; |
||
579 | } |
||
580 | |||
581 | if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) |
||
582 | { |
||
583 | if((newvalue-1) >= min) |
||
584 | { |
||
585 | lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
||
586 | // lcd_frect ((newvalue * (16*8) / max), (8*5), ((16*8) / max), 6, 0); |
||
587 | newvalue--; |
||
588 | } |
||
589 | } |
||
590 | } |
||
591 | |||
592 | if(get_key_long (1 << KEY_ESC)) |
||
593 | { |
||
594 | lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
||
595 | newvalue = defaultvalue; |
||
596 | } |
||
597 | |||
598 | if(get_key_short (1 << KEY_ENTER)) |
||
599 | { |
||
600 | if(newvalue != value) |
||
601 | { |
||
602 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
603 | changes=1; |
||
604 | } |
||
605 | break; |
||
606 | } |
||
607 | |||
608 | } |
||
609 | while (!get_key_short (1 << KEY_ESC)); |
||
610 | get_key_press(KEY_ALL); |
||
611 | } |
||
612 | |||
613 | //------------------------------------------------------- |
||
614 | if(type == 1) // mit poti |
||
615 | { |
||
616 | lcd_printp_at (4, 4, PSTR("(0-247-P8)(d:Po )"), 0); |
||
617 | lcd_printp_at (12, 6, PSTR("Std."), 0); |
||
618 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
619 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
620 | |||
621 | uint8_t min = pgm_read_byte(param_config+(8*param)+2); |
||
622 | uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
||
623 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
624 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
||
625 | uint8_t newvalue = value; |
||
626 | uint8_t mode = 0; |
||
627 | |||
628 | if(defaultvalue > 247) |
||
629 | { |
||
630 | lcd_printp_at (17, 4, PSTR("Po )"), 0); |
||
631 | write_ndigit_number_u (19, 4, 256-defaultvalue, 1, 0); |
||
632 | } |
||
633 | else |
||
634 | write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
||
635 | |||
636 | if(value > 247) |
||
637 | mode = 1; |
||
638 | |||
639 | do |
||
640 | { |
||
641 | if(newvalue > 247) |
||
642 | mode = 1; |
||
643 | else |
||
644 | mode = 0; |
||
645 | |||
646 | if(mode == 0) |
||
647 | { |
||
648 | write_ndigit_number_u (0, 4, newvalue, 3, 0); |
||
649 | lcd_frect ((8*0), (8*5), (newvalue * (16*8) / max), 6, 1); |
||
650 | |||
651 | if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 3)) |
||
652 | { |
||
653 | if((newvalue+1) <= max) |
||
654 | newvalue++; |
||
655 | |||
656 | if(newvalue > 247) |
||
657 | { |
||
658 | lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
||
659 | newvalue = 255; |
||
660 | } |
||
661 | } |
||
662 | |||
663 | if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 3)) |
||
664 | { |
||
665 | if((newvalue-1)>=min) |
||
666 | { |
||
667 | lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
||
668 | // lcd_frect ((newvalue * (16*8) / max), (8*5), ((16*8) / max), 6, 0); |
||
669 | newvalue--; |
||
670 | } |
||
671 | } |
||
672 | } |
||
673 | else |
||
674 | { |
||
675 | lcd_printp_at (0, 4, PSTR("Po"), 0); |
||
676 | write_ndigit_number_u (2, 4, 256 - newvalue, 1, 0); |
||
677 | lcd_frect ((8*0), (8*5), ((256 - newvalue) * (16*8) / 8), 6, 1); |
||
678 | |||
679 | if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
680 | { |
||
681 | if(newvalue - 1 > 247) |
||
682 | { |
||
683 | newvalue--; |
||
684 | } |
||
685 | } |
||
686 | |||
687 | if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
688 | { |
||
689 | lcd_frect (((255 - newvalue) * (16*8) / 8), (8*5), (16*8), 6, 0); |
||
690 | // lcd_frect (((255 - newvalue) * (16*8) / 8), (8*5), ((16*8) / 8), 6, 0); |
||
691 | newvalue++; |
||
692 | |||
693 | if(newvalue == 0) |
||
694 | { |
||
695 | lcd_frect ((8*0), (8*5), (16*8), 6, 0); // balken löschen |
||
696 | newvalue = 247; |
||
697 | } |
||
698 | } |
||
699 | } |
||
700 | |||
701 | if(get_key_long (1 << KEY_ESC)) |
||
702 | { |
||
703 | lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
||
704 | newvalue = defaultvalue; |
||
705 | } |
||
706 | |||
707 | if(get_key_short (1 << KEY_ENTER)) |
||
708 | { |
||
709 | if(newvalue != value) |
||
710 | { |
||
711 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
712 | changes=1; |
||
713 | } |
||
714 | break; |
||
715 | } |
||
716 | } |
||
717 | while (!get_key_short (1 << KEY_ESC)); |
||
718 | get_key_press(KEY_ALL); |
||
719 | } |
||
720 | |||
721 | //------------------------------------------------------- |
||
722 | if(type == 2) // ja/nein |
||
723 | { |
||
724 | // lcd_printp_at (3, 4, PSTR("Ja"), 0); |
||
725 | // lcd_printp_at (3, 5, PSTR("Nein"), 0); |
||
726 | lcd_puts_at(3, 4, strGet(YES), 0); |
||
727 | lcd_puts_at(3, 5, strGet(NOO), 0); |
||
728 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
729 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
730 | |||
731 | uint8_t bitmap = pgm_read_byte(param_config+(8*param)+3); |
||
732 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
733 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
||
734 | uint8_t newvalue = value; |
||
735 | |||
736 | if(defaultvalue == 1) |
||
737 | lcd_printp_at (8, 4, PSTR("*"), 0); |
||
738 | if(defaultvalue == 0) |
||
739 | lcd_printp_at (8, 5, PSTR("*"), 0); |
||
740 | |||
741 | do |
||
742 | { |
||
743 | if(newvalue & bitmap) |
||
744 | { |
||
745 | lcd_printp_at (1, 4, PSTR("\x1d"), 0); |
||
746 | lcd_printp_at (1, 5, PSTR(" "), 0); |
||
747 | } |
||
748 | else |
||
749 | { |
||
750 | lcd_printp_at (1, 4, PSTR(" "), 0); |
||
751 | lcd_printp_at (1, 5, PSTR("\x1d"), 0); |
||
752 | } |
||
753 | |||
754 | if((get_key_press (1 << KEY_MINUS)) && (!(newvalue & bitmap))) |
||
755 | newvalue ^= bitmap; |
||
756 | |||
757 | if((get_key_press (1 << KEY_PLUS)) && (newvalue & bitmap)) |
||
758 | newvalue ^= bitmap; |
||
759 | |||
760 | if(get_key_press (1 << KEY_ENTER)) |
||
761 | { |
||
762 | if(newvalue != value) |
||
763 | { |
||
764 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
765 | changes=1; |
||
766 | } |
||
767 | break; |
||
768 | } |
||
769 | } |
||
770 | while (!get_key_short (1 << KEY_ESC)); |
||
771 | get_key_press(KEY_ALL); |
||
772 | } |
||
773 | |||
774 | //------------------------------------------------------- |
||
775 | if(type == 3) // serCH |
||
776 | { |
||
777 | lcd_printp_at (4, 4, PSTR("(1-S12/W) (d: )"), 0); |
||
778 | lcd_printp_at (12, 6, PSTR("Std."), 0); |
||
779 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
780 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
781 | |||
782 | uint8_t min = pgm_read_byte(param_config+(8*param)+2); |
||
783 | uint8_t max = pgm_read_byte(param_config+(8*param)+3); |
||
784 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
785 | uint8_t defaultvalue = pgm_read_byte(param_config+(8*param)+4 + setting ); // 5 - 7 |
||
786 | uint8_t newvalue = value; |
||
787 | |||
788 | write_ndigit_number_u (17, 4, defaultvalue, 3, 0); |
||
789 | |||
790 | do |
||
791 | { |
||
792 | if (newvalue<=(max-13)) |
||
793 | write_ndigit_number_u (0, 4, newvalue, 3, 0); |
||
794 | else |
||
795 | { |
||
796 | if (newvalue<=(max-1)) |
||
797 | { |
||
798 | lcd_printp_at (0, 4, PSTR("S"), 0); |
||
799 | write_ndigit_number_u (1, 4, (newvalue-12), 2, 0); |
||
800 | } |
||
801 | } |
||
802 | if (newvalue==max) |
||
803 | lcd_printp_at (0, 4, PSTR("WPE"), 0); |
||
804 | |||
805 | lcd_frect ((8*0), (8*5), (newvalue * (16*8)) / max, 6, 1); |
||
806 | |||
807 | |||
808 | if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 2)) |
||
809 | { |
||
810 | if((newvalue+1) <= max) |
||
811 | newvalue++; |
||
812 | } |
||
813 | |||
814 | if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 2)) |
||
815 | { |
||
816 | if((newvalue-1)>=min) |
||
817 | { |
||
818 | lcd_frect (((newvalue - 1) * (16*8) / max), (8*5), (16*8), 6, 0); |
||
819 | newvalue--; |
||
820 | } |
||
821 | } |
||
822 | |||
823 | if(get_key_long (1 << KEY_ESC)) |
||
824 | { |
||
825 | lcd_frect ((8*0), (8*5), (16*8), 6, 0); |
||
826 | newvalue = defaultvalue; |
||
827 | } |
||
828 | |||
829 | if(get_key_short (1 << KEY_ENTER)) |
||
830 | { |
||
831 | if(newvalue != value) |
||
832 | { |
||
833 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
834 | changes=1; |
||
835 | } |
||
836 | break; |
||
837 | } |
||
838 | } |
||
839 | while (!get_key_short (1 << KEY_ESC)); |
||
840 | get_key_press(KEY_ALL); |
||
841 | } |
||
842 | |||
843 | //------------------------------------------------------- |
||
844 | if(type == 4) // led bitfeld |
||
845 | { |
||
846 | // TODO: Übersetzung |
||
847 | lcd_printp_at (0, 7, PSTR(" \x19 0\x11I Ende OK"), 0); |
||
848 | |||
849 | if (param == 93 || param == 94) |
||
850 | // lcd_printp_at (5, 6, PSTR("aktiv"), 0); |
||
851 | lcd_puts_at(5, 6, strGet(AKTIV), 0); |
||
852 | |||
853 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
854 | uint8_t newvalue = value; |
||
855 | uint8_t pos = 0; |
||
856 | |||
857 | do |
||
858 | { |
||
859 | |||
860 | for(ii = 0; ii < 8; ii++) |
||
861 | { |
||
862 | if(newvalue & (1 << ii)) |
||
863 | lcd_printp_at (8-ii, 4,PSTR("1"),0); |
||
864 | else |
||
865 | lcd_printp_at (8-ii, 4,PSTR("0"),0); |
||
866 | } |
||
867 | lcd_printp_at (pos+1, 5,PSTR("\x12"),0); |
||
868 | |||
869 | if(get_key_press (1 << KEY_MINUS)) |
||
870 | { |
||
871 | lcd_printp_at (pos+1, 5,PSTR(" "),0); |
||
872 | pos++; |
||
873 | if(pos == 8) |
||
874 | pos = 0; |
||
875 | } |
||
876 | |||
877 | if (param == 93 || param == 94) |
||
878 | { |
||
879 | if(get_key_long (1 << KEY_PLUS)) |
||
880 | { |
||
881 | if (newvalue != 0) |
||
882 | newvalue = 0; |
||
883 | else |
||
884 | newvalue = 170; |
||
885 | } |
||
886 | } |
||
887 | |||
888 | if(get_key_short (1 << KEY_PLUS)) |
||
889 | newvalue ^= (1<<(7-pos)); |
||
890 | |||
891 | if(get_key_short (1 << KEY_ENTER)) |
||
892 | { |
||
893 | if(newvalue != value) |
||
894 | { |
||
895 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
896 | changes = 1; |
||
897 | } |
||
898 | break; |
||
899 | } |
||
900 | } |
||
901 | while (!get_key_short (1 << KEY_ESC)); |
||
902 | get_key_press(KEY_ALL); |
||
903 | } |
||
904 | |||
905 | //------------------------------------------------------- |
||
906 | if(type == 5) // Angle |
||
907 | { |
||
908 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_2), 0); |
||
909 | lcd_puts_at(0, 7, strGet(KEYLINE2), 0); |
||
910 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
911 | |||
912 | lcd_ecircle(102, 35, 16, 1); |
||
913 | |||
914 | uint8_t newvalue = value; |
||
915 | uint8_t oldvalue = newvalue; |
||
916 | do |
||
917 | { |
||
918 | |||
919 | if(oldvalue != newvalue) lcd_ecirc_line (102, 35, 15, oldvalue*15, 0); |
||
920 | oldvalue = newvalue; |
||
921 | lcd_ecirc_line (102, 35, 15, newvalue*15, 1); |
||
922 | |||
923 | |||
924 | if(get_key_press (1 << KEY_PLUS) | get_key_long_rpt_sp ((1 << KEY_PLUS), 1)) |
||
925 | { |
||
926 | newvalue++; |
||
927 | if(newvalue == 24) |
||
928 | newvalue = 0; |
||
929 | } |
||
930 | if(get_key_press (1 << KEY_MINUS) | get_key_long_rpt_sp ((1 << KEY_MINUS), 1)) |
||
931 | { |
||
932 | if(newvalue == 0) |
||
933 | newvalue = 24; |
||
934 | newvalue--; |
||
935 | } |
||
936 | if(get_key_short (1 << KEY_ENTER)) |
||
937 | { |
||
938 | if(newvalue != value) |
||
939 | { |
||
940 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
941 | changes=1; |
||
942 | } |
||
943 | break; |
||
944 | } |
||
945 | } |
||
946 | while (!get_key_short (1 << KEY_ESC)); |
||
947 | get_key_press(KEY_ALL); |
||
948 | } |
||
949 | |||
950 | //------------------------------------------------------- |
||
951 | if(type == 6) // receiver |
||
952 | { |
||
953 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)); |
||
954 | |||
955 | uint8_t newvalue = value + 1; |
||
956 | uint8_t val =0; |
||
957 | uint8_t ii = 0; |
||
958 | uint8_t offset = 0; |
||
959 | uint8_t dmode = 0; |
||
960 | uint8_t target_pos = 1; |
||
961 | |||
962 | uint8_t size = ITEMS_RX; |
||
963 | |||
964 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
965 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
966 | |||
967 | while(1) |
||
968 | { |
||
969 | ii = 0; |
||
970 | if(offset > 0) |
||
971 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
972 | |||
973 | for(ii = 0;ii < 6 ; ii++) |
||
974 | { |
||
975 | if((ii+offset) < size) |
||
976 | lcd_printp_at(3,ii+1,param_items_rx[ii+offset], 0); |
||
977 | |||
978 | if((ii == 5)&&(ii+offset < (size-1))) |
||
979 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
980 | } |
||
981 | |||
982 | if(dmode == 0) |
||
983 | { |
||
984 | if(offset == 0) |
||
985 | { |
||
986 | if(size > 6) |
||
987 | val = menu_choose3 (1, 5, target_pos,0,1); //menu_choose3 (min, max, start, return_at_start, return_at_end) |
||
988 | else |
||
989 | val = menu_choose3 (1, size, target_pos,0,0); |
||
990 | } |
||
991 | else |
||
992 | val = menu_choose3 (2, 5, target_pos,1,1); |
||
993 | } |
||
994 | |||
995 | if(dmode == 1) |
||
996 | { |
||
997 | if(offset+7 > size) |
||
998 | val = menu_choose3 (2, 6, target_pos,1,0); |
||
999 | else |
||
1000 | val = menu_choose3 (2, 5, target_pos,1,1); |
||
1001 | } |
||
1002 | if(val == 254) // überlauf unten |
||
1003 | { |
||
1004 | offset++; |
||
1005 | dmode = 1; |
||
1006 | target_pos = 5; |
||
1007 | } |
||
1008 | else if(val == 253) // überlauf oben |
||
1009 | { |
||
1010 | offset--; |
||
1011 | dmode = 0; |
||
1012 | target_pos = 2; |
||
1013 | } |
||
1014 | else if(val == 252) // ESC |
||
1015 | return; |
||
1016 | else if(val <= size) |
||
1017 | { |
||
1018 | newvalue = val + offset - 1; |
||
1019 | *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*param)+4)) = newvalue; |
||
1020 | changes=1; |
||
1021 | return; |
||
1022 | } |
||
1023 | } |
||
1024 | } |
||
1025 | } |
||
1026 | |||
1027 | |||
1028 | //-------------------------------------------------------------- |
||
1029 | uint8_t display_param_menu(uint8_t group) |
||
1030 | { |
||
1031 | uint8_t items[20]; |
||
1032 | |||
1033 | uint8_t size=0; |
||
1034 | for(ii = 0;ii < PARAM_COUNT; ii++) |
||
1035 | { |
||
1036 | if(pgm_read_byte(param_config+(8*ii)) == (group-1)) |
||
1037 | { |
||
1038 | items[size] = ii; |
||
1039 | size++; |
||
1040 | } |
||
1041 | } |
||
1042 | |||
1043 | uint8_t val =0 ; |
||
1044 | |||
1045 | while(1) |
||
1046 | { |
||
1047 | lcd_cls (); |
||
1048 | // lcd_printp_at (0, 0, PSTR(" Wähle Parameter: "), 2); |
||
1049 | lcd_puts_at(0, 0, strGet(PARA_SELECT), 2); |
||
1050 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
1051 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
1052 | |||
1053 | ii = 0; |
||
1054 | if(offset2 > 0) |
||
1055 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
1056 | |||
1057 | for(ii = 0;ii < 6 ; ii++) |
||
1058 | { |
||
1059 | if((ii+offset2) < size) |
||
1060 | { |
||
1061 | lcd_printp_at(3,ii+1,param_names[items[ii+offset2]][DisplayLanguage], 0); |
||
1062 | // this reads the the offset in the struct from the pgm configuration table and then reads the value from the struct |
||
1063 | |||
1064 | uint8_t type = pgm_read_byte(param_config+(8*items[ii+offset2])+1); |
||
1065 | |||
1066 | if(type == 0) |
||
1067 | write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
||
1068 | |||
1069 | if(type == 1) |
||
1070 | { |
||
1071 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1072 | |||
1073 | if(value < 248) |
||
1074 | write_ndigit_number_u (18, ii+1, value, 3, 0); |
||
1075 | |||
1076 | if(value >= 248) |
||
1077 | { |
||
1078 | lcd_printp_at (18, ii+1, PSTR(" P"), 0); |
||
1079 | write_ndigit_number_u (20, ii+1, 256-value, 1, 0); |
||
1080 | } |
||
1081 | } |
||
1082 | |||
1083 | if(type == 2) |
||
1084 | { |
||
1085 | |||
1086 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1087 | uint8_t bitmap = pgm_read_byte(param_config+(8*items[ii+offset2])+3); |
||
1088 | if(value & bitmap) |
||
1089 | lcd_printp_at (18, ii+1, PSTR(" J"), 0); |
||
1090 | else |
||
1091 | lcd_printp_at (18, ii+1, PSTR(" N"), 0); |
||
1092 | |||
1093 | } |
||
1094 | |||
1095 | if(type == 3) |
||
1096 | { |
||
1097 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1098 | if (value<=12) |
||
1099 | write_ndigit_number_u (18, ii+1, value, 3, 0); |
||
1100 | else |
||
1101 | if (value<=(24)) |
||
1102 | { |
||
1103 | lcd_printp_at (18, ii+1, PSTR("S"), 0); |
||
1104 | write_ndigit_number_u (19, ii+1, (value-12), 2, 0); |
||
1105 | } |
||
1106 | |||
1107 | if (value==25) |
||
1108 | lcd_printp_at (18, ii+1, PSTR("WPE"), 0); |
||
1109 | |||
1110 | } |
||
1111 | |||
1112 | if(type == 4) |
||
1113 | write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
||
1114 | |||
1115 | if(type == 5) |
||
1116 | write_ndigit_number_u (18, ii+1, (*(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)))*15, 3, 0); |
||
1117 | |||
1118 | if(type == 6) // Empfänger Typ |
||
1119 | { |
||
1120 | uint8_t value = *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)); |
||
1121 | |||
1122 | if(value == 0) |
||
1123 | lcd_printp_at (18, ii+1, PSTR("PPM"), 0); |
||
1124 | else if(value == 1) |
||
1125 | lcd_printp_at (18, ii+1, PSTR("Spe"), 0); |
||
1126 | else if(value == 2) |
||
1127 | lcd_printp_at (18, ii+1, PSTR("SpH"), 0); |
||
1128 | else if(value == 3) |
||
1129 | lcd_printp_at (18, ii+1, PSTR("SpL"), 0); |
||
1130 | else if(value == 4) |
||
1131 | lcd_printp_at (18, ii+1, PSTR("Jet"), 0); |
||
1132 | else if(value == 5) |
||
1133 | lcd_printp_at (18, ii+1, PSTR("ACT"), 0); |
||
1134 | else if(value == 6) |
||
1135 | lcd_printp_at (18, ii+1, PSTR("HoT"), 0); |
||
1136 | else |
||
1137 | write_ndigit_number_u (18, ii+1, *(((uint8_t*)mk_param_struct) + pgm_read_byte(param_config+(8*items[ii+offset2])+4)), 3, 0); |
||
1138 | |||
1139 | } |
||
1140 | } |
||
1141 | |||
1142 | if((ii == 5)&&(ii+offset2 < (size-1))) |
||
1143 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
1144 | |||
1145 | } |
||
1146 | |||
1147 | if(pmode == 0) |
||
1148 | { |
||
1149 | if(offset2 == 0) |
||
1150 | { |
||
1151 | if(size > 6) |
||
1152 | val = menu_choose2 (1, 5, target_pos2,0,1); |
||
1153 | else |
||
1154 | val = menu_choose2 (1, size, target_pos2,0,0); |
||
1155 | |||
1156 | } |
||
1157 | else |
||
1158 | val = menu_choose2 (2, 5, target_pos2,1,1); |
||
1159 | |||
1160 | } |
||
1161 | if(pmode == 1) |
||
1162 | { |
||
1163 | if(offset2+7 > size) |
||
1164 | val = menu_choose2 (2, 6, target_pos2,1,0); |
||
1165 | else |
||
1166 | val = menu_choose2 (2, 5, target_pos2,1,1); |
||
1167 | |||
1168 | } |
||
1169 | |||
1170 | if(val == 254) |
||
1171 | { |
||
1172 | offset2++; |
||
1173 | pmode = 1; |
||
1174 | target_pos2 = 5; |
||
1175 | } |
||
1176 | else if(val == 253) |
||
1177 | { |
||
1178 | offset2--; |
||
1179 | pmode = 0; |
||
1180 | target_pos2 = 2; |
||
1181 | } |
||
1182 | else |
||
1183 | break; |
||
1184 | |||
1185 | } |
||
1186 | |||
1187 | if(val != 255) |
||
1188 | { |
||
1189 | target_pos2=val; |
||
1190 | return items[val+offset2-1]; |
||
1191 | } |
||
1192 | else |
||
1193 | return val; |
||
1194 | |||
1195 | } |
||
1196 | |||
1197 | |||
1198 | //-------------------------------------------------------------- |
||
1199 | uint8_t display_section_menu(void) |
||
1200 | { |
||
1201 | uint8_t size = PAGES; |
||
1202 | |||
1203 | uint8_t val =0; |
||
1204 | |||
1205 | |||
1206 | while(1) |
||
1207 | { |
||
1208 | lcd_cls (); |
||
1209 | // lcd_printp_at (0, 0, PSTR(" Wähle Seite: "), 2); |
||
1210 | lcd_puts_at(0, 7, strGet(PARA_SEITE),2); |
||
1211 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
1212 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
1213 | |||
1214 | ii = 0; |
||
1215 | if(offset > 0) |
||
1216 | lcd_printp_at(1,1, PSTR("\x12"), 0); |
||
1217 | |||
1218 | for(ii = 0;ii < 6 ; ii++) |
||
1219 | { |
||
1220 | if((ii+offset) < size) |
||
1221 | lcd_printp_at(3,ii+1,param_pages[ii+offset][DisplayLanguage], 0); |
||
1222 | |||
1223 | if((ii == 5)&&(ii+offset < (size-1))) |
||
1224 | lcd_printp_at(1,6, PSTR("\x13"), 0); |
||
1225 | |||
1226 | } |
||
1227 | |||
1228 | |||
1229 | |||
1230 | if(dmode == 0) |
||
1231 | { |
||
1232 | if(offset == 0) |
||
1233 | { |
||
1234 | if(size > 6) |
||
1235 | val = menu_choose2 (1, 5, target_pos,0,1); |
||
1236 | else |
||
1237 | val = menu_choose2 (1, size, target_pos,0,0); |
||
1238 | |||
1239 | } |
||
1240 | else |
||
1241 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
1242 | |||
1243 | } |
||
1244 | if(dmode == 1) |
||
1245 | { |
||
1246 | if(offset+7 > size) |
||
1247 | val = menu_choose2 (2, 6, target_pos,1,0); |
||
1248 | else |
||
1249 | val = menu_choose2 (2, 5, target_pos,1,1); |
||
1250 | |||
1251 | } |
||
1252 | |||
1253 | |||
1254 | if(val == 254) |
||
1255 | { |
||
1256 | offset++; |
||
1257 | dmode = 1; |
||
1258 | target_pos = 5; |
||
1259 | } |
||
1260 | else if(val == 253) |
||
1261 | { |
||
1262 | offset--; |
||
1263 | dmode = 0; |
||
1264 | target_pos = 2; |
||
1265 | } |
||
1266 | else |
||
1267 | break; |
||
1268 | |||
1269 | } |
||
1270 | |||
1271 | if(val != 255) |
||
1272 | { |
||
1273 | target_pos=val; |
||
1274 | return val+offset; |
||
1275 | } |
||
1276 | else |
||
1277 | return val; |
||
1278 | |||
1279 | } |
||
1280 | |||
1281 | |||
1282 | //-------------------------------------------------------------- |
||
1283 | uint8_t display_settings_menu (void) |
||
1284 | { |
||
1285 | uint8_t status; |
||
1286 | |||
1287 | lcd_cls (); |
||
1288 | |||
1289 | // lcd_printp_at (0, 0, PSTR(" Wähle Setting: "), 2); |
||
1290 | lcd_puts_at(0, 0, strGet(PARA_SELSETT), 2); |
||
1291 | // lcd_printp_at (0, 7, PSTR(KEY_LINE_1), 0); |
||
1292 | lcd_puts_at(0, 7, strGet(KEYLINE1), 0); |
||
1293 | |||
1294 | |||
1295 | for(setting=1;setting<6;setting++) |
||
1296 | { |
||
1297 | status = load_setting(setting); |
||
1298 | if(status == 255) |
||
1299 | return 255; |
||
1300 | |||
1301 | write_ndigit_number_u (3, setting, status, 1, 0); |
||
1302 | lcd_print_at (5,setting,(uint8_t*)mk_param_struct->Name, 0); |
||
1303 | } |
||
1304 | // lcd_printp_at (3, 6, PSTR("Kopiere Setting"), 0); |
||
1305 | lcd_puts_at(3, 6, strGet(PARA_COPY), 0); |
||
1306 | |||
1307 | status = load_setting(0xff); |
||
1308 | if(status == 255) |
||
1309 | return 255; |
||
1310 | |||
1311 | setting = menu_choose (1, 6, 1,status); |
||
1312 | |||
1313 | return setting; |
||
1314 | } |
||
1315 | |||
1316 | |||
1317 | //-------------------------------------------------------------- |
||
1318 | uint8_t load_setting(uint8_t setting) |
||
1319 | { |
||
1320 | mode = 'Q'; // Settings |
||
1321 | uint8_t timeout = 50; |
||
1322 | rxd_buffer_locked = FALSE; |
||
1323 | |||
1324 | while (!rxd_buffer_locked && timeout) |
||
1325 | { |
||
1326 | SendOutData ('q', ADDRESS_FC, 1, &setting, 1); |
||
1327 | // _delay_ms(50); |
||
1328 | timer = 20; |
||
1329 | while (timer > 0); |
||
1330 | timeout--; |
||
1331 | } |
||
1332 | |||
1333 | if (timeout != 0) |
||
1334 | { |
||
1335 | Decode64 (); |
||
1336 | setting = *pRxData; |
||
1337 | mk_param_struct = (mk_param_struct_t *) (pRxData + 1) ; |
||
1338 | } |
||
1339 | else |
||
1340 | { // timeout occured |
||
1341 | // lcd_printp_at (0, 2, PSTR("Fehler: keine Daten"), 0); |
||
1342 | lcd_puts_at(0, 2, strGet(OSD_ERROR), 0); |
||
1343 | timer = 100; |
||
1344 | while (timer > 0); |
||
1345 | setting = 255; |
||
1346 | } |
||
1347 | return setting; |
||
1348 | } |
||
1349 | |||
1350 | |||
1351 | //-------------------------------------------------------------- |
||
1352 | uint8_t write_setting(uint8_t setting) |
||
1353 | { |
||
1354 | mode = 'S'; // Settings |
||
1355 | uint8_t timeout = 50; |
||
1356 | rxd_buffer_locked = FALSE; |
||
1357 | |||
1358 | while (!rxd_buffer_locked && timeout) |
||
1359 | { |
||
1360 | SendOutData ('s', ADDRESS_FC, 2, &setting, 1, mk_param_struct, sizeof(mk_param_struct_t)); |
||
1361 | // _delay_ms(50); |
||
1362 | timer = 20; |
||
1363 | while (timer > 0); |
||
1364 | timeout--; |
||
1365 | } |
||
1366 | |||
1367 | if (timeout != 0) |
||
1368 | { |
||
1369 | Decode64 (); |
||
1370 | setting = *pRxData; |
||
1371 | } |
||
1372 | else // timeout occured |
||
1373 | { |
||
1374 | // lcd_printp_at (0, 2, PSTR("Fehler: keine Daten"), 0); |
||
1375 | lcd_puts_at(0, 2, strGet(OSD_ERROR), 0); |
||
1376 | timer = 100; |
||
1377 | while (timer > 0); |
||
1378 | setting = 255; |
||
1379 | } |
||
1380 | |||
1381 | return setting; |
||
1382 | } |
||
1383 | |||
1384 |