Subversion Repositories Projects

Rev

Rev 1437 | Rev 1866 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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