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