Subversion Repositories FlightCtrl

Rev

Rev 1917 | Rev 1920 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1917 Rev 1919
1
#include "libfc.h"
1
#include "libfc.h"
2
#include "printf_P.h"
2
#include "printf_P.h"
3
#include "main.h"
3
#include "main.h"
4
#include "spi.h"
4
#include "spi.h"
5
#include "capacity.h"
5
#include "capacity.h"
6
 
6
 
7
#define HoTT_printfxy(x,y,format, args...)  { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
7
#define HoTT_printfxy(x,y,format, args...)  { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
8
#define HoTT_printf(format, args...)        {  _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
8
#define HoTT_printf(format, args...)        {  _printf_P(&LIBFC_HoTT_Putchar, PSTR(format) , ## args);}
9
 
9
 
10
#define HoTT_printfxy_INV(x,y,format, args...)  { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
10
#define HoTT_printfxy_INV(x,y,format, args...)  { LIBFC_HoTT_SetPos(y * 21 + x); _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
11
#define HoTT_printf_INV(format, args...)        {  _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
11
#define HoTT_printf_INV(format, args...)        {  _printf_P(&LIBFC_HoTT_Putchar_INV, PSTR(format) , ## args);}
-
 
12
 
-
 
13
#define VOICE_MINIMALE_EINGANSSPANNUNG    16
-
 
14
#define VOICE_BEEP                         5
-
 
15
 
12
 
16
 
13
 
17
//---------------------------------------------------------------
14
void Hott_ClearLine(unsigned char line)
18
void Hott_ClearLine(unsigned char line)
15
{
19
{
16
 HoTT_printfxy(0,line,"                     ");
20
 HoTT_printfxy(0,line,"                     ");
17
}
21
}
-
 
22
//---------------------------------------------------------------
-
 
23
 
-
 
24
unsigned char HoTT_Waring(void)
-
 
25
{
-
 
26
  if(FC_StatusFlags & FC_STATUS_LOWBAT) return(VOICE_MINIMALE_EINGANSSPANNUNG);
-
 
27
  if(MotorenEin && NC_ErrorCode)                return(VOICE_BEEP);
-
 
28
  return(0);
-
 
29
}
-
 
30
 
-
 
31
//---------------------------------------------------------------
-
 
32
unsigned char HoTT_Telemety(unsigned char packet_request)
-
 
33
{
-
 
34
 switch(packet_request)
-
 
35
 {
-
 
36
  case HOTT_VARIO_PACKET_ID:
-
 
37
                VarioPacket.Altitude = HoehenWert + 500;  
-
 
38
                if (VarioPacket.Altitude < VarioPacket.MinAltitude) VarioPacket.MinAltitude = VarioPacket.Altitude;
-
 
39
                if (VarioPacket.Altitude > VarioPacket.MaxAltitude) VarioPacket.MaxAltitude = VarioPacket.Altitude;            
-
 
40
                VarioPacket.WarnBeep = HoTT_Waring();
-
 
41
                HoTT_DataPointer = (unsigned char *) &VarioPacket;
-
 
42
                return(sizeof(VarioPacket));
-
 
43
                break;
-
 
44
  case HOTT_GPS_PACKET_ID:
-
 
45
                GPSPacket.Altitude = HoehenWert  + 500 + 30;  
-
 
46
                GPSPacket.Hoehe  = GPSPacket.Altitude;
-
 
47
                GPSPacket.Distance = GPSInfo.HomeDistance/10;
-
 
48
                GPSPacket.Heading++;
-
 
49
                GPSPacket.WarnBeep = HoTT_Waring();
-
 
50
                HoTT_DataPointer = (unsigned char *) &GPSPacket;
-
 
51
                return(sizeof(GPSPacket));  
-
 
52
                break;
-
 
53
  case HOTT_ELECTRIC_AIR_PACKET_ID:
-
 
54
                ElectricAirPacket.Altitude++;
-
 
55
                ElectricAirPacket.Battery1++;
-
 
56
                ElectricAirPacket.Capacity++;
-
 
57
                ElectricAirPacket.WarnBeep = HoTT_Waring();
-
 
58
                HoTT_DataPointer = (unsigned char *) &ElectricAirPacket;
-
 
59
                return(sizeof(ElectricAirPacket));
-
 
60
                break;
-
 
61
  default: return(0);
-
 
62
  }            
-
 
63
}
-
 
64
 
18
 
