Rev 685 | Rev 783 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 685 | Rev 728 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2009-2010 by Claas Anders "CaScAdE" Rathje * |
3 | * admiralcascade@gmail.com * |
3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
5 | * * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License. * |
8 | * the Free Software Foundation; either version 2 of the License. * |
9 | * * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
13 | * GNU General Public License for more details. * |
14 | * * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | * * |
19 | * * |
20 | * This is an alternative FC-mode contributed by Josef "jopl" Plasil * |
20 | * This is an alternative FC-mode contributed by Josef "jopl" Plasil * |
21 | * who is using the FC with an MK3Mag and the OSD * |
21 | * who is using the FC with an MK3Mag and the OSD * |
22 | ****************************************************************************/ |
22 | ****************************************************************************/ |
23 | 23 | ||
24 | #include "main.h" |
24 | #include "main.h" |
25 | #include "max7456_software_spi.h" |
25 | #include "max7456_software_spi.h" |
26 | #include "osd_helpers.h" |
26 | #include "osd_helpers.h" |
27 | #include "osd_fcmode_default.h" |
27 | #include "osd_fcmode_default.h" |
28 | 28 | ||
29 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
29 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
30 | 30 | ||
31 | // jopl Vario |
31 | // jopl Vario |
32 | static int16_t last_Altimeter = 0; |
32 | static int16_t last_Altimeter = 0; |
33 | static int16_t Vario = 0; |
33 | static int16_t Vario = 0; |
34 | 34 | ||
35 | int osd_fcmode_jopl() { |
35 | int osd_fcmode_jopl() { |
36 | if (COSD_FLAGS_MODES & COSD_FLAG_HUD) { |
36 | if (COSD_FLAGS_MODES & COSD_FLAG_HUD) { |
37 | // write icons at init or after menu/mode-switch |
37 | // write icons at init or after menu/mode-switch |
38 | if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) { |
38 | if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) { |
39 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
39 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
40 | 40 | ||
41 | // jopl ... compass |
41 | // jopl ... compass |
42 | write_char_xy(16, top_line, 0xD0); // degree symbol |
42 | write_char_xy(16, top_line, 0xD0); // degree symbol |
43 | // end jopl |
43 | // end jopl |
44 | 44 | ||
45 | write_char_xy(26, top_line, 0xCC); // small meters m height |
45 | write_char_xy(26, top_line, 0xCC); // small meters m height |
46 | write_char_xy(7, bottom_line, 0x9E); // small v |
46 | write_char_xy(7, bottom_line, 0x9E); // small v |
47 | 47 | ||
48 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
48 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
49 | write_char_xy(7, bottom_line - 1, 0x9F); // small A |
49 | write_char_xy(7, bottom_line - 1, 0x9F); // small A |
50 | write_char_xy(14, bottom_line - 1, 0xB5); // mah |
50 | write_char_xy(14, bottom_line - 1, 0xB5); // mah |
51 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
51 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
52 | write_char_xy(21, bottom_line - 1, 0x9E); // small V |
52 | write_char_xy(21, bottom_line - 1, 0x9E); // small V |
53 | } |
53 | } |
54 | } |
54 | } |
55 | 55 | ||
56 | // jopl ... Times |
56 | // jopl ... Times |
57 | write_char_xy(14, bottom_line, 0xD1); // on clock |
57 | write_char_xy(14, bottom_line, 0xD1); // on clock |
58 | write_char_xy(21, bottom_line, 0xD2); // fly clock |
58 | write_char_xy(21, bottom_line, 0xD2); // fly clock |
59 | // end jopl |
59 | // end jopl |
60 | 60 | ||
61 | COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN; |
61 | COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN; |
62 | } |
62 | } |
63 | 63 | ||
64 | write_ndigit_number_u(7, top_line, debugData.Analog[10], 3, 0); |
64 | write_ndigit_number_u(7, top_line, debugData.Analog[10], 3, 0); |
65 | if (debugData.Analog[10] <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
65 | if (debugData.Analog[10] <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
66 | for (uint8_t x = 0; x < 4; x++) |
66 | for (uint8_t x = 0; x < 4; x++) |
67 | write_char_att_xy(7 + x, top_line, BLINK); |
67 | write_char_att_xy(7 + x, top_line, BLINK); |
68 | } else if (debugData.Analog[10] > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
68 | } else if (debugData.Analog[10] > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
69 | for (uint8_t x = 0; x < 4; x++) |
69 | for (uint8_t x = 0; x < 4; x++) |
70 | write_char_att_xy(7 + x, top_line, 0); |
70 | write_char_att_xy(7 + x, top_line, 0); |
71 | } |
71 | } |
72 | 72 | ||
73 | // jopl ... compass |
73 | // jopl ... compass |
74 | write_ndigit_number_u(13, top_line, debugData.Analog[8], 3, 0); |
74 | write_ndigit_number_u(13, top_line, debugData.Analog[8], 3, 0); |
75 | write_ascii_string_pgm(17, top_line, (const char *) (pgm_read_word(&(directions[heading_conv(debugData.Analog[8])])))); |
75 | write_ascii_string_pgm(17, top_line, (const char *) (pgm_read_word(&(directions[heading_conv(debugData.Analog[8])])))); |
76 | // end jopl |
76 | // end jopl |
77 | 77 | ||
78 | // jopl Altimeter modification |
78 | // jopl Altimeter modification |
79 | if ((debugData.Analog[5] > 100) || (debugData.Analog[5] < -100)) { |
79 | if ((debugData.Analog[5] > 100) || (debugData.Analog[5] < -100)) { |
80 | // above 10m only write full meters |
80 | // above 10m only write full meters |
81 | write_ndigit_number_s(22, top_line, debugData.Analog[5] / 10, 4, 0); |
81 | write_ndigit_number_s(22, top_line, debugData.Analog[5] / 10, 4, 0); |
82 | } else { |
82 | } else { |
83 | // up to 10m write meters.dm |
83 | // up to 10m write meters.dm |
84 | write_ndigit_number_s_10th(22, top_line, debugData.Analog[5], 3, 0); |
84 | write_ndigit_number_s_10th(22, top_line, debugData.Analog[5], 3, 0); |
85 | } |
85 | } |
86 | Vario = debugData.Analog[5] - last_Altimeter; |
86 | Vario = debugData.Analog[5] - last_Altimeter; |
87 | draw_variometer(27, top_line, Vario); |
87 | draw_variometer(27, top_line, Vario); |
88 | if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) { |
88 | if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) { |
89 | draw_big_variometer(27, 8, Vario); |
89 | draw_big_variometer(27, 8, Vario); |
90 | } |
90 | } |
91 | last_Altimeter = debugData.Analog[5]; |
91 | last_Altimeter = debugData.Analog[5]; |
92 | // end jopl |
92 | // end jopl |
93 | 93 | ||
94 | if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5]; |
94 | if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5]; |
95 | 95 | ||
96 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
96 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
97 | draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]); |
97 | draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]); |
98 | } |
98 | } |
99 | 99 | ||
100 | // jopl ... compass heading |
100 | // jopl ... compass heading |
101 | // seccond line |
101 | // seccond line |
102 | draw_compass(11, top_line + 1, debugData.Analog[8]); |
102 | draw_compass(11, top_line + 1, debugData.Analog[8]); |
103 | // end jopl |
103 | // end jopl |
104 | 104 | ||
105 | // pre-bottom line |
105 | // pre-bottom line |
106 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
106 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
107 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
107 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
108 | write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0); |
108 | write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0); |
109 | write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0); |
109 | write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0); |
110 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
110 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
111 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
111 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
112 | } |
112 | } |
113 | } |
113 | } |
114 | 114 | ||
115 | draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage); |
115 | draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage); |
116 | write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 3, 0); |
116 | write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 3, 0); |
117 | if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) { |
117 | if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) { |
118 | for (uint8_t x = 2; x < 8; x++) |
118 | for (uint8_t x = 2; x < 8; x++) |
119 | write_char_att_xy(x, bottom_line, BLINK); |
119 | write_char_att_xy(x, bottom_line, BLINK); |
120 | } else if (debugData.Analog[9] > min_voltage && last_UBat < min_voltage) { |
120 | } else if (debugData.Analog[9] > min_voltage && last_UBat < min_voltage) { |
121 | for (uint8_t x = 2; x < 8; x++) |
121 | for (uint8_t x = 2; x < 8; x++) |
122 | write_char_att_xy(x, bottom_line, 0); |
122 | write_char_att_xy(x, bottom_line, 0); |
123 | } |
123 | } |
124 | 124 | ||
125 | // jopl ... Times |
125 | // jopl ... Times |
126 | write_time(8, bottom_line, uptime); |
126 | write_time(8, bottom_line, uptime); |
127 | write_time(15, bottom_line, flytime_fc); |
127 | write_time(15, bottom_line, flytime_fc); |
128 | // Test ... show Gas value |
128 | // Test ... show Gas value |
129 | // write_ndigit_number_s(22, bottom_line, debugData.Analog[5], 5, 0); |
129 | // write_ndigit_number_s(22, bottom_line, debugData.Analog[5], 5, 0); |
130 | // end jopl |
130 | // end jopl |
131 | 131 | ||
132 | } |
132 | } |
133 | // remember last values |
133 | // remember last values |
134 | last_UBat = debugData.Analog[9]; |
134 | last_UBat = debugData.Analog[9]; |
135 | last_RC_Quality = debugData.Analog[10]; |
135 | last_RC_Quality = debugData.Analog[10]; |
136 | 136 | ||
137 | /* |
137 | /* |
138 | debugData.Analog[0]); // AngleNick |
138 | debugData.Analog[0]); // AngleNick |
139 | debugData.Analog[1]); // AngleRoll |
139 | debugData.Analog[1]); // AngleRoll |
140 | debugData.Analog[2]); // AccNick |
140 | debugData.Analog[2]); // AccNick |
141 | debugData.Analog[3]); // AccRoll |
141 | debugData.Analog[3]); // AccRoll |
142 | debugData.Analog[4]); // GyroGier |
142 | debugData.Analog[4]); // GyroGier |
143 | debugData.Analog[5]); // Height Value |
143 | debugData.Analog[5]); // Height Value |
144 | debugData.Analog[6]); // AccZ |
144 | debugData.Analog[6]); // AccZ |
145 | debugData.Analog[7]); // Throttle |
145 | debugData.Analog[7]); // Throttle |
146 | debugData.Analog[8]); // Compass Value |
146 | debugData.Analog[8]); // Compass Value |
147 | debugData.Analog[9]); // Voltage |
147 | debugData.Analog[9]); // Voltage |
148 | debugData.Analog[10]);// RC Signal |
148 | debugData.Analog[10]);// RC Signal |
149 | debugData.Analog[11]);// Gyro compass |
149 | debugData.Analog[11]);// Gyro compass |
150 | debugData.Analog[12]);// Motor Front |
150 | debugData.Analog[12]);// Motor Front |
151 | debugData.Analog[13]);// Motor Rear |
151 | debugData.Analog[13]);// Motor Rear |
152 | debugData.Analog[14]);// Motor Left |
152 | debugData.Analog[14]);// Motor Left |
153 | debugData.Analog[15]);// Motor Right |
153 | debugData.Analog[15]);// Motor Right |
154 | debugData.Analog[16]);// |
154 | debugData.Analog[16]);// |
155 | debugData.Analog[17]);// |
155 | debugData.Analog[17]);// |
156 | debugData.Analog[18]);// |
156 | debugData.Analog[18]);// |
157 | debugData.Analog[19]);// MK3Mag CalState |
157 | debugData.Analog[19]);// MK3Mag CalState |
158 | debugData.Analog[20]);// Servo |
158 | debugData.Analog[20]);// Servo |
159 | debugData.Analog[21]);// |
159 | debugData.Analog[21]);// |
160 | debugData.Analog[22]);// |
160 | debugData.Analog[22]);// |
161 | debugData.Analog[23]);// |
161 | debugData.Analog[23]);// |
162 | debugData.Analog[24]);// |
162 | debugData.Analog[24]);// |
163 | debugData.Analog[25]);// |
163 | debugData.Analog[25]);// |
164 | debugData.Analog[26]);// |
164 | debugData.Analog[26]);// |
165 | debugData.Analog[27]);// Kalman_MaxDrift |
165 | debugData.Analog[27]);// Kalman_MaxDrift |
166 | debugData.Analog[28]);// |
166 | debugData.Analog[28]);// |
167 | debugData.Analog[29]);// |
167 | debugData.Analog[29]);// |
168 | debugData.Analog[30]);// GPS_Nick |
168 | debugData.Analog[30]);// GPS_Nick |
169 | debugData.Analog[31]);// GPS_Roll |
169 | debugData.Analog[31]);// GPS_Roll |
170 | */ |
170 | */ |
171 | seconds_since_last_data = 0; |
171 | seconds_since_last_data = 0; |
172 | 172 | ||
173 | return 0; |
173 | return 0; |
174 | } |
174 | } |
175 | 175 | ||
176 | #endif |
176 | #endif |
177 | 177 |