Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1484 | killagreg | 1 | #include "jetimenu.h" |
2 | #include "libfc.h" |
||
3 | #include "printf_P.h" |
||
4 | #include "main.h" |
||
5 | #include "spi.h" |
||
6 | |||
7 | #define JETIBOX_KEY_RIGHT 0x1F |
||
8 | #define JETIBOX_KEY_UP 0x2F |
||
9 | #define JETIBOX_KEY_DOWN 0x4F |
||
10 | #define JETIBOX_KEY_LEFT 0x8F |
||
11 | #define JETIBOX_KEY_NONE 0x0F |
||
12 | #define JETIBOX_KEY_UNDEF 0x00 |
||
13 | |||
14 | #define JetiBox_printfxy(x,y,format, args...) { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
||
15 | #define JetiBox_printf(format, args...) { _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
||
16 | |||
17 | // ----------------------------------------------------------- |
||
18 | // the menu functions |
||
19 | // ----------------------------------------------------------- |
||
20 | #define JETI_MENU_FCINFO 0 |
||
21 | void mf0(uint8_t key) |
||
22 | { |
||
23 | JetiBox_printfxy(0,0,"+ Flight-Ctrl + "); |
||
24 | JetiBox_printfxy(0,1,"HW:%d.%d SW:%d.%d%c",PlatinenVersion/10,PlatinenVersion%10,VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH+'a'); |
||
25 | } |
||
26 | #define JETI_MENU_VOLT_RC 1 |
||
27 | void mf1(uint8_t key) |
||
28 | { |
||
29 | JetiBox_printfxy(0,0,"Volt RC-Level"); |
||
30 | JetiBox_printfxy(0,1,"%2i.%1iV %03i",UBat/10, UBat%10, SenderOkay); |
||
31 | } |
||
32 | #define JETI_MENU_HEIGHT 2 |
||
33 | void mf2(uint8_t key) |
||
34 | { |
||
35 | JetiBox_printfxy(0,0,"Height Vario"); |
||
36 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
||
37 | { |
||
38 | JetiBox_printfxy(0,1,"%5i %5i", (int16_t)(HoehenWert/5), VarioMeter); |
||
39 | } |
||
40 | else |
||
41 | { |
||
42 | JetiBox_printfxy(0,1,"no press. sensor"); |
||
43 | } |
||
44 | } |
||
45 | #define JETI_MENU_ATTITUDE 3 |
||
46 | void mf3(uint8_t key) |
||
47 | { |
||
48 | JetiBox_printfxy(0,0,"Nick Roll Yaw"); |
||
49 | JetiBox_printfxy(0,1,"%4i %4i %4i", (int16_t)(IntegralNick/1024), (int16_t)(IntegralRoll/1024), (int16_t)(ErsatzKompass / GIER_GRAD_FAKTOR)); |
||
50 | } |
||
51 | #define JETI_MENU_NCINFO 4 |
||
52 | void mf4(uint8_t key) |
||
53 | { |
||
54 | JetiBox_printfxy(0,0," + Navi-Ctrl + "); |
||
55 | if(NaviDataOkay) |
||
56 | { |
||
57 | 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'); |
||
58 | } |
||
59 | else |
||
60 | { |
||
61 | JetiBox_printfxy(0,1," Not found! "); |
||
62 | } |
||
63 | } |
||
64 | #define JETI_MENU_GPSINFO 5 |
||
65 | void mf5(uint8_t key) |
||
66 | { |
||
67 | JetiBox_printfxy(0,0,"Sat:%02d", GPSInfo.NumOfSats); |
||
68 | switch (GPSInfo.SatFix) |
||
69 | { |
||
70 | case SATFIX_NONE: |
||
71 | JetiBox_printfxy(6,0,"NoFix"); |
||
72 | break; |
||
73 | case SATFIX_2D: |
||
74 | JetiBox_printfxy(6,0,"2DFix"); |
||
75 | break; |
||
76 | case SATFIX_3D: |
||
77 | JetiBox_printfxy(6,0,"3DFix"); |
||
78 | break; |
||
79 | default: |
||
80 | JetiBox_printfxy(6,0,"??Fix"); |
||
81 | break; |
||
82 | } |
||
83 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
||
84 | { |
||
85 | JetiBox_printfxy(11,0,"/DGPS"); |
||
86 | } |
||
87 | JetiBox_printfxy(0,1,"Home:%03dm %03d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF); |
||
88 | } |
||
89 | |||
90 | // ----------------------------------------------------------- |
||
91 | // the menu topology |
||
92 | // ----------------------------------------------------------- |
||
93 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
||
94 | |||
95 | typedef struct{ |
||
96 | int8_t left; |
||
97 | int8_t right; |
||
98 | int8_t up; |
||
99 | int8_t down; |
||
100 | pFctMenu pHandler; |
||
101 | } MENU_ENTRY; |
||
102 | |||
103 | |||
104 | // the menu navigation structure |
||
105 | /* |
||
106 | |||
107 | | | |
||
108 | 3 - 1 - 2 - 3 - 1 5 |
||
109 | |||
110 | */ |
||
111 | |||
112 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
||
113 | { // l r u d pHandler |
||
114 | {0, 4, 0, 1, &mf0 }, // 0 |
||
115 | {3, 2, 0, 1, &mf1 }, // 1 |
||
116 | {1, 3, 0, 2, &mf2 }, // 2 |
||
117 | {2, 1, 0, 3, &mf3 }, // 3 |
||
118 | {0, 4, 4, 5, &mf4 }, // 4 |
||
119 | {5, 5, 4, 5, &mf5 } // 5 |
||
120 | }; |
||
121 | |||
122 | |||
123 | // ----------------------------------------------------------- |
||
124 | // Update display buffer |
||
125 | // ----------------------------------------------------------- |
||
126 | void JetiBox_Update(unsigned char key) |
||
127 | { |
||
128 | static uint8_t item = 0, last_item = 0; // the menu item |
||
129 | |||
130 | // navigate within the menu by key action |
||
131 | last_item = item; |
||
132 | switch(key) |
||
133 | { |
||
134 | case JETIBOX_KEY_LEFT: |
||
135 | item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
||
136 | break; |
||
137 | case JETIBOX_KEY_RIGHT: |
||
138 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
||
139 | break; |
||
140 | case JETIBOX_KEY_UP: |
||
141 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
||
142 | break; |
||
143 | case JETIBOX_KEY_DOWN: |
||
144 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
||
145 | break; |
||
146 | default: |
||
147 | break; |
||
148 | } |
||
149 | // if the menu item has been changed, do not pass the key to the item handler |
||
150 | // to avoid jumping over to items |
||
151 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
||
152 | |||
153 | LIBFC_JetiBox_Clear(); |
||
154 | //execute menu item handler |
||
155 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
||
156 | } |
||
157 |