Rev 1740 | Rev 1749 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1484 | killagreg | 1 | #include "jetimenu.h" |
2 | #include "libfc.h" |
||
3 | #include "printf_P.h" |
||
4 | #include "main.h" |
||
5 | #include "spi.h" |
||
1500 | killagreg | 6 | #include "capacity.h" |
1484 | killagreg | 7 | |
8 | #define JETIBOX_KEY_RIGHT 0x1F |
||
9 | #define JETIBOX_KEY_UP 0x2F |
||
10 | #define JETIBOX_KEY_DOWN 0x4F |
||
11 | #define JETIBOX_KEY_LEFT 0x8F |
||
12 | #define JETIBOX_KEY_NONE 0x0F |
||
13 | #define JETIBOX_KEY_UNDEF 0x00 |
||
14 | |||
15 | #define JetiBox_printfxy(x,y,format, args...) { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
||
16 | #define JetiBox_printf(format, args...) { _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
||
17 | |||
18 | // ----------------------------------------------------------- |
||
19 | // the menu functions |
||
20 | // ----------------------------------------------------------- |
||
1517 | killagreg | 21 | |
22 | void Menu_Status(uint8_t key) |
||
23 | { //0123456789ABCDEF |
||
1512 | holgerb | 24 | JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10); |
25 | if(NaviDataOkay) |
||
1484 | killagreg | 26 | { |
1694 | holgerb | 27 | // JetiBox_printfxy(6,0,"%03dm %03d%c", GPSInfo.HomeDistance/10,GPSInfo.HomeBearing, 0xDF); |
28 | JetiBox_printfxy(6,0,"%3d%c %03dm",(int)(ErsatzKompass / GIER_GRAD_FAKTOR), 0xDF, GPSInfo.HomeDistance/10); |
||
1484 | killagreg | 29 | } |
1517 | killagreg | 30 | else |
31 | { |
||
1591 | holgerb | 32 | JetiBox_printfxy(6,0,"Status"); |
1517 | killagreg | 33 | } |
1703 | holgerb | 34 | if(NC_ErrorCode) JetiBox_printfxy(6,0,"ERROR: %2d",NC_ErrorCode); |
1591 | holgerb | 35 | JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
1517 | killagreg | 36 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
37 | { |
||
1591 | holgerb | 38 | JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter); |
1517 | killagreg | 39 | } |
40 | } |
||
1512 | holgerb | 41 | |
1705 | holgerb | 42 | |
1693 | holgerb | 43 | void Menu_Temperature(uint8_t key) |
1517 | killagreg | 44 | { //0123456789ABCDEF |
1687 | holgerb | 45 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature); |
1693 | holgerb | 46 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature); |
1690 | holgerb | 47 | if(RequiredMotors <= 4) |
48 | { |
||
49 | JetiBox_printfxy(0,1,"Temperatures "); |
||
50 | } |
||
51 | else |
||
52 | if(RequiredMotors <= 6) |
||
53 | { |
||
54 | JetiBox_printfxy(8,1,"\%cC ",0xdf); |
||
55 | } |
||
1692 | holgerb | 56 | |
1484 | killagreg | 57 | } |
1517 | killagreg | 58 | |
59 | void Menu_Battery(uint8_t key) |
||
1500 | killagreg | 60 | { //0123456789ABCDEF |
1529 | killagreg | 61 | JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
1739 | - | 62 | //1 |
63 | JetiBox_printfxy(0,1,"%4iW %6imAH",Capacity.ActualPower, Capacity.UsedCapacity); |
||
64 | //1 |
||
1500 | killagreg | 65 | } |
66 | |||
1680 | holgerb | 67 | |
1517 | killagreg | 68 | void Menu_PosInfo(uint8_t key) |
1484 | killagreg | 69 | { |
70 | if(NaviDataOkay) |
||
71 | { |
||
1690 | holgerb | 72 | JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats); |
1517 | killagreg | 73 | switch (GPSInfo.SatFix) |
74 | { |
||
1690 | holgerb | 75 | case SATFIX_3D: |
76 | JetiBox_printfxy(12,0," 3D"); |
||
1517 | killagreg | 77 | break; |
1690 | holgerb | 78 | |
1517 | killagreg | 79 | case SATFIX_2D: |
1690 | holgerb | 80 | case SATFIX_NONE: |
1517 | killagreg | 81 | default: |
1690 | holgerb | 82 | JetiBox_printfxy(12,0,"NoFx"); |
1517 | killagreg | 83 | break; |
84 | } |
||
85 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
||
86 | { |
||
1690 | holgerb | 87 | JetiBox_printfxy(12,0,"DGPS"); |
1517 | killagreg | 88 | } |
1690 | holgerb | 89 | JetiBox_printfxy(0,1,"Home:%3dm %3d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF); |
1484 | killagreg | 90 | } |
91 | else |
||
1517 | killagreg | 92 | { //0123456789ABCDEF |
93 | JetiBox_printfxy(2,0,"No NaviCtrl!"); |
||
1484 | killagreg | 94 | } |
95 | } |
||
96 | |||
1739 | - | 97 | //1 |
98 | void Menu_Current(uint8_t key) |
||
99 | { //0123456789ABCDEF |
||
1517 | killagreg | 100 | |
1742 | - | 101 | |
102 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Current-12, Motor[1].Current-12, Motor[2].Current-12, Motor[3].Current-12); |
||
103 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Current-12, Motor[5].Current-12, Motor[6].Current-12, Motor[7].Current-12); |
||
104 | if(RequiredMotors <= 4) |
||
105 | { |
||
106 | JetiBox_printfxy(0,1,"Currents "); |
||
107 | } |
||
108 | else |
||
109 | if(RequiredMotors <= 6) |
||
110 | { |
||
111 | JetiBox_printfxy(8,1,"%3i.%1iA ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
||
112 | } |
||
113 | |||
114 | |||
1739 | - | 115 | } |
116 | //1 |
||
117 | //1 |
||
118 | void Menu_SetPoint(uint8_t key) |
||
119 | { //0123456789ABCDEF |
||
120 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].SetPoint, Motor[1].SetPoint, Motor[2].SetPoint, Motor[3].SetPoint); |
||
121 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].SetPoint, Motor[5].SetPoint, Motor[6].SetPoint, Motor[7].SetPoint); |
||
122 | if(RequiredMotors <= 4) |
||
123 | { |
||
124 | JetiBox_printfxy(0,1,"M SetPoint "); |
||
125 | } |
||
126 | else |
||
127 | if(RequiredMotors <= 6) |
||
128 | { |
||
129 | JetiBox_printfxy(8,1,"MSetP "); |
||
130 | } |
||
131 | |||
132 | } |
||
133 | |||
134 | void Menu_Integal(uint8_t key) |
||
135 | { //0123456789ABCDEF |
||
136 | int r=0; |
||
137 | int n=0; |
||
138 | int g=0; |
||
139 | n=SummeNick >> 9; |
||
140 | r=SummeRoll >> 9; |
||
141 | g=Mess_Integral_Gier >> 9; |
||
142 | |||
143 | JetiBox_printfxy(0,0,"%3iN %3iR +N",n, r); |
||
144 | JetiBox_printfxy(0,1,"%3iG +R -N -R",g); |
||
145 | //1 |
||
146 | |||
147 | |||
148 | } |
||
149 | |||
150 | void Menu_Info(uint8_t key) |
||
151 | { //0123456789ABCDEF |
||
152 | |||
153 | JetiBox_printfxy(0,0,"%3i=Hovergas",HoverGas); |
||
154 | JetiBox_printfxy(0,1,"%3i=HG/4 %3i=Gas",HoverGas/4,StickGas); |
||
155 | } |
||
156 | |||
157 | void Menu_spoti1(uint8_t key) |
||
158 | { //0123456789ABCDEF |
||
159 | |||
160 | JetiBox_printfxy(0,0,">%3i=Serialpot1",PPM_in[13]); |
||
161 | JetiBox_printfxy(0,1," %3i=Serialpot2",PPM_in[14]); |
||
162 | if(key== JETIBOX_KEY_UP) PPM_in[13] = PPM_in[13]+1; |
||
163 | if(key== JETIBOX_KEY_DOWN) PPM_in[13] = PPM_in[13]-1; |
||
164 | } |
||
165 | |||
166 | void Menu_spoti2(uint8_t key) |
||
167 | { //0123456789ABCDEF |
||
168 | |||
169 | JetiBox_printfxy(0,0," %3i=Serialpot1",PPM_in[13]); |
||
1740 | - | 170 | JetiBox_printfxy(0,1,">%3i=Serialpot2",PPM_in[14],key); |
1739 | - | 171 | if(key== JETIBOX_KEY_UP) PPM_in[14] = PPM_in[14]+5; |
172 | if(key== JETIBOX_KEY_DOWN) PPM_in[14] = PPM_in[14]-5; |
||
173 | } |
||
1742 | - | 174 | void Menu_hoeheD(uint8_t key) |
175 | { //0123456789ABCDEF |
||
1739 | - | 176 | |
1742 | - | 177 | JetiBox_printfxy(0,0,">%3i=HD",EE_Parameter.Luftdruck_D); |
178 | JetiBox_printfxy(0,1," %3i=HP",EE_Parameter.Hoehe_P); |
||
179 | if(key== JETIBOX_KEY_UP) EE_Parameter.Luftdruck_D = EE_Parameter.Luftdruck_D+1; |
||
180 | if(key== JETIBOX_KEY_DOWN) EE_Parameter.Luftdruck_D = EE_Parameter.Luftdruck_D-1; |
||
181 | } |
||
182 | void Menu_hoeheP(uint8_t key) |
||
183 | { //0123456789ABCDEF |
||
184 | |||
185 | JetiBox_printfxy(0,0," %3i=HD",EE_Parameter.Luftdruck_D); |
||
186 | JetiBox_printfxy(0,1,">%3i=HP",EE_Parameter.Hoehe_P); |
||
187 | if(key== JETIBOX_KEY_UP) EE_Parameter.Hoehe_P = EE_Parameter.Hoehe_P+1; |
||
188 | if(key== JETIBOX_KEY_DOWN) EE_Parameter.Hoehe_P = EE_Parameter.Hoehe_P-1; |
||
189 | } |
||
1739 | - | 190 | //#define JETIBOX_KEY_UP 0x2F |
191 | //#define JETIBOX_KEY_DOWN 0x4F |
||
1742 | - | 192 | //unsigned char Parameter_Luftdruck_D = 48; // Wert : 0-250 |
193 | //unsigned char Parameter_Hoehe_P = 16; // Wert : 0-32 |
||
194 | //CHK_POTI_MM(Parameter_Luftdruck_D,EE_Parameter.Luftdruck_D,0,100); |
||
195 | //CHK_POTI_MM(Parameter_Hoehe_P,EE_Parameter.Hoehe_P,0,100); |
||
1739 | - | 196 | //1 |
1484 | killagreg | 197 | // ----------------------------------------------------------- |
198 | // the menu topology |
||
199 | // ----------------------------------------------------------- |
||
200 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
||
201 | |||
202 | typedef struct{ |
||
203 | int8_t left; |
||
204 | int8_t right; |
||
205 | int8_t up; |
||
206 | int8_t down; |
||
207 | pFctMenu pHandler; |
||
208 | } MENU_ENTRY; |
||
209 | |||
210 | |||
211 | // the menu navigation structure |
||
1517 | killagreg | 212 | /* | |
1484 | killagreg | 213 | |
1517 | killagreg | 214 | 3 - 0 - 1 - 2 - 3 - 0 |
215 | |||
1484 | killagreg | 216 | */ |
217 | |||
218 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
||
1739 | - | 219 | { // l r u d pHandler links rechts up down |
1742 | - | 220 | {11, 1, 0, 0, &Menu_Status }, // 0 /// |
1693 | holgerb | 221 | {0, 2, 1, 1, &Menu_Temperature }, // 1 |
1517 | killagreg | 222 | {1, 3, 2, 2, &Menu_Battery }, // 2 |
1739 | - | 223 | {2, 4, 3, 3, &Menu_PosInfo }, // 3 |
224 | //1 |
||
225 | {3, 5, 4, 4, &Menu_Current }, // 4 /// |
||
226 | {4, 6, 5, 5, &Menu_SetPoint }, // 5 /// |
||
227 | {5, 7, 6, 6, &Menu_Integal }, // 6 /// |
||
228 | {6, 8, 7, 7, &Menu_Info }, // 7 /// |
||
229 | {7, 9, 8, 8, &Menu_spoti1 }, // 8 /// |
||
1742 | - | 230 | {8, 10, 9, 9, &Menu_spoti2 }, // 9 /// |
231 | {9, 11, 10, 10, &Menu_hoeheD }, // 10 /// |
||
232 | {10, 0, 11, 11, &Menu_hoeheP }, // 11 /// |
||
1739 | - | 233 | |
234 | //1 |
||
1484 | killagreg | 235 | }; |
236 | |||
237 | // ----------------------------------------------------------- |
||
238 | // Update display buffer |
||
239 | // ----------------------------------------------------------- |
||
1583 | ingob | 240 | unsigned char JetiBox_Update(unsigned char key) |
1484 | killagreg | 241 | { |
242 | static uint8_t item = 0, last_item = 0; // the menu item |
||
243 | |||
244 | // navigate within the menu by key action |
||
245 | last_item = item; |
||
246 | switch(key) |
||
247 | { |
||
248 | case JETIBOX_KEY_LEFT: |
||
1583 | ingob | 249 | if (item == 0) return (1); // switch back to jeti expander menu |
250 | else item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
||
1484 | killagreg | 251 | break; |
252 | case JETIBOX_KEY_RIGHT: |
||
253 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
||
254 | break; |
||
1742 | - | 255 | case JETIBOX_KEY_UP: |
1484 | killagreg | 256 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
257 | break; |
||
258 | case JETIBOX_KEY_DOWN: |
||
259 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
||
260 | break; |
||
261 | default: |
||
262 | break; |
||
263 | } |
||
264 | // if the menu item has been changed, do not pass the key to the item handler |
||
265 | // to avoid jumping over to items |
||
266 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
||
267 | |||
268 | LIBFC_JetiBox_Clear(); |
||
269 | //execute menu item handler |
||
270 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
||
1583 | ingob | 271 | |
272 | return (0); |
||
1484 | killagreg | 273 | } |
274 |