Subversion Repositories FlightCtrl

Rev

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