Subversion Repositories Projects

Rev

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