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