Subversion Repositories Projects

Rev

Rev 471 | Rev 497 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 471 Rev 495
1
/****************************************************************************
1
/****************************************************************************
2
 *   Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje                    *
2
 *   Copyright (C) 2009 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
/* ##########################################################################
21
/* ##########################################################################
22
 * Debugging and general purpose definitions
22
 * Debugging and general purpose definitions
23
 * ##########################################################################*/
23
 * ##########################################################################*/
24
#ifndef BUILDDATE
24
#ifndef BUILDDATE
25
#define BUILDDATE "DEVEL-BUILD" // build date, this is testing...
25
#define BUILDDATE "DEVEL-BUILD" // build date, this is testing...
26
#endif
26
#endif
27
 
27
 
28
#define ALLCHARSDEBUG 0         // set to 1 and flash firmware to see all chars
28
#define ALLCHARSDEBUG 0         // set to 1 and flash firmware to see all chars
29
 
29
 
30
#ifndef WRITECHARS              // if WRITECHARS not set via makefile
30
#ifndef WRITECHARS              // if WRITECHARS not set via makefile
31
#define WRITECHARS -1           // set to XXX and flash firmware to write new char
31
#define WRITECHARS -1           // set to XXX and flash firmware to write new char
32
                                // enables the allchars as well to see results
32
                                // enables the allchars as well to see results
33
                                // currently in use:
33
                                // currently in use:
34
                                // 112, 128, 136, 144, 152, 160, 168, 176, 184
34
                                // 112, 128, 136, 144, 152, 160, 168, 176, 184
35
                                // 192, 200, 208, 216, 224, 232
35
                                // 192, 200, 208, 216, 224, 232
36
#endif
36
#endif
37
 
37
 
38
#ifndef NTSC                    // if NTSC is not thet via makefile
38
#ifndef NTSC                    // if NTSC is not thet via makefile
39
#define NTSC 0                  // set to 1 for NTSC mode + lifts the bottom line
39
#define NTSC 0                  // set to 1 for NTSC mode + lifts the bottom line
40
#endif
40
#endif
41
 
41
 
42
#ifndef FCONLY
42
#ifndef FCONLY
43
#define FCONLY 0                // set to 1 if you do NOT have a NaviCtrl and the OSD is
43
#define FCONLY 0                // set to 1 if you do NOT have a NaviCtrl and the OSD is
44
#endif                          // connected to the FC directly
44
#endif                          // connected to the FC directly
-
 
45
 
-
 
46
#ifndef OSD_FCMODE              // set up which FCMODE to display if doing batch generating
-
 
47
#define OSD_FCMODE "osd_fcmode_default.c"       // default is a nice standard
-
 
48
#endif
-
 
49
 
-
 
50
#ifndef OSD_NCMODE              // set up which NCMODE to display if doing batch generating
-
 
51
#define OSD_NCMODE "osd_ncmode_default.c"       // default is a nice standard
-
 
52
#endif
45
 
53
 
46
#define HUD 1                   // set to 0 to disable HUD by default
54
#define HUD 1                   // set to 0 to disable HUD by default
47
#define ARTHORIZON 0            // set to 1 to enable roll&nick artificial horizon by default
55
#define ARTHORIZON 0            // set to 1 to enable roll&nick artificial horizon by default
48
#define BIGVARIO 0                      // set to 1 to enable the big vario bar on right side
56
#define BIGVARIO 0                      // set to 1 to enable the big vario bar on right side
49
#define STATS 1                         // set to 1 to enable statistics during motor off by default
57
#define STATS 1                         // set to 1 to enable statistics during motor off by default
50
#define WARNINGS 1                      // set to 1 to display battery+rc warning even if HUD is disabled
58
#define WARNINGS 1                      // set to 1 to display battery+rc warning even if HUD is disabled
51
 
59
 
52
//#define UBAT_WRN  94          // voltage for blinking warning, like FC settings (deprecated)
60
//#define UBAT_WRN  94          // voltage for blinking warning, like FC settings (deprecated)
53
//#define UBAT_MAX 114          // maximal battery voltage for battery-sign (deprecated)
61
//#define UBAT_MAX 114          // maximal battery voltage for battery-sign (deprecated)
54
#define CELL_VOLT_MAX 37        // max voltage per battery cell (37 for LiPo)
62
#define CELL_VOLT_MAX 37        // max voltage per battery cell (37 for LiPo)
55
#define CELL_VOLT_MIN 32        // min voltage per battery cell (maybe 32 for LiPo?)
63
#define CELL_VOLT_MIN 32        // min voltage per battery cell (maybe 32 for LiPo?)
56
#define CELL_NUM -1                     // -1 for auto, 3 for 3s1p and 4 for 4s1p
64
#define CELL_NUM -1                     // -1 for auto, 3 for 3s1p and 4 for 4s1p
57
#define RCLVL_WRN 100           // make the RC level blink if below this number
65
#define RCLVL_WRN 100           // make the RC level blink if below this number
58
 
