Rev 1731 | Rev 1740 | 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 |
||
100 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Current-12, Motor[1].Current-12, Motor[2].Current-12, Motor[3].Current-12); |
||
101 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Current-12, Motor[5].Current-12, Motor[6].Current-12, Motor[7].Current-12); |
||
102 | if(RequiredMotors <= 4) |
||
103 | { |
||
104 | JetiBox_printfxy(0,1,"Currents "); |
||
105 | } |
||
106 | else |
||
107 | if(RequiredMotors <= 6) |
||
108 | { |
||
109 | JetiBox_printfxy(8,1,"%3i.%1iA ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
||
110 | } |
||
1517 | killagreg | 111 | |
1739 | - | 112 | } |
113 | //1 |
||
114 | //1 |
||
115 | void Menu_SetPoint(uint8_t key) |
||
116 | { //0123456789ABCDEF |
||
117 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].SetPoint, Motor[1].SetPoint, Motor[2].SetPoint, Motor[3].SetPoint); |
||
118 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].SetPoint, Motor[5].SetPoint, Motor[6].SetPoint, Motor[7].SetPoint); |
||
119 | if(RequiredMotors <= 4) |
||
120 | { |
||
121 | JetiBox_printfxy(0,1,"M SetPoint "); |
||
122 | } |
||
123 | else |
||
124 | if(RequiredMotors <= 6) |
||
125 | { |
||
126 | JetiBox_printfxy(8,1,"MSetP "); |
||
127 | } |
||
128 | |||
129 | } |
||
130 | |||
131 | void Menu_Integal(uint8_t key) |
||
132 | { //0123456789ABCDEF |
||
133 | int r=0; |
||
134 | int n=0; |
||
135 | int g=0; |
||
136 | n=SummeNick >> 9; |
||
137 | r=SummeRoll >> 9; |
||
138 | g=Mess_Integral_Gier >> 9; |
||
139 | |||
140 | JetiBox_printfxy(0,0,"%3iN %3iR +N",n, r); |
||
141 | JetiBox_printfxy(0,1,"%3iG +R -N -R",g); |
||
142 | //1 |
||
143 | |||
144 | |||
145 | } |
||
146 | |||
147 | void Menu_Info(uint8_t key) |
||
148 | { //0123456789ABCDEF |
||
149 | |||
150 | JetiBox_printfxy(0,0,"%3i=Hovergas",HoverGas); |
||
151 | JetiBox_printfxy(0,1,"%3i=HG/4 %3i=Gas",HoverGas/4,StickGas); |
||
152 | } |
||
153 | |||
154 | void Menu_spoti1(uint8_t key) |
||
155 | { //0123456789ABCDEF |
||
156 | |||
157 | JetiBox_printfxy(0,0,">%3i=Serialpot1",PPM_in[13]); |
||
158 | JetiBox_printfxy(0,1," %3i=Serialpot2",PPM_in[14]); |
||
159 | if(key== JETIBOX_KEY_UP) PPM_in[13] = PPM_in[13]+1; |
||
160 | if(key== JETIBOX_KEY_DOWN) PPM_in[13] = PPM_in[13]-1; |
||
161 | } |
||
162 | |||
163 | void Menu_spoti2(uint8_t key) |
||
164 | { //0123456789ABCDEF |
||
165 | |||
166 | JetiBox_printfxy(0,0," %3i=Serialpot1",PPM_in[13]); |
||
167 | JetiBox_printfxy(0,1,">%3i=SPo %3i",PPM_in[14],key); |
||
168 | if(key== JETIBOX_KEY_UP) PPM_in[14] = PPM_in[14]+5; |
||
169 | if(key== JETIBOX_KEY_DOWN) PPM_in[14] = PPM_in[14]-5; |
||
170 | } |
||
171 | |||
172 | //#define JETIBOX_KEY_UP 0x2F |
||
173 | //#define JETIBOX_KEY_DOWN 0x4F |
||
174 | //1 |
||
175 | |||
176 | |||
177 | |||
1484 | killagreg | 178 | // ----------------------------------------------------------- |
179 | // the menu topology |
||
180 | // ----------------------------------------------------------- |
||
181 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
||
182 | |||
183 | typedef struct{ |
||
184 | int8_t left; |
||
185 | int8_t right; |
||
186 | int8_t up; |
||
187 | int8_t down; |
||
188 | pFctMenu pHandler; |
||
189 | } MENU_ENTRY; |
||
190 | |||
191 | |||
192 | // the menu navigation structure |
||
1517 | killagreg | 193 | /* | |
1484 | killagreg | 194 | |
1517 | killagreg | 195 | 3 - 0 - 1 - 2 - 3 - 0 |
196 | |||
1484 | killagreg | 197 | */ |
198 | |||
199 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
||
1739 | - | 200 | { // l r u d pHandler links rechts up down |
201 | {9, 1, 0, 0, &Menu_Status }, // 0 /// |
||
1693 | holgerb | 202 | {0, 2, 1, 1, &Menu_Temperature }, // 1 |
1517 | killagreg | 203 | {1, 3, 2, 2, &Menu_Battery }, // 2 |
1739 | - | 204 | {2, 4, 3, 3, &Menu_PosInfo }, // 3 |
205 | //1 |
||
206 | {3, 5, 4, 4, &Menu_Current }, // 4 /// |
||
207 | {4, 6, 5, 5, &Menu_SetPoint }, // 5 /// |
||
208 | {5, 7, 6, 6, &Menu_Integal }, // 6 /// |
||
209 | {6, 8, 7, 7, &Menu_Info }, // 7 /// |
||
210 | {7, 9, 8, 8, &Menu_spoti1 }, // 8 /// |
||
211 | {8, 0, 9, 9, &Menu_spoti2 }, // 9 /// |
||
212 | |||
213 | |||
214 | |||
215 | //1 |
||
1484 | killagreg | 216 | }; |
217 | |||
218 | // ----------------------------------------------------------- |
||
219 | // Update display buffer |
||
220 | // ----------------------------------------------------------- |
||
1583 | ingob | 221 | unsigned char JetiBox_Update(unsigned char key) |
1484 | killagreg | 222 | { |
223 | static uint8_t item = 0, last_item = 0; // the menu item |
||
224 | |||
225 | // navigate within the menu by key action |
||
226 | last_item = item; |
||
227 | switch(key) |
||
228 | { |
||
229 | case JETIBOX_KEY_LEFT: |
||
1583 | ingob | 230 | if (item == 0) return (1); // switch back to jeti expander menu |
231 | else item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
||
1484 | killagreg | 232 | break; |
233 | case JETIBOX_KEY_RIGHT: |
||
234 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
||
235 | break; |
||
236 | case JETIBOX_KEY_UP: |
||
1739 | - | 237 | |
238 | jetivalue1=jetivalue1+5; |
||
239 | |||
1484 | killagreg | 240 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
241 | break; |
||
242 | case JETIBOX_KEY_DOWN: |
||
1739 | - | 243 | |
244 | jetivalue1=jetivalue1-5; |
||
245 | |||
1484 | killagreg | 246 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
247 | break; |
||
248 | default: |
||
249 | break; |
||
250 | } |
||
251 | // if the menu item has been changed, do not pass the key to the item handler |
||
252 | // to avoid jumping over to items |
||
253 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
||
254 | |||
255 | LIBFC_JetiBox_Clear(); |
||
256 | //execute menu item handler |
||
257 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
||
1583 | ingob | 258 | |
259 | return (0); |
||
1484 | killagreg | 260 | } |
261 |