Rev 1500 | Rev 1517 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1500 | Rev 1512 | ||
---|---|---|---|
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 | #define JETI_MENU_FCINFO 0 |
21 | #define JETI_MENU_FCINFO 0 |
22 | void mfc0(uint8_t key) |
22 | void mfc0(uint8_t key) |
23 | { |
23 | { |
24 | JetiBox_printfxy(0,0,"+ Flight-Ctrl + "); |
24 | JetiBox_printfxy(0,0,"+ Flight-Ctrl + "); |
25 | JetiBox_printfxy(0,1,"HW:%d.%d SW:%d.%d%c",PlatinenVersion/10,PlatinenVersion%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
25 | JetiBox_printfxy(0,1,"HW:%d.%d SW:%d.%d%c",PlatinenVersion/10,PlatinenVersion%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
26 | } |
26 | } |
- | 27 | /* |
|
27 | #define JETI_MENU_VOLT_RC 1 |
28 | #define JETI_MENU_VOLT_RC 1 |
28 | void mfc1(uint8_t key) |
29 | void mfc1(uint8_t key) |
29 | { |
30 | { |
30 | JetiBox_printfxy(0,0,"Volt RC-Level"); |
31 | JetiBox_printfxy(0,0,"Volt RC-Level"); |
31 | JetiBox_printfxy(0,1,"%2i.%1iV %03i",UBat/10, UBat%10, SenderOkay); |
32 | JetiBox_printfxy(0,1,"%2i.%1iV %03i",UBat/10, UBat%10, SenderOkay); |
32 | } |
33 | } |
- | 34 | */ |
|
33 | #define JETI_MENU_HEIGHT 2 |
35 | #define JETI_MENU_HEIGHT 2 |
34 | void mfc2(uint8_t key) |
36 | void mfc2(uint8_t key) |
35 | { |
37 | { |
36 | JetiBox_printfxy(0,0,"Height Vario"); |
- | |
37 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
38 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
38 | { |
39 | { |
39 | JetiBox_printfxy(0,1,"%5i %5i", (int16_t)(HoehenWert/5), VarioMeter); |
40 | JetiBox_printfxy(11,1,"%4im", (int16_t)(HoehenWert/100)); |
40 | } |
41 | } |
- | 42 | JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10); |
|
41 | else |
43 | |
- | 44 | JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
|
- | 45 | if(NaviDataOkay) |
|
42 | { |
46 | { |
43 | JetiBox_printfxy(0,1,"no press. sensor"); |
47 | JetiBox_printfxy(7,0,"%03dm %03d%c", GPSInfo.HomeDistance/10,GPSInfo.HomeBearing, 0xDF); |
44 | } |
48 | } |
- | 49 | else |
|
- | 50 | JetiBox_printfxy(7,0,"Status"); |
|
- | 51 | ||
45 | } |
52 | } |
46 | #define JETI_MENU_ATTITUDE 3 |
53 | #define JETI_MENU_ATTITUDE 3 |
47 | void mfc3(uint8_t key) |
54 | void mfc3(uint8_t key) |
48 | { |
55 | { |
49 | JetiBox_printfxy(0,0,"Nick Roll Yaw"); |
56 | JetiBox_printfxy(0,0,"Nick Roll Yaw"); |
50 | JetiBox_printfxy(0,1,"%4i %4i %4i", (int16_t)(IntegralNick/1024), (int16_t)(IntegralRoll/1024), (int16_t)(ErsatzKompass / GIER_GRAD_FAKTOR)); |
57 | JetiBox_printfxy(0,1,"%4i %4i %4i", (int16_t)(IntegralNick/1024), (int16_t)(IntegralRoll/1024), (int16_t)(ErsatzKompass / GIER_GRAD_FAKTOR)); |
51 | } |
58 | } |
52 | #define JETI_MENU_AKKU 4 |
59 | #define JETI_MENU_AKKU 4 |
53 | void mfc4(uint8_t key) |
60 | void mfc4(uint8_t key) |
54 | { //0123456789ABCDEF |
61 | { //0123456789ABCDEF |
55 | JetiBox_printfxy(0,0,"U[V] I[A] C[mAh]"); |
62 | JetiBox_printfxy(0,0," [V] [A] [mAh]"); |
56 | JetiBox_printfxy(0,1,"%2i.%1i %2i.%1i %6i",UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10, Capacity.UsedCapacity); |
63 | JetiBox_printfxy(0,1,"%2i.%1i %2i.%1i %6i",UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10, Capacity.UsedCapacity); |
57 | } |
64 | } |
58 | 65 | ||
59 | 66 | ||
60 | #define JETI_MENU_NCINFO 4 |
67 | #define JETI_MENU_NCINFO 5 |
61 | void mnc1(uint8_t key) |
68 | void mnc1(uint8_t key) |
62 | { |
69 | { |
63 | JetiBox_printfxy(1,0,"+ Navi-Ctrl +"); |
70 | JetiBox_printfxy(1,0,"+ Navi-Ctrl +"); |
64 | if(NaviDataOkay) |
71 | if(NaviDataOkay) |
65 | { |
72 | { |
66 | JetiBox_printfxy(0,1,"HW:%d.%d SW:%d.%d%c",NC_Version.Hardware/10,NC_Version.Hardware%10,NC_Version.Major, NC_Version.Minor, NC_Version.Patch+'a'); |
73 | JetiBox_printfxy(0,1,"HW:%d.%d SW:%d.%d%c",NC_Version.Hardware/10,NC_Version.Hardware%10,NC_Version.Major, NC_Version.Minor, NC_Version.Patch+'a'); |
67 | } |
74 | } |
68 | else |
75 | else |
69 | { |
76 | { |
70 | JetiBox_printfxy(0,1," Not found! "); |
77 | JetiBox_printfxy(0,1," Not found! "); |
71 | } |
78 | } |
72 | } |
79 | } |
73 | #define JETI_MENU_GPSINFO 5 |
80 | #define JETI_MENU_GPSINFO 6 |
74 | void mnc2(uint8_t key) |
81 | void mnc2(uint8_t key) |
75 | { |
82 | { |
76 | JetiBox_printfxy(0,0,"Sat:%02d", GPSInfo.NumOfSats); |
83 | JetiBox_printfxy(0,0,"Sat:%02d", GPSInfo.NumOfSats); |
77 | switch (GPSInfo.SatFix) |
84 | switch (GPSInfo.SatFix) |
78 | { |
85 | { |
79 | case SATFIX_NONE: |
86 | case SATFIX_NONE: |
80 | JetiBox_printfxy(6,0,"NoFix"); |
87 | JetiBox_printfxy(6,0,"NoFix"); |
81 | break; |
88 | break; |
82 | case SATFIX_2D: |
89 | case SATFIX_2D: |
83 | JetiBox_printfxy(6,0,"2DFix"); |
90 | JetiBox_printfxy(6,0,"2DFix"); |
84 | break; |
91 | break; |
85 | case SATFIX_3D: |
92 | case SATFIX_3D: |
86 | JetiBox_printfxy(6,0,"3DFix"); |
93 | JetiBox_printfxy(6,0,"3DFix"); |
87 | break; |
94 | break; |
88 | default: |
95 | default: |
89 | JetiBox_printfxy(6,0,"??Fix"); |
96 | JetiBox_printfxy(6,0,"??Fix"); |
90 | break; |
97 | break; |
91 | } |
98 | } |
92 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
99 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
93 | { |
100 | { |
94 | JetiBox_printfxy(11,0,"/DGPS"); |
101 | JetiBox_printfxy(11,0,"/DGPS"); |
95 | } |
102 | } |
96 | JetiBox_printfxy(0,1,"Home:%03dm %03d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF); |
103 | JetiBox_printfxy(0,1,"Home:%03dm %03d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF); |
97 | } |
104 | } |
98 | 105 | ||
99 | // ----------------------------------------------------------- |
106 | // ----------------------------------------------------------- |
100 | // the menu topology |
107 | // the menu topology |
101 | // ----------------------------------------------------------- |
108 | // ----------------------------------------------------------- |
102 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
109 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
103 | 110 | ||
104 | typedef struct{ |
111 | typedef struct{ |
105 | int8_t left; |
112 | int8_t left; |
106 | int8_t right; |
113 | int8_t right; |
107 | int8_t up; |
114 | int8_t up; |
108 | int8_t down; |
115 | int8_t down; |
109 | pFctMenu pHandler; |
116 | pFctMenu pHandler; |
110 | } MENU_ENTRY; |
117 | } MENU_ENTRY; |
111 | 118 | ||
112 | 119 | ||
113 | // the menu navigation structure |
120 | // the menu navigation structure |
114 | /* |
121 | /* |
115 | 0 ----------------------------- 5 |
122 | 0 ----------------------------- 5 |
116 | | | |
123 | | | |
117 | 4 - 1 - 2 - 3 - 4 - 1 6 |
124 | 4 - 1 - 2 - 3 - 4 - 1 6 |
118 | 125 | ||
119 | */ |
126 | */ |
120 | 127 | ||
121 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
128 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
122 | { // l r u d pHandler |
129 | { // l r u d pHandler |
123 | {0, 5, 0, 1, &mfc0 }, // 0 |
130 | {0, 4, 0, 1, &mfc0 }, // 0 |
124 | {4, 2, 0, 1, &mfc1 }, // 1 |
131 | {0, 3, 0, 1, &mfc2 }, // 1 |
125 | {1, 3, 0, 2, &mfc2 }, // 2 |
132 | {1, 3, 0, 2, &mfc3 }, // 2 |
126 | {2, 4, 0, 3, &mfc3 }, // 3 |
133 | {2, 0, 0, 3, &mfc4 }, // 3 |
127 | {3, 1, 0, 4, &mfc4 }, // 4 |
- | |
128 | {0, 5, 5, 6, &mnc1 }, // 5 |
134 | {0, 4, 4, 5, &mnc1 }, // 4 |
129 | {6, 6, 5, 6, &mnc2 } // 6 |
135 | {5, 5, 4, 6, &mnc2 } // 5 |
130 | }; |
136 | }; |
131 | 137 | ||
132 | 138 | ||
133 | // ----------------------------------------------------------- |
139 | // ----------------------------------------------------------- |
134 | // Update display buffer |
140 | // Update display buffer |
135 | // ----------------------------------------------------------- |
141 | // ----------------------------------------------------------- |
136 | void JetiBox_Update(unsigned char key) |
142 | void JetiBox_Update(unsigned char key) |
137 | { |
143 | { |
138 | static uint8_t item = 0, last_item = 0; // the menu item |
144 | static uint8_t item = 0, last_item = 0; // the menu item |
139 | 145 | ||
140 | // navigate within the menu by key action |
146 | // navigate within the menu by key action |
141 | last_item = item; |
147 | last_item = item; |
142 | switch(key) |
148 | switch(key) |
143 | { |
149 | { |
144 | case JETIBOX_KEY_LEFT: |
150 | case JETIBOX_KEY_LEFT: |
145 | item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
151 | item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
146 | break; |
152 | break; |
147 | case JETIBOX_KEY_RIGHT: |
153 | case JETIBOX_KEY_RIGHT: |
148 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
154 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
149 | break; |
155 | break; |
150 | case JETIBOX_KEY_UP: |
156 | case JETIBOX_KEY_UP: |
151 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
157 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
152 | break; |
158 | break; |
153 | case JETIBOX_KEY_DOWN: |
159 | case JETIBOX_KEY_DOWN: |
154 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
160 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
155 | break; |
161 | break; |
156 | default: |
162 | default: |
157 | break; |
163 | break; |
158 | } |
164 | } |
159 | // if the menu item has been changed, do not pass the key to the item handler |
165 | // if the menu item has been changed, do not pass the key to the item handler |
160 | // to avoid jumping over to items |
166 | // to avoid jumping over to items |
161 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
167 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
162 | 168 | ||
163 | LIBFC_JetiBox_Clear(); |
169 | LIBFC_JetiBox_Clear(); |
164 | //execute menu item handler |
170 | //execute menu item handler |
165 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
171 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
166 | } |
172 | } |
167 | 173 | ||
168 | 174 |