66
 
59
// ### read datasheet before changing stuff below this line :)
67
// ### read datasheet before changing stuff below this line :)
60
#define BLINK   0b01001111      // attribute byte for blinking chars
68
#define BLINK   0b01001111      // attribute byte for blinking chars
61
 
69
 
62
/* ##########################################################################
70
/* ##########################################################################
63
 * FLAGS usable during runtime that get saved
71
 * FLAGS usable during runtime that get saved
64
 * ##########################################################################*/
72
 * ##########################################################################*/
65
#define COSD_FLAG_NTSC                    1
73
#define COSD_FLAG_NTSC                    1
66
#define COSD_FLAG_HUD                     2
74
#define COSD_FLAG_HUD                     2
67
#define COSD_FLAG_ARTHORIZON      4
75
#define COSD_FLAG_ARTHORIZON      4
68
#define COSD_FLAG_BIGVARIO                8
76
#define COSD_FLAG_BIGVARIO                8
69
#define COSD_FLAG_STATS                  16
77
#define COSD_FLAG_STATS                  16
70
#define COSD_FLAG_WARNINGS               32
78
#define COSD_FLAG_WARNINGS               32
71
 
79
 
72
/* ##########################################################################
80
/* ##########################################################################
73
 * FLAGS only usable during runtime (not saved)
81
 * FLAGS only usable during runtime (not saved)
74
 * ##########################################################################*/
82
 * ##########################################################################*/
75
#define COSD_FLAG_STROMREC                1
83
#define COSD_FLAG_STROMREC                1
76
#define COSD_ICONS_WRITTEN                2
84
#define COSD_ICONS_WRITTEN                2
77
#define COSD_WASFLYING                    4
85
#define COSD_WASFLYING                    4
78
 
86
 
79
/* ##########################################################################
87
/* ##########################################################################
80
 * LED controll
88
 * LED controll
81
 * ##########################################################################*/
89
 * ##########################################################################*/
82
#define LED1_ON                 PORTC |=  (1 << PC0);
90
#define LED1_ON                 PORTC |=  (1 << PC0);
83
#define LED1_OFF                PORTC &= ~(1 << PC0);
91
#define LED1_OFF                PORTC &= ~(1 << PC0);
84
#define LED2_ON                 PORTC |=  (1 << PC1);
92
#define LED2_ON                 PORTC |=  (1 << PC1);
85
#define LED2_OFF                PORTC &= ~(1 << PC1);
93
#define LED2_OFF                PORTC &= ~(1 << PC1);
86
#define LED3_ON                 PORTC |=  (1 << PC2);
94
#define LED3_ON                 PORTC |=  (1 << PC2);
87
#define LED3_OFF                PORTC &= ~(1 << PC2);
95
#define LED3_OFF                PORTC &= ~(1 << PC2);
88
#define LED4_ON                 PORTC |=  (1 << PC3);
96
#define LED4_ON                 PORTC |=  (1 << PC3);
89
#define LED4_OFF                PORTC &= ~(1 << PC3);
97
#define LED4_OFF                PORTC &= ~(1 << PC3);
90
 
98
 
91
/* ##########################################################################
99
/* ##########################################################################
92
 * switch controll
100
 * switch controll
93
 * ##########################################################################*/
101
 * ##########################################################################*/
94
#define S1_PRESSED              !(PINC & (1<<PC5))
102
#define S1_PRESSED              !(PINC & (1<<PC5))
95
#define S2_PRESSED              !(PINC & (1<<PC4))
103
#define S2_PRESSED              !(PINC & (1<<PC4))
96
 
104
 
97
/* ##########################################################################
105
/* ##########################################################################
98
 * extern spi controlled vars
106
 * extern spi controlled vars
99
 * ##########################################################################*/
107
 * ##########################################################################*/
100
extern volatile uint16_t icnt;
108
extern volatile uint16_t icnt;
101
extern volatile unsigned char * iptr;
109
extern volatile unsigned char * iptr;
102
extern volatile unsigned char spi_cmd_buffer[];
110
extern volatile unsigned char spi_cmd_buffer[];
103
extern volatile uint8_t spi_ready;
111
extern volatile uint8_t spi_ready;
104
extern int16_t ampere, max_ampere;
112
extern int16_t ampere, max_ampere;
105
extern int32_t ampere_wasted;
113
extern int32_t ampere_wasted;
106
 
114
 
107
 
115