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