Rev 1928 | Go to most recent revision | Details | Compare with Previous | 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" |
||
1500 | killagreg | 6 | #include "capacity.h" |
1930 | holgerb | 7 | #include "hottmenu.h" |
1484 | killagreg | 8 | |
9 | #define JETIBOX_KEY_RIGHT 0x1F |
||
10 | #define JETIBOX_KEY_UP 0x2F |
||
11 | #define JETIBOX_KEY_DOWN 0x4F |
||
12 | #define JETIBOX_KEY_LEFT 0x8F |
||
13 | #define JETIBOX_KEY_NONE 0x0F |
||
14 | #define JETIBOX_KEY_UNDEF 0x00 |
||
15 | |||
16 | #define JetiBox_printfxy(x,y,format, args...) { LIBFC_JetiBox_SetPos(y * 16 + x); _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
||
17 | #define JetiBox_printf(format, args...) { _printf_P(&LIBFC_JetiBox_Putchar, PSTR(format) , ## args);} |
||
18 | |||
19 | // ----------------------------------------------------------- |
||
20 | // the menu functions |
||
21 | // ----------------------------------------------------------- |
||
1517 | killagreg | 22 | void Menu_Status(uint8_t key) |
23 | { //0123456789ABCDEF |
||
1512 | holgerb | 24 | JetiBox_printfxy(0,0,"%2i.%1iV",UBat/10, UBat%10); |
25 | if(NaviDataOkay) |
||
1484 | killagreg | 26 | { |
1923 | holgerb | 27 | JetiBox_printfxy(6,0,"%3d%c %03dm%c",KompassValue, 0xDF, GPSInfo.HomeDistance/10,NC_GPS_ModeCharacter); |
1484 | killagreg | 28 | } |
1517 | killagreg | 29 | else |
30 | { |
||
1591 | holgerb | 31 | JetiBox_printfxy(6,0,"Status"); |
1517 | killagreg | 32 | } |
1930 | holgerb | 33 | |
34 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
||
35 | if(NC_ErrorCode) |
||
36 | { |
||
37 | static unsigned int timer; |
||
38 | static char toggle = 1; |
||
39 | |||
40 | if(CheckDelay(timer)) { if(toggle) toggle = 0; else toggle = 1; timer = SetDelay(1500);}; |
||
41 | if(toggle) |
||
42 | { |
||
43 | LIBFC_JetiBox_SetPos(0); |
||
44 | _printf_P(&LIBFC_JetiBox_Putchar, NC_ERROR_TEXT[NC_ErrorCode] , 0); |
||
45 | } |
||
46 | else |
||
47 | { |
||
48 | JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); |
||
49 | JetiBeep = 'O'; |
||
50 | } |
||
51 | } |
||
52 | #else |
||
53 | if(NC_ErrorCode) { JetiBox_printfxy(6,0,"ERROR: %2d ",NC_ErrorCode); JetiBeep = 'O';}; |
||
54 | #endif |
||
1591 | holgerb | 55 | JetiBox_printfxy(0,1,"%4i %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60); |
1916 | holgerb | 56 | if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG) |
1517 | killagreg | 57 | { |
1591 | holgerb | 58 | JetiBox_printfxy(10,1,"%4im%c", (int16_t)(HoehenWert/100),VarioCharacter); |
1517 | killagreg | 59 | } |
60 | } |
||
1512 | holgerb | 61 | |
1705 | holgerb | 62 | |
1693 | holgerb | 63 | void Menu_Temperature(uint8_t key) |
1517 | killagreg | 64 | { //0123456789ABCDEF |
1687 | holgerb | 65 | JetiBox_printfxy(0,0,"%3i %3i %3i %3i", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature); |
1693 | holgerb | 66 | JetiBox_printfxy(0,1,"%3i %3i %3i %3i", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature); |
1690 | holgerb | 67 | if(RequiredMotors <= 4) |
68 | { |
||
69 | JetiBox_printfxy(0,1,"Temperatures "); |
||
70 | } |
||
71 | else |
||
72 | if(RequiredMotors <= 6) |
||
73 | { |
||
74 | JetiBox_printfxy(8,1,"\%cC ",0xdf); |
||
75 | } |
||
1692 | holgerb | 76 | |
1484 | killagreg | 77 | } |
1517 | killagreg | 78 | |
79 | void Menu_Battery(uint8_t key) |
||
1500 | killagreg | 80 | { //0123456789ABCDEF |
1529 | killagreg | 81 | JetiBox_printfxy(0,0,"%2i.%1iV %3i.%1iA", UBat/10, UBat%10, Capacity.ActualCurrent/10, Capacity.ActualCurrent%10); |
82 | JetiBox_printfxy(0,1,"%4iW %6imAh",Capacity.ActualPower, Capacity.UsedCapacity); |
||
1500 | killagreg | 83 | } |
84 | |||
1680 | holgerb | 85 | |
1517 | killagreg | 86 | void Menu_PosInfo(uint8_t key) |
1484 | killagreg | 87 | { |
88 | if(NaviDataOkay) |
||
89 | { |
||
1690 | holgerb | 90 | JetiBox_printfxy(0,0,"%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats); |
1517 | killagreg | 91 | switch (GPSInfo.SatFix) |
92 | { |
||
1690 | holgerb | 93 | case SATFIX_3D: |
94 | JetiBox_printfxy(12,0," 3D"); |
||
1517 | killagreg | 95 | break; |
1690 | holgerb | 96 | |
1517 | killagreg | 97 | case SATFIX_2D: |
1690 | holgerb | 98 | case SATFIX_NONE: |
1517 | killagreg | 99 | default: |
1690 | holgerb | 100 | JetiBox_printfxy(12,0,"NoFx"); |
1517 | killagreg | 101 | break; |
102 | } |
||
103 | if(GPSInfo.Flags & FLAG_DIFFSOLN) |
||
104 | { |
||
1690 | holgerb | 105 | JetiBox_printfxy(12,0,"DGPS"); |
1517 | killagreg | 106 | } |
1923 | holgerb | 107 | JetiBox_printfxy(0,1,"Home:%3dm %3d%c %c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0xDF,NC_GPS_ModeCharacter); |
1484 | killagreg | 108 | } |
109 | else |
||
1517 | killagreg | 110 | { //0123456789ABCDEF |
111 | JetiBox_printfxy(2,0,"No NaviCtrl!"); |
||
1484 | killagreg | 112 | } |
113 | } |
||
114 | |||
1517 | killagreg | 115 | |
1484 | killagreg | 116 | // ----------------------------------------------------------- |
117 | // the menu topology |
||
118 | // ----------------------------------------------------------- |
||
119 | typedef void (*pFctMenu) (uint8_t); // the menu item handler function pointer |
||
120 | |||
121 | typedef struct{ |
||
122 | int8_t left; |
||
123 | int8_t right; |
||
124 | int8_t up; |
||
125 | int8_t down; |
||
126 | pFctMenu pHandler; |
||
127 | } MENU_ENTRY; |
||
128 | |||
129 | |||
130 | // the menu navigation structure |
||
1517 | killagreg | 131 | /* | |
1484 | killagreg | 132 | |
1517 | killagreg | 133 | 3 - 0 - 1 - 2 - 3 - 0 |
134 | |||
1484 | killagreg | 135 | */ |
136 | |||
137 | const MENU_ENTRY JetiBox_Menu[] PROGMEM= |
||
138 | { // l r u d pHandler |
||
1517 | killagreg | 139 | {3, 1, 0, 0, &Menu_Status }, // 0 |
1693 | holgerb | 140 | {0, 2, 1, 1, &Menu_Temperature }, // 1 |
1517 | killagreg | 141 | {1, 3, 2, 2, &Menu_Battery }, // 2 |
142 | {2, 0, 3, 3, &Menu_PosInfo }, // 3 |
||
1484 | killagreg | 143 | }; |
144 | |||
145 | // ----------------------------------------------------------- |
||
146 | // Update display buffer |
||
147 | // ----------------------------------------------------------- |
||
1583 | ingob | 148 | unsigned char JetiBox_Update(unsigned char key) |
1484 | killagreg | 149 | { |
150 | static uint8_t item = 0, last_item = 0; // the menu item |
||
151 | |||
152 | // navigate within the menu by key action |
||
153 | last_item = item; |
||
154 | switch(key) |
||
155 | { |
||
156 | case JETIBOX_KEY_LEFT: |
||
1583 | ingob | 157 | if (item == 0) return (1); // switch back to jeti expander menu |
158 | else item = pgm_read_byte(&JetiBox_Menu[item].left); //trigger to left menu item |
||
1484 | killagreg | 159 | break; |
160 | case JETIBOX_KEY_RIGHT: |
||
161 | item = pgm_read_byte(&JetiBox_Menu[item].right); //trigger to right menu item |
||
162 | break; |
||
163 | case JETIBOX_KEY_UP: |
||
164 | item = pgm_read_byte(&JetiBox_Menu[item].up); //trigger to up menu item |
||
165 | break; |
||
166 | case JETIBOX_KEY_DOWN: |
||
167 | item = pgm_read_byte(&JetiBox_Menu[item].down); //trigger to down menu item |
||
168 | break; |
||
169 | default: |
||
170 | break; |
||
171 | } |
||
172 | // if the menu item has been changed, do not pass the key to the item handler |
||
173 | // to avoid jumping over to items |
||
174 | if(item != last_item) key = JETIBOX_KEY_UNDEF; |
||
175 | |||
176 | LIBFC_JetiBox_Clear(); |
||
177 | //execute menu item handler |
||
178 | ((pFctMenu)(pgm_read_word(&(JetiBox_Menu[item].pHandler))))(key); |
||
1583 | ingob | 179 | |
180 | return (0); |
||
1484 | killagreg | 181 | } |
182 |