Rev 687 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 687 | Rev 690 | ||
---|---|---|---|
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
2 | // + Copyright (c) 04.2007 Holger Buss |
3 | // + only for non-profit use |
3 | // + only for non-profit use |
4 | // + www.MikroKopter.com |
4 | // + www.MikroKopter.com |
5 | // + see the File "License.txt" for further Informations |
5 | // + see the File "License.txt" for further Informations |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | 7 | ||
8 | 8 | ||
9 | #include <inttypes.h> |
9 | #include <inttypes.h> |
10 | #include "main.h" |
10 | #include "main.h" |
11 | #include "eeprom.h" |
11 | #include "eeprom.h" |
12 | #include "timer2.h" |
12 | #include "timer2.h" |
13 | #include "fc.h" |
13 | #include "fc.h" |
14 | #include "rc.h" |
14 | #include "rc.h" |
15 | #include "uart.h" |
15 | #include "uart.h" |
16 | #include "printf_P.h" |
16 | #include "printf_P.h" |
17 | #include "analog.h" |
17 | #include "analog.h" |
18 | #include "_Settings.h" |
18 | #include "_Settings.h" |
19 | 19 | ||
20 | uint16_t TestInt = 0; |
20 | uint16_t TestInt = 0; |
21 | #define ARRAYSIZE 10 |
21 | #define ARRAYSIZE 10 |
22 | uint8_t Array[ARRAYSIZE] = {1,2,3,4,5,6,7,8,9,10}; |
22 | uint8_t Array[ARRAYSIZE] = {1,2,3,4,5,6,7,8,9,10}; |
23 | #define DISPLAYBUFFSIZE 80 |
23 | #define DISPLAYBUFFSIZE 80 |
24 | int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
24 | int8_t DisplayBuff[DISPLAYBUFFSIZE] = "Hello World"; |
25 | uint8_t DispPtr = 0; |
25 | uint8_t DispPtr = 0; |
26 | uint8_t RemoteButtons = 0; |
26 | uint8_t RemoteButtons = 0; |
27 | 27 | ||
28 | #define KEY1 0x01 |
28 | #define KEY1 0x01 |
29 | #define KEY2 0x02 |
29 | #define KEY2 0x02 |
30 | #define KEY3 0x04 |
30 | #define KEY3 0x04 |
31 | #define KEY4 0x08 |
31 | #define KEY4 0x08 |
32 | #define KEY5 0x10 |
32 | #define KEY5 0x10 |
33 | 33 | ||
34 | /************************************/ |
34 | /************************************/ |
35 | /* Clear LCD Buffer */ |
35 | /* Clear LCD Buffer */ |
36 | /************************************/ |
36 | /************************************/ |
37 | void LCD_Clear(void) |
37 | void LCD_Clear(void) |
38 | { |
38 | { |
39 | uint8_t i; |
39 | uint8_t i; |
40 | for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' '; |
40 | for( i = 0; i < DISPLAYBUFFSIZE; i++) DisplayBuff[i] = ' '; |
41 | } |
41 | } |
42 | 42 | ||
43 | 43 | ||
44 | /************************************/ |
44 | /************************************/ |
45 | /* Update Menu on LCD */ |
45 | /* Update Menu on LCD */ |
46 | /************************************/ |
46 | /************************************/ |
47 | // Display with 20 characters in 4 lines |
47 | // Display with 20 characters in 4 lines |
48 | void LCD_PrintMenu(void) |
48 | void LCD_PrintMenu(void) |
49 | { |
49 | { |
50 | static uint8_t MaxMenuItem = 11, MenuItem=0; |
50 | static uint8_t MaxMenuItem = 11, MenuItem=0; |
51 | 51 | ||
52 | // if KEY1 is activated goto previous menu item |
52 | // if KEY1 is activated goto previous menu item |
53 | if(RemoteButtons & KEY1) |
53 | if(RemoteButtons & KEY1) |
54 | { |
54 | { |
55 | if(MenuItem) MenuItem--; |
55 | if(MenuItem) MenuItem--; |
56 | else MenuItem = MaxMenuItem; |
56 | else MenuItem = MaxMenuItem; |
57 | LCD_Clear(); |
57 | LCD_Clear(); |
58 | RemotePollDisplayLine = -1; |
58 | RemotePollDisplayLine = -1; |
59 | } |
59 | } |
60 | // if KEY2 is activated goto next menu item |
60 | // if KEY2 is activated goto next menu item |
61 | if(RemoteButtons & KEY2) |
61 | if(RemoteButtons & KEY2) |
62 | { |
62 | { |
63 | if (MenuItem == MaxMenuItem) MenuItem = 0; |
63 | if (MenuItem == MaxMenuItem) MenuItem = 0; |
64 | else MenuItem++; |
64 | else MenuItem++; |
65 | LCD_Clear(); |
65 | LCD_Clear(); |
66 | RemotePollDisplayLine = -1; |
66 | RemotePollDisplayLine = -1; |
67 | } |
67 | } |
68 | 68 | ||
69 | // if KEY1 and KEY2 is activated goto initial menu item |
69 | // if KEY1 and KEY2 is activated goto initial menu item |
70 | if((RemoteButtons & KEY1) && (RemoteButtons & KEY2)) MenuItem = 0; |
70 | if((RemoteButtons & KEY1) && (RemoteButtons & KEY2)) MenuItem = 0; |
71 | 71 | ||
72 | // print menu item number in the upper right corner |
72 | // print menu item number in the upper right corner |
73 | if(MenuItem < 10) |
73 | if(MenuItem < 10) |
74 | { |
74 | { |
75 | LCD_printfxy(17,0,"[%i]",MenuItem); |
75 | LCD_printfxy(17,0,"[%i]",MenuItem); |
76 | } |
76 | } |
77 | else |
77 | else |
78 | { |
78 | { |
79 | LCD_printfxy(16,0,"[%i]",MenuItem); |
79 | LCD_printfxy(16,0,"[%i]",MenuItem); |
80 | } |
80 | } |
81 | 81 | ||
82 | switch(MenuItem) |
82 | switch(MenuItem) |
83 | { |
83 | { |
84 | case 0:// Version Info Menu Item |
84 | case 0:// Version Info Menu Item |
85 | LCD_printfxy(0,0,"+ MikroKopter +"); |
85 | LCD_printfxy(0,0,"+ MikroKopter +"); |
86 | LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_HAUPTVERSION, VERSION_NEBENVERSION,VERSION_INDEX+'a'); |
86 | LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",BoardRelease/10,BoardRelease%10,VERSION_HAUPTVERSION, VERSION_NEBENVERSION,VERSION_INDEX+'a'); |
87 | LCD_printfxy(0,2,"Setting: %d ", GetActiveParamSet()); |
87 | LCD_printfxy(0,2,"Setting: %d ", GetActiveParamSet()); |
88 | LCD_printfxy(0,3,"(c) Holger Buss"); |
88 | LCD_printfxy(0,3,"(c) Holger Buss"); |
89 | break; |
89 | break; |
90 | case 1:// Hight Control Menu Item |
90 | case 1:// Hight Control Menu Item |
91 | if(ParamSet.GlobalConfig & CFG_HOEHENREGELUNG) |
91 | if(ParamSet.GlobalConfig & CFG_HEIGHT_CONTROL) |
92 | { |
92 | { |
93 | LCD_printfxy(0,0,"Hoehe: %5i",HoehenWert); |
93 | LCD_printfxy(0,0,"Hoehe: %5i",HoehenWert); |
94 | LCD_printfxy(0,1,"SollHoehe: %5i",SollHoehe); |
94 | LCD_printfxy(0,1,"SollHoehe: %5i",SollHoehe); |
95 | LCD_printfxy(0,2,"Luftdruck: %5i",MessLuftdruck); |
95 | LCD_printfxy(0,2,"Luftdruck: %5i",MessLuftdruck); |
96 | LCD_printfxy(0,3,"Off : %5i",DruckOffsetSetting); |
96 | LCD_printfxy(0,3,"Off : %5i",DruckOffsetSetting); |
97 | } |
97 | } |
98 | else |
98 | else |
99 | { |
99 | { |
100 | LCD_printfxy(0,1,"Keine "); |
100 | LCD_printfxy(0,1,"Keine "); |
101 | LCD_printfxy(0,2,"Höhenregelung"); |
101 | LCD_printfxy(0,2,"Höhenregelung"); |
102 | } |
102 | } |
103 | 103 | ||
104 | break; |
104 | break; |
105 | case 2:// Attitude Menu Item |
105 | case 2:// Attitude Menu Item |
106 | LCD_printfxy(0,0,"akt. Lage"); |
106 | LCD_printfxy(0,0,"akt. Lage"); |
107 | LCD_printfxy(0,1,"Nick: %5i",IntegralNick/1024); |
107 | LCD_printfxy(0,1,"Nick: %5i",IntegralNick/1024); |
108 | LCD_printfxy(0,2,"Roll: %5i",IntegralRoll/1024); |
108 | LCD_printfxy(0,2,"Roll: %5i",IntegralRoll/1024); |
109 | LCD_printfxy(0,3,"Kompass: %5i",KompassValue); |
109 | LCD_printfxy(0,3,"Kompass: %5i",KompassValue); |
110 | break; |
110 | break; |
111 | case 3:// Remote Control Channel Menu Item |
111 | case 3:// Remote Control Channel Menu Item |
112 | LCD_printfxy(0,0,"K1:%4i K2:%4i ",PPM_in[1],PPM_in[2]); |
112 | LCD_printfxy(0,0,"K1:%4i K2:%4i ",PPM_in[1],PPM_in[2]); |
113 | LCD_printfxy(0,1,"K3:%4i K4:%4i ",PPM_in[3],PPM_in[4]); |
113 | LCD_printfxy(0,1,"K3:%4i K4:%4i ",PPM_in[3],PPM_in[4]); |
114 | LCD_printfxy(0,2,"K5:%4i K6:%4i ",PPM_in[5],PPM_in[6]); |
114 | LCD_printfxy(0,2,"K5:%4i K6:%4i ",PPM_in[5],PPM_in[6]); |
115 | LCD_printfxy(0,3,"K7:%4i K8:%4i ",PPM_in[7],PPM_in[8]); |
115 | LCD_printfxy(0,3,"K7:%4i K8:%4i ",PPM_in[7],PPM_in[8]); |
116 | break; |
116 | break; |
117 | case 4:// Remote Control Mapping Menu Item |
117 | case 4:// Remote Control Mapping Menu Item |
118 | LCD_printfxy(0,0,"Ni:%4i Ro:%4i ",PPM_in[ParamSet.Kanalbelegung[K_NICK]],PPM_in[ParamSet.Kanalbelegung[K_ROLL]]); |
118 | LCD_printfxy(0,0,"Ni:%4i Ro:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_NICK]],PPM_in[ParamSet.ChannelAssignment[CH_ROLL]]); |
119 | LCD_printfxy(0,1,"Gs:%4i Gi:%4i ",PPM_in[ParamSet.Kanalbelegung[K_GAS]],PPM_in[ParamSet.Kanalbelegung[K_GIER]]); |
119 | LCD_printfxy(0,1,"Gs:%4i Gi:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_GAS]],PPM_in[ParamSet.ChannelAssignment[CH_GIER]]); |
120 | LCD_printfxy(0,2,"P1:%4i P2:%4i ",PPM_in[ParamSet.Kanalbelegung[K_POTI1]],PPM_in[ParamSet.Kanalbelegung[K_POTI2]]); |
120 | LCD_printfxy(0,2,"P1:%4i P2:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI1]],PPM_in[ParamSet.ChannelAssignment[CH_POTI2]]); |
121 | LCD_printfxy(0,3,"P3:%4i P4:%4i ",PPM_in[ParamSet.Kanalbelegung[K_POTI3]],PPM_in[ParamSet.Kanalbelegung[K_POTI4]]); |
121 | LCD_printfxy(0,3,"P3:%4i P4:%4i ",PPM_in[ParamSet.ChannelAssignment[CH_POTI3]],PPM_in[ParamSet.ChannelAssignment[CH_POTI4]]); |
122 | break; |
122 | break; |
123 | case 5:// Gyro Sensor Menu Item |
123 | case 5:// Gyro Sensor Menu Item |
124 | LCD_printfxy(0,0,"Gyro - Sensor"); |
124 | LCD_printfxy(0,0,"Gyro - Sensor"); |
125 | if(BoardRelease == 10) |
125 | if(BoardRelease == 10) |
126 | { |
126 | { |
127 | LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick); |
127 | LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick); |
128 | LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll); |
128 | LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll); |
129 | LCD_printfxy(0,3,"Gier %4i (%3i)",MesswertGier, AdNeutralGier); |
129 | LCD_printfxy(0,3,"Gier %4i (%3i)",MesswertGier, AdNeutralGier); |
130 | } |
130 | } |
131 | else |
131 | else |
132 | { |
132 | { |
133 | LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick/2); |
133 | LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueGyrNick - AdNeutralNick, AdNeutralNick/2); |
134 | LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll/2); |
134 | LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueGyrRoll - AdNeutralRoll, AdNeutralRoll/2); |
135 | LCD_printfxy(0,3,"Gier %4i (%3i)",MesswertGier, AdNeutralGier/2); |
135 | LCD_printfxy(0,3,"Gier %4i (%3i)",MesswertGier, AdNeutralGier/2); |
136 | } |
136 | } |
137 | break; |
137 | break; |
138 | case 6:// Acceleration Sensor Menu Item |
138 | case 6:// Acceleration Sensor Menu Item |
139 | LCD_printfxy(0,0,"ACC - Sensor"); |
139 | LCD_printfxy(0,0,"ACC - Sensor"); |
140 | LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueAccNick,NeutralAccX); |
140 | LCD_printfxy(0,1,"Nick %4i (%3i)",AdValueAccNick,NeutralAccX); |
141 | LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueAccRoll,NeutralAccY); |
141 | LCD_printfxy(0,2,"Roll %4i (%3i)",AdValueAccRoll,NeutralAccY); |
142 | LCD_printfxy(0,3,"Hoch %4i (%3i)",Mittelwert_AccHoch/*accumulate_AccHoch / messanzahl_AccHoch*/,(int)NeutralAccZ); |
142 | LCD_printfxy(0,3,"Hoch %4i (%3i)",Mittelwert_AccHoch/*accumulate_AccHoch / messanzahl_AccHoch*/,(int)NeutralAccZ); |
143 | break; |
143 | break; |
144 | case 7:// Accumulator Voltage / Remote Control Level |
144 | case 7:// Accumulator Voltage / Remote Control Level |
145 | LCD_printfxy(0,1,"Spannung: %5i",UBat); |
145 | LCD_printfxy(0,1,"Spannung: %5i",UBat); |
146 | LCD_printfxy(0,2,"Empf.Pegel:%5i",SenderOkay); |
146 | LCD_printfxy(0,2,"Empf.Pegel:%5i",SenderOkay); |
147 | break; |
147 | break; |
148 | case 8:// Compass Menu Item |
148 | case 8:// Compass Menu Item |
149 | LCD_printfxy(0,0,"Kompass "); |
149 | LCD_printfxy(0,0,"Kompass "); |
150 | LCD_printfxy(0,1,"Richtung: %5i",KompassRichtung); |
150 | LCD_printfxy(0,1,"Richtung: %5i",KompassRichtung); |
151 | LCD_printfxy(0,2,"Messwert: %5i",KompassValue); |
151 | LCD_printfxy(0,2,"Messwert: %5i",KompassValue); |
152 | LCD_printfxy(0,3,"Start: %5i",KompassStartwert); |
152 | LCD_printfxy(0,3,"Start: %5i",KompassStartwert); |
153 | break; |
153 | break; |
154 | case 9:// Poti Menu Item |
154 | case 9:// Poti Menu Item |
155 | LCD_printfxy(0,0,"Poti1: %3i",Poti1); |
155 | LCD_printfxy(0,0,"Poti1: %3i",Poti1); |
156 | LCD_printfxy(0,1,"Poti2: %3i",Poti2); |
156 | LCD_printfxy(0,1,"Poti2: %3i",Poti2); |
157 | LCD_printfxy(0,2,"Poti3: %3i",Poti3); |
157 | LCD_printfxy(0,2,"Poti3: %3i",Poti3); |
158 | LCD_printfxy(0,3,"Poti4: %3i",Poti4); |
158 | LCD_printfxy(0,3,"Poti4: %3i",Poti4); |
159 | break; |
159 | break; |
160 | case 10:// Servo Menu Item |
160 | case 10:// Servo Menu Item |
161 | LCD_printfxy(0,0,"Servo " ); |
161 | LCD_printfxy(0,0,"Servo " ); |
162 | LCD_printfxy(0,1,"Setpoint %3i",Parameter_ServoNickControl); |
162 | LCD_printfxy(0,1,"Setpoint %3i",Parameter_ServoNickControl); |
163 | LCD_printfxy(0,2,"Stellung: %3i",ServoValue); |
163 | LCD_printfxy(0,2,"Stellung: %3i",ServoValue); |
164 | LCD_printfxy(0,3,"Range:%3i-%3i",ParamSet.ServoNickMin,ParamSet.ServoNickMax); |
164 | LCD_printfxy(0,3,"Range:%3i-%3i",ParamSet.ServoNickMin,ParamSet.ServoNickMax); |
165 | break; |
165 | break; |
166 | case 11://Extern Control |
166 | case 11://Extern Control |
167 | LCD_printfxy(0,0,"ExternControl " ); |
167 | LCD_printfxy(0,0,"ExternControl " ); |
168 | LCD_printfxy(0,1,"Ni:%4i Ro:%4i ",ExternControl.Nick,ExternControl.Roll); |
168 | LCD_printfxy(0,1,"Ni:%4i Ro:%4i ",ExternControl.Nick,ExternControl.Roll); |
169 | LCD_printfxy(0,2,"Gs:%4i Gi:%4i ",ExternControl.Gas,ExternControl.Gier); |
169 | LCD_printfxy(0,2,"Gs:%4i Gi:%4i ",ExternControl.Gas,ExternControl.Gier); |
170 | LCD_printfxy(0,3,"Hi:%4i Cf:%4i ",ExternControl.Hight,ExternControl.Config); |
170 | LCD_printfxy(0,3,"Hi:%4i Cf:%4i ",ExternControl.Hight,ExternControl.Config); |
171 | break; |
171 | break; |
172 | default: MaxMenuItem = MenuItem - 1; |
172 | default: MaxMenuItem = MenuItem - 1; |
173 | MenuItem = 0; |
173 | MenuItem = 0; |
174 | break; |
174 | break; |
175 | } |
175 | } |
176 | RemoteButtons = 0; |
176 | RemoteButtons = 0; |
177 | } |
177 | } |
178 | 178 |