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