Subversion Repositories FlightCtrl

Rev

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