Rev 902 | Rev 955 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 902 | Rev 954 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2009-2011 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2009-2011 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 | 20 | ||
21 | #include "main.h" |
21 | #include "main.h" |
22 | #include "max7456_software_spi.h" |
22 | #include "max7456_software_spi.h" |
23 | #include "osd_helpers.h" |
23 | #include "osd_helpers.h" |
24 | #include "osd_fcmode_default.h" |
24 | #include "osd_fcmode_default.h" |
- | 25 | #include "usart1.h" |
|
25 | 26 | ||
26 | #if (!(ALLCHARSDEBUG || (WRITECHARS != -1)) && FCONLY) |
27 | #if (!(ALLCHARSDEBUG || (WRITECHARS != -1)) && FCONLY) |
27 | 28 | ||
28 | int osd_fcmode_default() { |
29 | int osd_fcmode_default() { |
- | 30 | static signed int rc_quality = 0; |
|
- | 31 | #ifndef ACT_RSSI_FROM_LCD |
|
- | 32 | rc_quality = debugData.Analog[10]; |
|
- | 33 | #endif |
|
- | 34 | ||
29 | if (COSD_FLAGS_MODES & COSD_FLAG_HUD) { |
35 | if (COSD_FLAGS_MODES & COSD_FLAG_HUD) { |
30 | // write icons at init or after menu/mode-switch |
36 | // write icons at init or after menu/mode-switch |
31 | if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) { |
37 | if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) { |
32 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
38 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
33 | write_char_xy(27, top_line, 0xCC); // small meters m height |
39 | write_char_xy(27, top_line, 0xCC); // small meters m height |
34 | write_char_xy(7, bottom_line, 0x9E); // small v |
40 | write_char_xy(7, bottom_line, 0x9E); // small v |
35 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
41 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
36 | write_char_xy(7, bottom_line - 1, 0x9F); // small A |
42 | write_char_xy(7, bottom_line - 1, 0x9F); // small A |
37 | write_char_xy(14, bottom_line - 1, 0xB5); // mah |
43 | write_char_xy(14, bottom_line - 1, 0xB5); // mah |
38 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
44 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
39 | write_char_xy(21, bottom_line - 1, 0x9E); // small V |
45 | write_char_xy(21, bottom_line - 1, 0x9E); // small V |
40 | } |
46 | } |
41 | } |
47 | } |
42 | COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN; |
48 | COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN; |
43 | } |
49 | } |
44 | 50 | ||
45 | write_ndigit_number_u(7, top_line, debugData.Analog[10], 3, 0); |
51 | write_ndigit_number_u(7, top_line, rc_quality, 3, 0); |
46 | if (debugData.Analog[10] <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
52 | if (rc_quality <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) { |
47 | for (uint8_t x = 0; x < 4; x++) |
53 | for (uint8_t x = 0; x < 4; x++) |
48 | write_char_att_xy(7 + x, top_line, BLINK); |
54 | write_char_att_xy(7 + x, top_line, BLINK); |
49 | } else if (debugData.Analog[10] > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
55 | } else if (rc_quality > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) { |
50 | for (uint8_t x = 0; x < 4; x++) |
56 | for (uint8_t x = 0; x < 4; x++) |
51 | write_char_att_xy(7 + x, top_line, 0); |
57 | write_char_att_xy(7 + x, top_line, 0); |
52 | } |
58 | } |
53 | 59 | ||
54 | if (debugData.Analog[5] > 200 || debugData.Analog[5] < -200) { |
60 | if (debugData.Analog[5] > 200 || debugData.Analog[5] < -200) { |
55 | // above 10m only write full meters |
61 | // above 10m only write full meters |
56 | write_ndigit_number_s(23, top_line, debugData.Analog[5] / 20, 4, 0); |
62 | write_ndigit_number_s(23, top_line, debugData.Analog[5] / 20, 4, 0); |
57 | } else { |
63 | } else { |
58 | // up to 10m write meters.dm |
64 | // up to 10m write meters.dm |
59 | write_ndigit_number_s_10th(23, top_line, debugData.Analog[5] / 2, 3, 0); |
65 | write_ndigit_number_s_10th(23, top_line, debugData.Analog[5] / 2, 3, 0); |
60 | } |
66 | } |
61 | if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5]; |
67 | if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5]; |
62 | 68 | ||
63 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
69 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
64 | draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]); |
70 | draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]); |
65 | } |
71 | } |
66 | 72 | ||
67 | // pre-bottom line |
73 | // pre-bottom line |
68 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
74 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
69 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
75 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
70 | write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0); |
76 | write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0); |
71 | write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0); |
77 | write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0); |
72 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
78 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
73 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
79 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
74 | } |
80 | } |
75 | } |
81 | } |
76 | 82 | ||
77 | draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage); |
83 | draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage); |
78 | write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 3, 0); |
84 | write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 3, 0); |
79 | if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) { |
85 | if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) { |
80 | for (uint8_t x = 2; x < 8; x++) |
86 | for (uint8_t x = 2; x < 8; x++) |
81 | write_char_att_xy(x, bottom_line, BLINK); |
87 | write_char_att_xy(x, bottom_line, BLINK); |
82 | } else if (debugData.Analog[9] > min_voltage && last_UBat < min_voltage) { |
88 | } else if (debugData.Analog[9] > min_voltage && last_UBat < min_voltage) { |
83 | for (uint8_t x = 2; x < 8; x++) |
89 | for (uint8_t x = 2; x < 8; x++) |
84 | write_char_att_xy(x, bottom_line, 0); |
90 | write_char_att_xy(x, bottom_line, 0); |
85 | } |
91 | } |
86 | } |
92 | } |
87 | // remember last values |
93 | // remember last values |
88 | last_UBat = debugData.Analog[9]; |
94 | last_UBat = debugData.Analog[9]; |
89 | last_RC_Quality = debugData.Analog[10]; |
95 | last_RC_Quality = debugData.Analog[10]; |
90 | 96 | ||
91 | /* |
97 | /* |
92 | debugData.Analog[0]); // AngleNick |
98 | debugData.Analog[0]); // AngleNick |
93 | debugData.Analog[1]); // AngleRoll |
99 | debugData.Analog[1]); // AngleRoll |
94 | debugData.Analog[5]); // Height |
100 | debugData.Analog[5]); // Height |
95 | debugData.Analog[9]); // Voltage |
101 | debugData.Analog[9]); // Voltage |
96 | debugData.Analog[10]);// RC Signal |
102 | debugData.Analog[10]);// RC Signal |
97 | debugData.Analog[11]);// Gyro compass |
103 | debugData.Analog[11]);// Gyro compass |
98 | */ |
104 | */ |
99 | seconds_since_last_data = 0; |
105 | seconds_since_last_data = 0; |
- | 106 | // |
|
- | 107 | ||
- | 108 | // really dirty way to get the RSSI out of the display |
|
- | 109 | #ifdef ACT_RSSI_FROM_LCD |
|
- | 110 | #define REQUEST_FC_LCD_8 "#al?===Dc\r" |
|
- | 111 | usart1_request_blocking('L', PSTR(REQUEST_FC_LCD_8)); |
|
- | 112 | char* str = ((char*)pRxData) + 2; |
|
- | 113 | /* |
|
- | 114 | write_ascii_string_len(2, 5, str, 20); |
|
- | 115 | write_ascii_string_len(2, 6, str + 20, 20); |
|
- | 116 | write_ascii_string_len(2, 7, str + 40, 20); |
|
- | 117 | write_ascii_string_len(2, 8, str + 60, 20); |
|
- | 118 | */ |
|
- | 119 | uint8_t rssi_index = 30; // middle of 2nd line |
|
- | 120 | while (str[rssi_index] == 0) rssi_index++; |
|
- | 121 | int lcd_rssi = atoi(str[rssi_index]); |
|
- | 122 | write_ndigit_number_u(7, top_line, lcd_rssi, 3, 0); |
|
- | 123 | rc_quality = lcd_rssi; |
|
- | 124 | ||
- | 125 | #endif |
|
100 | 126 | ||
101 | return 0; |
127 | return 0; |
102 | } |
128 | } |
103 | 129 | ||
104 | #endif |
130 | #endif |
105 | 131 |