Rev 2225 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2225 | Rev 2598 | ||
|---|---|---|---|
| 1 | /**************************************************************************** |
1 | /**************************************************************************** |
| 2 | * Copyright (C) 2009-2016 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2009-2017 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)) && FCONLY) |
29 | #if (!(ALLCHARSDEBUG || (WRITECHARS != -1)) && FCONLY) |
| 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 | clear(); |
37 | clear(); |
| 38 | } else { |
38 | } else { |
| 39 | // write icons at init or after menu/mode-switch |
39 | // write icons at init or after menu/mode-switch |
| 40 | if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) { |
40 | if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) { |
| 41 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
41 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
| 42 | 42 | ||
| 43 | // jopl ... compass |
43 | // jopl ... compass |
| 44 | write_char_xy(16, top_line, 0xD0); // degree symbol |
44 | write_char_xy(16, top_line, 0xD0); // degree symbol |
| 45 | // end jopl |
45 | // end jopl |
| 46 | 46 | ||
| 47 | write_char_xy(26, top_line, 0xCC); // small meters m height |
47 | write_char_xy(26, top_line, 0xCC); // small meters m height |
| 48 | write_char_xy(7, bottom_line, 0x9E); // small v |
48 | write_char_xy(7, bottom_line, 0x9E); // small v |
| 49 | 49 | ||
| 50 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
50 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
| 51 | write_char_xy(7, bottom_line - 1, 0x9F); // small A |
51 | write_char_xy(7, bottom_line - 1, 0x9F); // small A |
| 52 | write_char_xy(14, bottom_line - 1, 0xB5); // mah |
52 | write_char_xy(14, bottom_line - 1, 0xB5); // mah |
| 53 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
53 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
| 54 | write_char_xy(21, bottom_line - 1, 0x9E); // small V |
54 | write_char_xy(21, bottom_line - 1, 0x9E); // small V |
| 55 | } |
55 | } |
| 56 | } |
56 | } |
| 57 | 57 | ||
| 58 | // jopl ... Times |
58 | // jopl ... Times |
| 59 | write_char_xy(14, bottom_line, 0xD1); // on clock |
59 | write_char_xy(14, bottom_line, 0xD1); // on clock |
| 60 | write_char_xy(21, bottom_line, 0xD2); // fly clock |
60 | write_char_xy(21, bottom_line, 0xD2); // fly clock |
| 61 | // end jopl |
61 | // end jopl |
| 62 | 62 | ||
| 63 | COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN; |
63 | COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN; |
| 64 | } |
64 | } |
| 65 | 65 | ||
| 66 | write_ndigit_number_u(7, top_line, debugData.Analog[10], 3, 0); |
66 | write_ndigit_number_u(7, top_line, debugData.Analog[10], 3, 0); |
| 67 | if (debugData.Analog[10] <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
67 | if (debugData.Analog[10] <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
| 68 | for (uint8_t x = 0; x < 4; x++) |
68 | for (uint8_t x = 0; x < 4; x++) |
| 69 | write_char_att_xy(7 + x, top_line, BLINK); |
69 | write_char_att_xy(7 + x, top_line, BLINK); |
| 70 | } else if (debugData.Analog[10] > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
70 | } else if (debugData.Analog[10] > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
| 71 | for (uint8_t x = 0; x < 4; x++) |
71 | for (uint8_t x = 0; x < 4; x++) |
| 72 | write_char_att_xy(7 + x, top_line, 0); |
72 | write_char_att_xy(7 + x, top_line, 0); |
| 73 | } |
73 | } |
| 74 | 74 | ||
| 75 | // jopl ... compass |
75 | // jopl ... compass |
| 76 | write_ndigit_number_u(13, top_line, debugData.Analog[8], 3, 0); |
76 | write_ndigit_number_u(13, top_line, debugData.Analog[8], 3, 0); |
| 77 | write_ascii_string_pgm(17, top_line, directions[heading_conv(debugData.Analog[8])]); |
77 | write_ascii_string_pgm(17, top_line, directions[heading_conv(debugData.Analog[8])]); |
| 78 | // end jopl |
78 | // end jopl |
| 79 | 79 | ||
| 80 | // jopl Altimeter modification |
80 | // jopl Altimeter modification |
| 81 | if ((debugData.Analog[5] > 100) || (debugData.Analog[5] < -100)) { |
81 | if ((debugData.Analog[5] > 100) || (debugData.Analog[5] < -100)) { |
| 82 | // above 10m only write full meters |
82 | // above 10m only write full meters |
| 83 | write_ndigit_number_s(22, top_line, debugData.Analog[5] / 10, 4, 0); |
83 | write_ndigit_number_s(22, top_line, debugData.Analog[5] / 10, 4, 0); |
| 84 | } else { |
84 | } else { |
| 85 | // up to 10m write meters.dm |
85 | // up to 10m write meters.dm |
| 86 | write_ndigit_number_s_10th(22, top_line, debugData.Analog[5], 3, 0); |
86 | write_ndigit_number_s_10th(22, top_line, debugData.Analog[5], 3, 0); |
| 87 | } |
87 | } |
| 88 | Vario = debugData.Analog[5] - last_Altimeter; |
88 | Vario = debugData.Analog[5] - last_Altimeter; |
| 89 | draw_variometer(27, top_line, Vario); |
89 | draw_variometer(27, top_line, Vario); |
| 90 | if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) { |
90 | if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) { |
| 91 | draw_big_variometer(27, 8, Vario); |
91 | draw_big_variometer(27, 8, Vario); |
| 92 | } |
92 | } |
| 93 | last_Altimeter = debugData.Analog[5]; |
93 | last_Altimeter = debugData.Analog[5]; |
| 94 | // end jopl |
94 | // end jopl |
| 95 | 95 | ||
| 96 | if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5]; |
96 | if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5]; |
| 97 | 97 | ||
| 98 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
98 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
| 99 | draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]); |
99 | draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]); |
| 100 | } |
100 | } |
| 101 | 101 | ||
| 102 | // jopl ... compass heading |
102 | // jopl ... compass heading |
| 103 | // seccond line |
103 | // seccond line |
| 104 | draw_compass(11, top_line + 1, debugData.Analog[8]); |
104 | draw_compass(11, top_line + 1, debugData.Analog[8]); |
| 105 | // end jopl |
105 | // end jopl |
| 106 | 106 | ||
| 107 | // pre-bottom line |
107 | // pre-bottom line |
| 108 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
108 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
| 109 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
109 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
| 110 | write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0); |
110 | write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0); |
| 111 | write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0); |
111 | write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0); |
| 112 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
112 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
| 113 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
113 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
| 114 | } |
114 | } |
| 115 | } |
115 | } |
| 116 | 116 | ||
| 117 | draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage); |
117 | draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage); |
| 118 | write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 3, 0); |
118 | write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 3, 0); |
| 119 | if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) { |
119 | if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) { |
| 120 | for (uint8_t x = 2; x < 8; x++) |
120 | for (uint8_t x = 2; x < 8; x++) |
| 121 | write_char_att_xy(x, bottom_line, BLINK); |
121 | write_char_att_xy(x, bottom_line, BLINK); |
| 122 | } else if (debugData.Analog[9] > min_voltage && last_UBat < min_voltage) { |
122 | } else if (debugData.Analog[9] > min_voltage && last_UBat < min_voltage) { |
| 123 | for (uint8_t x = 2; x < 8; x++) |
123 | for (uint8_t x = 2; x < 8; x++) |
| 124 | write_char_att_xy(x, bottom_line, 0); |
124 | write_char_att_xy(x, bottom_line, 0); |
| 125 | } |
125 | } |
| 126 | 126 | ||
| 127 | // jopl ... Times |
127 | // jopl ... Times |
| 128 | write_time(8, bottom_line, uptime); |
128 | write_time(8, bottom_line, uptime); |
| 129 | write_time(15, bottom_line, flytime_fc); |
129 | write_time(15, bottom_line, flytime_fc); |
| 130 | // Test ... show Gas value |
130 | // Test ... show Gas value |
| 131 | // write_ndigit_number_s(22, bottom_line, debugData.Analog[5], 5, 0); |
131 | // write_ndigit_number_s(22, bottom_line, debugData.Analog[5], 5, 0); |
| 132 | // end jopl |
132 | // end jopl |
| 133 | 133 | ||
| 134 | } |
134 | } |
| 135 | // remember last values |
135 | // remember last values |
| 136 | last_UBat = debugData.Analog[9]; |
136 | last_UBat = debugData.Analog[9]; |
| 137 | last_RC_Quality = debugData.Analog[10]; |
137 | last_RC_Quality = debugData.Analog[10]; |
| 138 | 138 | ||
| 139 | /* |
139 | /* |
| 140 | debugData.Analog[0]); // AngleNick |
140 | debugData.Analog[0]); // AngleNick |
| 141 | debugData.Analog[1]); // AngleRoll |
141 | debugData.Analog[1]); // AngleRoll |
| 142 | debugData.Analog[2]); // AccNick |
142 | debugData.Analog[2]); // AccNick |
| 143 | debugData.Analog[3]); // AccRoll |
143 | debugData.Analog[3]); // AccRoll |
| 144 | debugData.Analog[4]); // GyroGier |
144 | debugData.Analog[4]); // GyroGier |
| 145 | debugData.Analog[5]); // Height Value |
145 | debugData.Analog[5]); // Height Value |
| 146 | debugData.Analog[6]); // AccZ |
146 | debugData.Analog[6]); // AccZ |
| 147 | debugData.Analog[7]); // Throttle |
147 | debugData.Analog[7]); // Throttle |
| 148 | debugData.Analog[8]); // Compass Value |
148 | debugData.Analog[8]); // Compass Value |
| 149 | debugData.Analog[9]); // Voltage |
149 | debugData.Analog[9]); // Voltage |
| 150 | debugData.Analog[10]);// RC Signal |
150 | debugData.Analog[10]);// RC Signal |
| 151 | debugData.Analog[11]);// Gyro compass |
151 | debugData.Analog[11]);// Gyro compass |
| 152 | debugData.Analog[12]);// Motor Front |
152 | debugData.Analog[12]);// Motor Front |
| 153 | debugData.Analog[13]);// Motor Rear |
153 | debugData.Analog[13]);// Motor Rear |
| 154 | debugData.Analog[14]);// Motor Left |
154 | debugData.Analog[14]);// Motor Left |
| 155 | debugData.Analog[15]);// Motor Right |
155 | debugData.Analog[15]);// Motor Right |
| 156 | debugData.Analog[16]);// |
156 | debugData.Analog[16]);// |
| 157 | debugData.Analog[17]);// |
157 | debugData.Analog[17]);// |
| 158 | debugData.Analog[18]);// |
158 | debugData.Analog[18]);// |
| 159 | debugData.Analog[19]);// MK3Mag CalState |
159 | debugData.Analog[19]);// MK3Mag CalState |
| 160 | debugData.Analog[20]);// Servo |
160 | debugData.Analog[20]);// Servo |
| 161 | debugData.Analog[21]);// |
161 | debugData.Analog[21]);// |
| 162 | debugData.Analog[22]);// |
162 | debugData.Analog[22]);// |
| 163 | debugData.Analog[23]);// |
163 | debugData.Analog[23]);// |
| 164 | debugData.Analog[24]);// |
164 | debugData.Analog[24]);// |
| 165 | debugData.Analog[25]);// |
165 | debugData.Analog[25]);// |
| 166 | debugData.Analog[26]);// |
166 | debugData.Analog[26]);// |
| 167 | debugData.Analog[27]);// Kalman_MaxDrift |
167 | debugData.Analog[27]);// Kalman_MaxDrift |
| 168 | debugData.Analog[28]);// |
168 | debugData.Analog[28]);// |
| 169 | debugData.Analog[29]);// |
169 | debugData.Analog[29]);// |
| 170 | debugData.Analog[30]);// GPS_Nick |
170 | debugData.Analog[30]);// GPS_Nick |
| 171 | debugData.Analog[31]);// GPS_Roll |
171 | debugData.Analog[31]);// GPS_Roll |
| 172 | */ |
172 | */ |
| 173 | seconds_since_last_data = 0; |
173 | seconds_since_last_data = 0; |
| 174 | 174 | ||
| 175 | return 0; |
175 | return 0; |
| 176 | } |
176 | } |
| 177 | 177 | ||
| 178 | #endif |
178 | #endif |
| 179 | 179 | ||