Rev 523 | Rev 728 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
346 | cascade | 1 | /**************************************************************************** |
2 | * Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje * |
||
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 | |||
497 | cascade | 21 | #include <avr/pgmspace.h> |
22 | #include "mk-data-structs.h" |
||
23 | |||
346 | cascade | 24 | /* ########################################################################## |
25 | * Debugging and general purpose definitions |
||
26 | * ##########################################################################*/ |
||
459 | cascade | 27 | #ifndef BUILDDATE |
28 | #define BUILDDATE "DEVEL-BUILD" // build date, this is testing... |
||
29 | #endif |
||
346 | cascade | 30 | |
459 | cascade | 31 | #define ALLCHARSDEBUG 0 // set to 1 and flash firmware to see all chars |
32 | |||
33 | #ifndef WRITECHARS // if WRITECHARS not set via makefile |
||
514 | cascade | 34 | #define WRITECHARS -1 // set to 1 and flash firmware to write all chars |
346 | cascade | 35 | #endif |
36 | |||
459 | cascade | 37 | #ifndef NTSC // if NTSC is not thet via makefile |
38 | #define NTSC 0 // set to 1 for NTSC mode + lifts the bottom line |
||
346 | cascade | 39 | #endif |
40 | |||
459 | cascade | 41 | #ifndef FCONLY |
460 | cascade | 42 | #define FCONLY 0 // set to 1 if you do NOT have a NaviCtrl and the OSD is |
495 | cascade | 43 | #endif // connected to the FC directly |
459 | cascade | 44 | |
497 | cascade | 45 | #define HUD 1 // set to 0 to disable HUD by default |
346 | cascade | 46 | #define ARTHORIZON 0 // set to 1 to enable roll&nick artificial horizon by default |
383 | cascade | 47 | #define BIGVARIO 0 // set to 1 to enable the big vario bar on right side |
346 | cascade | 48 | #define STATS 1 // set to 1 to enable statistics during motor off by default |
49 | #define WARNINGS 1 // set to 1 to display battery+rc warning even if HUD is disabled |
||
50 | |||
453 | cascade | 51 | //#define UBAT_WRN 94 // voltage for blinking warning, like FC settings (deprecated) |
52 | //#define UBAT_MAX 114 // maximal battery voltage for battery-sign (deprecated) |
||
53 | #define CELL_VOLT_MAX 37 // max voltage per battery cell (37 for LiPo) |
||
54 | #define CELL_VOLT_MIN 32 // min voltage per battery cell (maybe 32 for LiPo?) |
||
55 | #define CELL_NUM -1 // -1 for auto, 3 for 3s1p and 4 for 4s1p |
||
346 | cascade | 56 | #define RCLVL_WRN 100 // make the RC level blink if below this number |
57 | |||
58 | // ### read datasheet before changing stuff below this line :) |
||
59 | #define BLINK 0b01001111 // attribute byte for blinking chars |
||
60 | |||
61 | /* ########################################################################## |
||
471 | cascade | 62 | * FLAGS usable during runtime that get saved |
346 | cascade | 63 | * ##########################################################################*/ |
523 | cascade | 64 | #define COSD_FLAG_HUD 1 |
65 | #define COSD_FLAG_ARTHORIZON 2 |
||
66 | #define COSD_FLAG_BIGVARIO 4 |
||
67 | #define COSD_FLAG_STATS 8 |
||
68 | #define COSD_FLAG_WARNINGS 16 |
||
69 | #define COSD_FLAG_STROMVOLT 32 |
||
70 | |||
407 | cascade | 71 | #define COSD_FLAG_NTSC 1 |
523 | cascade | 72 | #define COSD_FLAG_GPSHEIGHT 2 |
73 | #define COSD_FLAG_FCMODE 4 |
||
346 | cascade | 74 | |
471 | cascade | 75 | /* ########################################################################## |
76 | * FLAGS only usable during runtime (not saved) |
||
77 | * ##########################################################################*/ |
||
465 | cascade | 78 | #define COSD_FLAG_STROMREC 1 |
471 | cascade | 79 | #define COSD_ICONS_WRITTEN 2 |
80 | #define COSD_WASFLYING 4 |
||
465 | cascade | 81 | |
346 | cascade | 82 | /* ########################################################################## |
83 | * LED controll |
||
84 | * ##########################################################################*/ |
||
85 | #define LED1_ON PORTC |= (1 << PC0); |
||
86 | #define LED1_OFF PORTC &= ~(1 << PC0); |
||
87 | #define LED2_ON PORTC |= (1 << PC1); |
||
88 | #define LED2_OFF PORTC &= ~(1 << PC1); |
||
89 | #define LED3_ON PORTC |= (1 << PC2); |
||
90 | #define LED3_OFF PORTC &= ~(1 << PC2); |
||
91 | #define LED4_ON PORTC |= (1 << PC3); |
||
92 | #define LED4_OFF PORTC &= ~(1 << PC3); |
||
93 | |||
94 | /* ########################################################################## |
||
95 | * switch controll |
||
96 | * ##########################################################################*/ |
||
97 | #define S1_PRESSED !(PINC & (1<<PC5)) |
||
98 | #define S2_PRESSED !(PINC & (1<<PC4)) |
||
99 | |||
471 | cascade | 100 | /* ########################################################################## |
101 | * extern spi controlled vars |
||
102 | * ##########################################################################*/ |
||
103 | extern volatile uint16_t icnt; |
||
104 | extern volatile unsigned char * iptr; |
||
507 | cascade | 105 | extern volatile uint8_t spi_cmd_buffer[]; |
471 | cascade | 106 | extern volatile uint8_t spi_ready; |
507 | cascade | 107 | extern int16_t ampere, max_ampere, s_volt; |
471 | cascade | 108 | extern int32_t ampere_wasted; |
109 | |||
497 | cascade | 110 | /* ########################################################################## |
111 | * struct for displaymodes |
||
112 | * ##########################################################################*/ |
||
113 | typedef struct { |
||
114 | int (*dfun)(void); // function pointer |
||
115 | char *desc; // description text |
||
116 | } displaymode_t; |
||
117 | |||
118 | const displaymode_t ncdisplaymodes[2]; |
||
685 | cascade | 119 | const displaymode_t fcdisplaymodes[2]; |
497 | cascade | 120 | |
121 | int (*osd_ncmode)(void); |
||
122 | int (*osd_fcmode)(void); |
||
123 | |||
124 | /* ########################################################################## |
||
125 | * vars used by other parts as well |
||
126 | * ##########################################################################*/ |
||
127 | volatile uint16_t setsReceived; |
||
128 | |||
129 | volatile NaviData_t naviData; |
||
130 | volatile DebugOut_t debugData; |
||
131 | |||
132 | // cache old vars for blinking attribute, checkup is faster than full |
||
133 | // attribute write each time |
||
134 | volatile uint8_t last_UBat; |
||
135 | volatile uint8_t last_RC_Quality; |
||
136 | |||
137 | // 16bit should be enough, normal LiPos don't last that long |
||
138 | volatile uint16_t uptime; |
||
139 | volatile uint16_t timer; |
||
685 | cascade | 140 | volatile uint16_t flytime_fc; |
497 | cascade | 141 | |
142 | // remember last time data was received |
||
143 | volatile uint8_t seconds_since_last_data; |
||
144 | |||
145 | // general PAL|NTSC distingiusch stuff |
||
146 | uint8_t top_line; |
||
147 | uint8_t bottom_line; |
||
148 | |||
149 | // battery voltages |
||
150 | uint8_t min_voltage; |
||
151 | uint8_t max_voltage; |
||
152 | |||
153 | // Flags |
||
523 | cascade | 154 | uint8_t COSD_FLAGS_MODES, COSD_FLAGS_CONFIG, COSD_FLAGS_RUNTIME, COSD_DISPLAYMODE; |
497 | cascade | 155 | |
156 | // stats for after flight |
||
523 | cascade | 157 | int16_t max_Altimeter, altimeter_offset; |
497 | cascade | 158 | uint8_t min_UBat; |
159 | |||
160 | uint16_t max_GroundSpeed; |
||
161 | int16_t max_Distance; |
||
162 | uint16_t max_FlyingTime; |
||
163 | |||
164 | // flags from last round to check for changes |
||
165 | uint8_t old_MKFlags; |
||
166 | |||
167 | const char *directions[8]; |
||
499 | cascade | 168 | const char *stats_item_pointers[8]; |