Rev 1984 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1984 | Rev 2013 | ||
---|---|---|---|
1 | #include "jetimenu.h" |
1 | #include "jetimenu.h" |
2 | #include "libfc.h" |
2 | #include "libfc.h" |
3 | #include "printf_P.h" |
3 | #include "printf_P.h" |
4 | #include "main.h" |
4 | #include "main.h" |
5 | #include "spi.h" |
5 | #include "spi.h" |
6 | #include "capacity.h" |
6 | #include "capacity.h" |
7 | #include "hottmenu.h" |
7 | #include "hottmenu.h" |
8 | 8 | ||
9 | #define JETIBOX_KEY_RIGHT 0x1F |
9 | #define JETIBOX_KEY_RIGHT 0x1F |
10 | #define JETIBOX_KEY_UP 0x2F |
10 | #define JETIBOX_KEY_UP 0x2F |
11 | #define JETIBOX_KEY_DOWN 0x4F |
11 | #define JETIBOX_KEY_DOWN 0x4F |
12 | #define JETIBOX_KEY_LEFT 0x8F |
12 | #define JETIBOX_KEY_LEFT 0x8F |
13 | #define JETIBOX_KEY_NONE 0x0F |
13 | #define JETIBOX_KEY_NONE 0x0F |
14 | #define JETIBOX_KEY_UNDEF 0x00 |
14 | #define JETIBOX_KEY_UNDEF 0x00 |
15 | 15 | ||
16 | #define JetiBox_printfxy(x,y,format, args...) { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
16 | #define JetiBox_printfxy(x,y,format, args...) { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
17 | #define JetiBox_printf(format, args...) { _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
17 | #define JetiBox_printf(format, args...) { _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
18 | 18 | ||
19 | // ----------------------------------------------------------- |
19 | // ----------------------------------------------------------- |
20 | // the menu functions |
20 | // the menu functions |
21 | // ----------------------------------------------------------- |
21 | // ----------------------------------------------------------- |
22 | void Menu_Status(uint8_t key) |
22 | void Menu_Status(uint8_t key) |
23 | { //0123456789ABCDEF |
23 | { //0123456789ABCDEF |
24 | JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10); |
24 | JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10); |
25 | if(NaviDataOkay) |
25 | if(NaviDataOkay) |
26 | { |
26 | { |
27 | JetiBox_printfxy(6,0,"%3d%c %03dm%c",ErsatzKompassInGrad, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter); |
27 | JetiBox_printfxy(6,0,"%3d%c %03dm%c",ErsatzKompassInGrad, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter); |
28 | } |
28 | } |
29 | else |
29 | else |
30 | { |
30 | { |
31 | JetiBox_printfxy(6,0,"Status"); |
31 | JetiBox_printfxy(6,0,"Status"); |
32 | } |
32 | } |
33 | 33 | ||
34 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
34 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
35 | if(NC_ErrorCode) |
35 | if(NC_ErrorCode) |
36 | { |
36 | { |
37 | static unsigned int timer; |
37 | static unsigned int timer; |
38 | static char toggle = 1; |
38 | static char toggle = 1; |
39 | 39 | ||
40 | if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);}; |
40 | if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);}; |
41 | if(toggle) |
41 | if(toggle) |
42 | { |
42 | { |
43 | LIBFC_JetiBox_SetPos(0); |
43 | LIBFC_JetiBox_SetPos(0); |
44 | _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0); |
44 | _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0); |
45 | } |
45 | } |
46 | else |
46 | else |
47 | { |
47 | { |
48 | JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); |
48 | JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); |
49 | if(MotorenEin) JetiBeep = 'O'; |
49 | if(MotorenEin) JetiBeep = 'O'; |
50 | } |
50 | } |
51 | } |
51 | } |
52 | #else |
52 | #else |
53 | if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'O';}; |
53 | if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); if(MotorenEin) JetiBeep = 'O';}; |
54 | #endif |
54 | #endif |
55 | JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
55 | JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
56 | if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG) |
56 | if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG) |
57 | { |
57 | { |
58 | JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter); |
58 | JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter); |
59 | } |
59 | } |
60 | } |
60 | } |
61 | 61 | ||
62 | 62 | ||
63 | void Menu_Temperature(uint8_t key) |
63 | void Menu_Temperature(uint8_t key) |
64 | { //0123456789ABCDEF |
64 | { //0123456789ABCDEF |
65 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature); |
65 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature); |
66 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature); |
66 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature); |
67 | if(RequiredMotors <= 4) |
67 | if(RequiredMotors <= 4) |
68 | { |
68 | { |
69 | JetiBox_printfxy(0,1,"Temperatures "); |
69 | JetiBox_printfxy(0,1,"Temperatures "); |
70 | } |
70 | } |
71 | else |
71 | else |
72 | if(RequiredMotors <= 6) |
72 | if(RequiredMotors <= 6) |
73 | { |
73 | { |
74 | JetiBox_printfxy(8,1,"\%cC ",0xdf); |
74 | JetiBox_printfxy(8,1,"\%cC ",0xdf); |
75 | } |
75 | } |
76 | 76 | ||
77 | } |
77 | } |
78 | 78 | ||
79 | void Menu_Battery(uint8_t key) |
79 | void Menu_Battery(uint8_t key) |
80 | { //0123456789ABCDEF |
80 | { //0123456789ABCDEF |
81 | JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
81 | JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
82 | JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity); |
82 | JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity); |
83 | } |
83 | } |
84 | 84 | ||
85 | void Magnet_Values(uint8_t key) |
85 | void Magnet_Values(uint8_t key) |
86 | { //0123456789ABCDEF |
86 | { //0123456789ABCDEF |
87 | JetiBox_printfxy(0,0,"Magnet:%3i%% %3i%c",EarthMagneticField, KompassValue,0xDF); |
87 | JetiBox_printfxy(0,0,"Magnet:%3i%% %3i%c",EarthMagneticField, KompassValue,0xDF); |
88 | JetiBox_printfxy(0,1,"Incli.:%3i%c (%i) ",EarthMagneticInclination, 0xDF,EarthMagneticInclinationTheoretic); |
88 | JetiBox_printfxy(0,1,"Incli.:%3i%c (%i) ",EarthMagneticInclination, 0xDF,EarthMagneticInclinationTheoretic); |
89 | } |
89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void Menu_PosInfo(uint8_t key) |
92 | void Menu_PosInfo(uint8_t key) |
93 | { |
93 | { |
94 | if(NaviDataOkay) |
94 | if(NaviDataOkay) |
95 | { |
95 | { |
96 | JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats); |
96 | JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats); |
97 | switch (GPSInfo.SatFix) |
97 | switch (GPSInfo.SatFix) |
98 | { |
98 | { |
99 | case SATFIX_3D: |
99 | case SATFIX_3D: |
100 | JetiBox_printfxy(12,0," 3D"); |
100 | JetiBox_printfxy(12,0," 3D"); |
101 | break; |
101 | break; |
102 | // case SATFIX_2D: |
102 | // case SATFIX_2D: |
103 | // case SATFIX_NONE: |
103 | // case SATFIX_NONE: |
104 | default: |
104 | default: |
105 | JetiBox_printfxy(12,0,"NoFx"); |
105 | JetiBox_printfxy(12,0,"NoFx"); |
106 | break; |
106 | break; |
107 | } |
107 | } |
108 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
108 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
109 | { |
109 | { |
110 | JetiBox_printfxy(12,0,"DGPS"); |
110 | JetiBox_printfxy(12,0,"DGPS"); |
111 | } |
111 | } |
112 | JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter); |
112 | JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter); |
113 | } |
113 | } |
114 | else |
114 | else |
115 | { //0123456789ABCDEF |
115 | { //0123456789ABCDEF |
116 | JetiBox_printfxy(2,0,"No NaviCtrl!"); |
116 | JetiBox_printfxy(2,0,"No NaviCtrl!"); |
117 | } |
117 | } |
118 | } |
118 | } |
119 | 119 | ||
- | 120 | ||
- | 121 | // MartinR für Jeti+ Anfang |
|
- | 122 | void Menu_spoti1(uint8_t key) |
|
- | 123 | { //0123456789ABCDEF |
|
- | 124 | ||
- | 125 | JetiBox_printfxy(0,0,">%3i=Serialpot1",PPM_in[13]); |
|
- | 126 | //JetiBox_printfxy(0,1," %3i=Serialpot2",PPM_in[14]); |
|
- | 127 | if(key== JETIBOX_KEY_UP) PPM_in[13] = PPM_in[13]+25; |
|
- | 128 | if(key== JETIBOX_KEY_DOWN) PPM_in[13] = PPM_in[13]-25; |
|
- | 129 | } |
|
- | 130 | ||
- | 131 | void Menu_spoti2(uint8_t key) |
|
- | 132 | { //0123456789ABCDEF |
|
- | 133 | ||
- | 134 | //JetiBox_printfxy(0,0," %3i=Serialpot1",PPM_in[13]); |
|
- | 135 | JetiBox_printfxy(0,1,">%3i=Serialpot2",PPM_in[14]); |
|
- | 136 | if(key== JETIBOX_KEY_UP) PPM_in[14] = PPM_in[14]+2; |
|
- | 137 | if(key== JETIBOX_KEY_DOWN) PPM_in[14] = PPM_in[14]-2; |
|
- | 138 | } |
|
- | 139 | ||
- | 140 | // MartinR für Jeti+ Ende |
|
120 | 141 | ||
121 | // ----------------------------------------------------------- |
142 | // ----------------------------------------------------------- |
122 | // the menu topology |
143 | // the menu topology |
123 | // ----------------------------------------------------------- |
144 | // ----------------------------------------------------------- |
124 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
145 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
125 | 146 | ||
126 | typedef struct{ |
147 | typedef struct{ |
127 | int8_t left; |
148 | int8_t left; |
128 | int8_t right; |
149 | int8_t right; |
129 | int8_t up; |
150 | int8_t up; |
130 | int8_t down; |
151 | int8_t down; |
131 | pFctMenu pHandler; |
152 | pFctMenu pHandler; |
132 | } MENU_ENTRY; |
153 | } MENU_ENTRY; |
133 | 154 | ||
134 | 155 | ||
135 | // the menu navigation structure |
156 | // the menu navigation structure |
136 | /* | |
157 | /* | |
137 | 158 | ||
138 | 3 - 0 - 1 - 2 - 3 - 0 |
159 | 3 - 0 - 1 - 2 - 3 - 0 |
139 | 160 | ||
140 | */ |
161 | */ |
141 | 162 | ||
142 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
163 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
143 | { // l r u d pHandler |
164 | { // l r u d pHandler |
- | 165 | //{4, 1, 0, 0, &Menu_Status }, // 0 // MartinR: so war es |
|
144 | {4, 1, 0, 0, &Menu_Status }, // 0 |
166 | {6, 1, 0, 0, &Menu_Status }, // 0 // MartinR: geändert |
145 | {0, 2, 1, 1, &Menu_Temperature }, // 1 |
167 | {0, 2, 1, 1, &Menu_Temperature }, // 1 |
146 | {1, 3, 2, 2, &Menu_Battery }, // 2 |
168 | {1, 3, 2, 2, &Menu_Battery }, // 2 |
147 | {2, 4, 3, 3, &Menu_PosInfo }, // 3 |
169 | {2, 4, 3, 3, &Menu_PosInfo }, // 3 |
148 | {3, 0, 4, 4, &Magnet_Values } // 4 |
170 | //{3, 0, 4, 4, &Magnet_Values } // 4 // MartinR: so war es |
- | 171 | {3, 5, 4, 4, &Magnet_Values }, // 4 // MartinR: geändert |
|
- | 172 | ||
- | 173 | {4, 6, 5, 5, &Menu_spoti1 }, // 5 // MartinR: für Jeti+ |
|
- | 174 | {5, 0, 6, 6, &Menu_spoti2 }, // 6 // MartinR: für Jeti+ |
|
- | 175 | ||
149 | }; |
176 | }; |
150 | 177 | ||
151 | // ----------------------------------------------------------- |
178 | // ----------------------------------------------------------- |
152 | // Update display buffer |
179 | // Update display buffer |
153 | // ----------------------------------------------------------- |
180 | // ----------------------------------------------------------- |
154 | unsigned char JetiBox_Update(unsigned char key) |
181 | unsigned char JetiBox_Update(unsigned char key) |
155 | { |
182 | { |
156 | static uint8_t item = 0, last_item = 0; // the menu item |
183 | static uint8_t item = 0, last_item = 0; // the menu item |
157 | 184 | ||
158 | // navigate within the menu by key action |
185 | // navigate within the menu by key action |
159 | last_item = item; |
186 | last_item = item; |
160 | switch(key) |
187 | switch(key) |
161 | { |
188 | { |
162 | case JETIBOX_KEY_LEFT: |
189 | case JETIBOX_KEY_LEFT: |
163 | //if (item == 0) return (1); // switch back to jeti expander menu |
190 | //if (item == 0) return (1); // switch back to jeti expander menu |
164 | // else |
191 | // else |
165 | item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
192 | item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
166 | break; |
193 | break; |
167 | case JETIBOX_KEY_RIGHT: |
194 | case JETIBOX_KEY_RIGHT: |
168 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
195 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
169 | break; |
196 | break; |
170 | case JETIBOX_KEY_UP: |
197 | case JETIBOX_KEY_UP: |
171 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
198 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
172 | break; |
199 | break; |
173 | case JETIBOX_KEY_DOWN: |
200 | case JETIBOX_KEY_DOWN: |
174 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
201 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
175 | break; |
202 | break; |
176 | default: |
203 | default: |
177 | break; |
204 | break; |
178 | } |
205 | } |
179 | // if the menu item has been changed, do not pass the key to the item handler |
206 | // if the menu item has been changed, do not pass the key to the item handler |
180 | // to avoid jumping over to items |
207 | // to avoid jumping over to items |
181 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
208 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
182 | 209 | ||
183 | LIBFC_JetiBox_Clear(); |
210 | LIBFC_JetiBox_Clear(); |
184 | //execute menu item handler |
211 | //execute menu item handler |
185 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
212 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
186 | 213 | ||
187 | return (0); |
214 | return (0); |
188 | } |
215 | } |
189 | 216 | ||
190 | 217 |