Rev 1692 | Rev 1694 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1692 | Rev 1693 | ||
---|---|---|---|
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 | } |
28 | } |
29 | else |
29 | else |
30 | { |
30 | { |
31 | JetiBox_printfxy(6,0,"Status"); |
31 | JetiBox_printfxy(6,0,"Status"); |
32 | } |
32 | } |
33 | JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
33 | JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
34 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
34 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
35 | { |
35 | { |
36 | JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter); |
36 | JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter); |
37 | } |
37 | } |
38 | } |
38 | } |
39 | 39 | ||
40 | void Menu_Attitude(uint8_t key) |
40 | void Menu_Temperature(uint8_t key) |
41 | { //0123456789ABCDEF |
- | |
42 | // JetiBox_printfxy(0,0,"Nick Roll Yaw"); |
- | |
43 | JetiBox_printfxy(0,1,"%4i %4i %4i", (int16_t)(IntegralNick/1024), (int16_t)(IntegralRoll/1024), (int16_t)(ErsatzKompass / GIER_GRAD_FAKTOR)); |
41 | { //0123456789ABCDEF |
44 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature); |
42 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature); |
45 | // JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature); |
43 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature); |
46 | if(RequiredMotors <= 4) |
44 | if(RequiredMotors <= 4) |
47 | { |
45 | { |
48 | JetiBox_printfxy(0,1,"Temperatures "); |
46 | JetiBox_printfxy(0,1,"Temperatures "); |
49 | //JetiBox_printfxy(0,0,"%3i ", Poti3); |
47 | //JetiBox_printfxy(0,0,"%3i ", Poti3); |
50 | //JetiBox_printfxy(0,1,"%3i %3i %3i %i ",HoverGas,DebugOut.Analog[16],DebugOut.Analog[17],DebugOut.Analog[18]); |
48 | //JetiBox_printfxy(0,1,"%3i %3i %3i %i ",HoverGas,DebugOut.Analog[26],DebugOut.Analog[17],DebugOut.Analog[18]); |
51 | } |
49 | } |
52 | else |
50 | else |
53 | if(RequiredMotors <= 6) |
51 | if(RequiredMotors <= 6) |
54 | { |
52 | { |
55 | JetiBox_printfxy(8,1,"\%cC ",0xdf); |
53 | JetiBox_printfxy(8,1,"\%cC ",0xdf); |
56 | } |
54 | } |
57 | 55 | ||
58 | } |
56 | } |
59 | 57 | ||
60 | void Menu_Battery(uint8_t key) |
58 | void Menu_Battery(uint8_t key) |
61 | { //0123456789ABCDEF |
59 | { //0123456789ABCDEF |
62 | JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
60 | JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
63 | JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity); |
61 | JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity); |
64 | } |
62 | } |
65 | 63 | ||
66 | 64 | ||
67 | void Menu_PosInfo(uint8_t key) |
65 | void Menu_PosInfo(uint8_t key) |
68 | { |
66 | { |
69 | if(NaviDataOkay) |
67 | if(NaviDataOkay) |
70 | { |
68 | { |
71 | JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats); |
69 | JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats); |
72 | switch (GPSInfo.SatFix) |
70 | switch (GPSInfo.SatFix) |
73 | { |
71 | { |
74 | case SATFIX_3D: |
72 | case SATFIX_3D: |
75 | JetiBox_printfxy(12,0," 3D"); |
73 | JetiBox_printfxy(12,0," 3D"); |
76 | break; |
74 | break; |
77 | 75 | ||
78 | case SATFIX_2D: |
76 | case SATFIX_2D: |
79 | case SATFIX_NONE: |
77 | case SATFIX_NONE: |
80 | default: |
78 | default: |
81 | JetiBox_printfxy(12,0,"NoFx"); |
79 | JetiBox_printfxy(12,0,"NoFx"); |
82 | break; |
80 | break; |
83 | } |
81 | } |
84 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
82 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
85 | { |
83 | { |
86 | JetiBox_printfxy(12,0,"DGPS"); |
84 | JetiBox_printfxy(12,0,"DGPS"); |
87 | } |
85 | } |
88 | JetiBox_printfxy(0,1,"Home:%3dm %3d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF); |
86 | JetiBox_printfxy(0,1,"Home:%3dm %3d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF); |
89 | } |
87 | } |
90 | else |
88 | else |
91 | { //0123456789ABCDEF |
89 | { //0123456789ABCDEF |
92 | JetiBox_printfxy(2,0,"No NaviCtrl!"); |
90 | JetiBox_printfxy(2,0,"No NaviCtrl!"); |
93 | } |
91 | } |
94 | } |
92 | } |
95 | 93 | ||
96 | 94 | ||
97 | // ----------------------------------------------------------- |
95 | // ----------------------------------------------------------- |
98 | // the menu topology |
96 | // the menu topology |
99 | // ----------------------------------------------------------- |
97 | // ----------------------------------------------------------- |
100 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
98 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
101 | 99 | ||
102 | typedef struct{ |
100 | typedef struct{ |
103 | int8_t left; |
101 | int8_t left; |
104 | int8_t right; |
102 | int8_t right; |
105 | int8_t up; |
103 | int8_t up; |
106 | int8_t down; |
104 | int8_t down; |
107 | pFctMenu pHandler; |
105 | pFctMenu pHandler; |
108 | } MENU_ENTRY; |
106 | } MENU_ENTRY; |
109 | 107 | ||
110 | 108 | ||
111 | // the menu navigation structure |
109 | // the menu navigation structure |
112 | /* | |
110 | /* | |
113 | 111 | ||
114 | 3 - 0 - 1 - 2 - 3 - 0 |
112 | 3 - 0 - 1 - 2 - 3 - 0 |
115 | 113 | ||
116 | */ |
114 | */ |
117 | 115 | ||
118 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
116 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
119 | { // l r u d pHandler |
117 | { // l r u d pHandler |
120 | {3, 1, 0, 0, &Menu_Status }, // 0 |
118 | {3, 1, 0, 0, &Menu_Status }, // 0 |
121 | {0, 2, 1, 1, &Menu_Attitude }, // 1 |
119 | {0, 2, 1, 1, &Menu_Temperature }, // 1 |
122 | {1, 3, 2, 2, &Menu_Battery }, // 2 |
120 | {1, 3, 2, 2, &Menu_Battery }, // 2 |
123 | {2, 0, 3, 3, &Menu_PosInfo }, // 3 |
121 | {2, 0, 3, 3, &Menu_PosInfo }, // 3 |
124 | }; |
122 | }; |
125 | 123 | ||
126 | // ----------------------------------------------------------- |
124 | // ----------------------------------------------------------- |
127 | // Update display buffer |
125 | // Update display buffer |
128 | // ----------------------------------------------------------- |
126 | // ----------------------------------------------------------- |
129 | unsigned char JetiBox_Update(unsigned char key) |
127 | unsigned char JetiBox_Update(unsigned char key) |
130 | { |
128 | { |
131 | static uint8_t item = 0, last_item = 0; // the menu item |
129 | static uint8_t item = 0, last_item = 0; // the menu item |
132 | 130 | ||
133 | // navigate within the menu by key action |
131 | // navigate within the menu by key action |
134 | last_item = item; |
132 | last_item = item; |
135 | switch(key) |
133 | switch(key) |
136 | { |
134 | { |
137 | case JETIBOX_KEY_LEFT: |
135 | case JETIBOX_KEY_LEFT: |
138 | if (item == 0) return (1); // switch back to jeti expander menu |
136 | if (item == 0) return (1); // switch back to jeti expander menu |
139 | else item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
137 | else item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
140 | break; |
138 | break; |
141 | case JETIBOX_KEY_RIGHT: |
139 | case JETIBOX_KEY_RIGHT: |
142 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
140 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
143 | break; |
141 | break; |
144 | case JETIBOX_KEY_UP: |
142 | case JETIBOX_KEY_UP: |
145 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
143 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
146 | break; |
144 | break; |
147 | case JETIBOX_KEY_DOWN: |
145 | case JETIBOX_KEY_DOWN: |
148 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
146 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
149 | break; |
147 | break; |
150 | default: |
148 | default: |
151 | break; |
149 | break; |
152 | } |
150 | } |
153 | // if the menu item has been changed, do not pass the key to the item handler |
151 | // if the menu item has been changed, do not pass the key to the item handler |
154 | // to avoid jumping over to items |
152 | // to avoid jumping over to items |
155 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
153 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
156 | 154 | ||
157 | LIBFC_JetiBox_Clear(); |
155 | LIBFC_JetiBox_Clear(); |
158 | //execute menu item handler |
156 | //execute menu item handler |
159 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
157 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
160 | 158 | ||
161 | return (0); |
159 | return (0); |
162 | } |
160 | } |
163 | 161 | ||
164 | 162 |