65
//---------------------------------------------------------------
19
void HoTT_Menu(void)
66
void HoTT_Menu(void)
20
{
67
{
21
 static unsigned char what;
68
 static unsigned char what;
22
 switch(what++)
69
 switch(what++)
23
  {
70
  {
-
 
71
        case 0:  
24
        case 0:  HoTT_printfxy(0,0,"%2i.%1iV   ",UBat/10, UBat%10);
72
                        HoTT_printfxy(0,0,"%2i.%1iV   ",UBat/10, UBat%10);
-
 
73
                if(FC_StatusFlags & FC_STATUS_LOWBAT) HoTT_printfxy_INV(6,0,"!!",UBat/10, UBat%10);
25
                        HoTT_printfxy(8,0,"%4imAh %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60);
74
                        HoTT_printfxy(8,0,"%4imAh %2i:%02i",Capacity.UsedCapacity,FlugSekunden/60,FlugSekunden%60);
26
                        break;
75
                        break;
27
        case 1:  
76
        case 1:  
28
                        HoTT_printfxy(0,1,"Dir:%3d%c",(int)(ErsatzKompass / GIER_GRAD_FAKTOR), 0x60);
77
                        HoTT_printfxy(0,1,"DIR:%3d%c",(int)(ErsatzKompass / GIER_GRAD_FAKTOR), 0x60);
29
                        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
78
                        if(Parameter_GlobalConfig & CFG_HOEHENREGELUNG)
30
                                HoTT_printfxy_INV(10,1,"Alt:%4im %c", (int16_t)(HoehenWert/100),VarioCharacter)
79
                                HoTT_printfxy_INV(10,1,"ALT:%4im %c", (int16_t)(HoehenWert/100),VarioCharacter)
31
            else HoTT_printfxy(10,1,"Alt: ----    ", (int16_t)(HoehenWert/100),VarioCharacter);
80
            else HoTT_printfxy(10,1,"ALT: ----    ", (int16_t)(HoehenWert/100),VarioCharacter);
32
            break;
81
            break;
33
        case 2:
82
        case 2:
34
                        HoTT_printfxy(0,2,"I=%3i.%1iA %4iW ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10,Capacity.ActualPower);
83
                        HoTT_printfxy(0,2,"I=%3i.%1iA %4iW ",Capacity.ActualCurrent/10, Capacity.ActualCurrent%10,Capacity.ActualPower);
35
                        break;
84
                        break;
36
        case 3:
85
        case 3:
37
                        if(NaviDataOkay)
86
                        if(NaviDataOkay)
38
                        {
87
                        {
39
                          HoTT_printfxy(0,3,"Home:%3dm %3d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0x60);
88
                          HoTT_printfxy(0,3,"Home:%3dm %3d%c", GPSInfo.HomeDistance/10, GPSInfo.HomeBearing, 0x60);
40
            }
89
            }
41
                        else
90
                        else
42
                        {
91
                        {
43
                         Hott_ClearLine(3);
92
                         Hott_ClearLine(3);
44
                        }
93
                        }
45
                        break;
94
                        break;
46
        case 4:  
95
        case 4:  
47
                        if(NaviDataOkay)
96
                        if(NaviDataOkay)
48
                        {
97
                        {
49
                                HoTT_printfxy(0,4,"GPS:%2um/s Sat:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
98
                                HoTT_printfxy(0,4,"GPS:%2um/s SAT:%d ",GPSInfo.Speed,GPSInfo.NumOfSats);
50
                                switch (GPSInfo.SatFix)
99
                                switch (GPSInfo.SatFix)
51
                                {
100
                                {
52
                                        case SATFIX_3D:
101
                                        case SATFIX_3D:
53
                                                HoTT_printfxy(16,4,"  3D ");
102
                                                HoTT_printfxy(16,4,"  3D ");
54
                                                break;
103
                                                break;
55
               
104
               
56
                                        case SATFIX_2D:
105
                                        case SATFIX_2D:
57
                                        case SATFIX_NONE:
106
                                        case SATFIX_NONE:
58
                                        default:
107
                                        default:
59
                                                HoTT_printfxy(16,4,"NoFix");
108
                                                HoTT_printfxy(16,4,"NOFIX");
60
                                                break;
109
                                                break;
61
                                }      
110
                                }      
62
                                if(GPSInfo.Flags & FLAG_DIFFSOLN)
111
                                if(GPSInfo.Flags & FLAG_DIFFSOLN)
63
                                {
112
                                {
64
                                        HoTT_printfxy(16,4,"DGPS ");
113
                                        HoTT_printfxy(16,4,"DGPS ");
65
                                }
114
                                }
66
                        }
115
                        }
67
                        else
116
                        else
68
                        {                    //012345678901234567890
117
                        {                    //012345678901234567890
69
                                HoTT_printfxy(0,4,"No NaviCtrl!         ");
118
                                HoTT_printfxy(0,4,"No NaviCtrl!         ");
70
                        }
119
                        }
71
                        break;
120
                        break;
72
        case 5:
121
        case 5:
73
                        HoTT_printfxy(0,5,"%3i %3i %3i %3i%cC ", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature,0x60);
122
                        HoTT_printfxy(0,5,"%3i %3i %3i %3i%cC ", Motor[0].Temperature, Motor[1].Temperature, Motor[2].Temperature, Motor[3].Temperature,0x60);
74
                        break;
123
                        break;
75
        case 6:
124
        case 6:
76
                    if(RequiredMotors == 4) Hott_ClearLine(6);
125
                    if(RequiredMotors == 4) Hott_ClearLine(6);
77
                                else
126
                                else
78
                                if(RequiredMotors == 6)  HoTT_printfxy(0,6,"%3i %3i%cC         ", Motor[4].Temperature, Motor[5].Temperature,0x60)
127
                                if(RequiredMotors == 6)  HoTT_printfxy(0,6,"%3i %3i%cC         ", Motor[4].Temperature, Motor[5].Temperature,0x60)
79
                                else
128
                                else
80
                                if(RequiredMotors > 6)   HoTT_printfxy(0,6,"%3i %3i %3i %3i%cC ", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature,0x6D);
129
                                if(RequiredMotors > 6)   HoTT_printfxy(0,6,"%3i %3i %3i %3i%cC ", Motor[4].Temperature, Motor[5].Temperature, Motor[6].Temperature, Motor[7].Temperature,0x6D);
81
//HoTT_printfxy(0,6,"%2x:%c %2x:%c %c",Poti3,Poti3,Poti3+1,Poti3+1, 'A'+128);
130
//HoTT_printfxy(0,6,"%2x:%c %c %c %c %c %c %c %c ",Parameter_UserParam1,Parameter_UserParam1,Parameter_UserParam1+1,Parameter_UserParam1+2,Parameter_UserParam1+3,Parameter_UserParam1+4,Parameter_UserParam1+5,Parameter_UserParam1+6 ,Parameter_UserParam1+7 ,Parameter_UserParam1+8);
82
                        break;
131
                        break;
83
        case 7: if(NC_ErrorCode) HoTT_printfxy(0,7,"ERROR: %2d ",NC_ErrorCode)
132
        case 7: if(NC_ErrorCode) {Hott_ClearLine(7); HoTT_printfxy_INV(3,7,"ERROR: %2d ",NC_ErrorCode);}
84
                        else HoTT_printfxy(0,7," www.MikroKopter.de ");
133
                        else HoTT_printfxy(0,7," www.MikroKopter.de ");
85
                        break;
134
                        break;
-
 
135
 
86
        case 8:
136
        case 8: ASCIIPacket.WarnBeep = HoTT_Waring();
-
 
137
                        // ASCIIPacket.WarnBeep = Parameter_UserParam1;
87
        case 9:
138
        case 9:
88
        case 10:
139
        case 10:
89
        case 11:
140
        case 11:
90
        case 12:
141
        case 12:
91
        case 13:
142
        case 13:
92
        case 14:
143
        case 14:  
93
        case 15:
144
        case 15:  
94
        case 16:  break;
145
        case 16:  
-
 
146
                                break;
-
 
147
 
95
 
148
 
96
/*
149
/*
97
012345678901234567890
150
012345678901234567890
98
+++++++++++++++++++++
151
+++++++++++++++++++++
99
13,8V 1234mAh 12:30    0
152
13,8V 1234mAh 12:30    0
100
Dir:180° Alt: 123m +   1
153
Dir:180° Alt: 123m +   1
101
GPS: 10Sat DGPS PH CF  2
154
GPS: 10Sat DGPS PH CF  2
102
Home: 280° 123m        3
155
Home: 280° 123m        3
103
I=23A P=123W Max=123   4
156
I=23A P=123W Max=123   4
104
BL1-4: 11 22 33 44°C   5
157
BL1-4: 11 22 33 44°C   5
105
BL5-8: 55 66 77 88°C   6
158
BL5-8: 55 66 77 88°C   6
106
No Error               7
159
No Error               7
107
+++++++++++++++++++++
160
+++++++++++++++++++++
108
*/
161
*/
109
   default:  what = 0;
162
   default:  what = 0;
110
                        break;
163
                        break;
111
  }
164
  }
112
}
165
}
113
 
166
 
114
 
167
 
115
 
168
 
116
 
169
 
117
       
170
       
118
 
171