Subversion Repositories Projects

Rev

Rev 2039 | Rev 2225 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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