Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2136 - 1
/*****************************************************************************
2
 *   Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de                  *
3
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
4
 *   based on the key handling by Peter Dannegger                            *
5
 *     see www.mikrocontroller.net                                           *
6
 *   Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
7
 *   Copyright (C) 2011 Harald Bongartz                                      *
8
 *                                                                           *
9
 *   This program is free software; you can redistribute it and/or modify    *
10
 *   it under the terms of the GNU General Public License as published by    *
11
 *   the Free Software Foundation; either version 2 of the License.          *
12
 *                                                                           *
13
 *   This program is distributed in the hope that it will be useful,         *
14
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
15
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
16
 *   GNU General Public License for more details.                            *
17
 *                                                                           *
18
 *   You should have received a copy of the GNU General Public License       *
19
 *   along with this program; if not, write to the                           *
20
 *   Free Software Foundation, Inc.,                                         *
21
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
22
 *                                                                           *
23
 *                                                                           *
24
 *   Credits to:                                                             *
25
 *   Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN  *
26
 *                          http://www.mikrokopter.de                        *
27
 *   Gregor "killagreg" Stobrawa for his version of the MK code              *
28
 *   Thomas Kaiser "thkais" for the original project. See                    *
29
 *                          http://www.ft-fanpage.de/mikrokopter/            *
30
 *                          http://forum.mikrokopter.de/topic-4061-1.html    *
31
 *   Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
32
 *                          http://www.mylifesucks.de/oss/c-osd/             *
33
 *   Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
34
 *****************************************************************************/
35
 
36
//############################################################################
37
//# HISTORY  timer.h
38
//#
39
//# 08.08.2015 CB
40
//# - add: timer_nmea_timeout
41
//#
42
//# 24.06.2014 OG
43
//# - add: timer_gauge
44
//#
45
//# 13.06.2014 OG
46
//# - del: IdleTimer entfernt da nicht verwendet
47
//#
48
//# 31.05.2014 OG
49
//# - chg: 'timer_pktctrl' umbenannt zu 'timer_pktupdatecheck' (exklusiv fuer pkt.c)
50
//#
51
//# 25.04.2014 OG
52
//# - add: timer_get_displaydata
53
//#
54
//# 24.04.2014 OG
55
//# - add: timer1 (generischer Timer)
56
//# - add: timer3 (generischer Timer)
57
//# - add: timer_mk_timeout
58
//# - del: timer_get_erdata
59
//#
60
//# 29.03.2014 OG
61
//# - add: clear_key_all()
62
//#
63
//# 07.07.2013 OG
64
//# - chg: ABO_TIMEOUT verschoben nach main.h
65
//#
66
//# 19.05.2013 OG
67
//# - add: timer_pktctrl - exclusive Verwendung von pkt.c
68
//############################################################################
69
 
70
 
71
 
72
#ifndef _TIMER_H
73
#define _TIMER_H
74
 
75
#include "../cpu.h"
76
#include "../main.h"
77
 
78
typedef struct
79
{
80
    uint32_t    seconds;    // seconds since nnew day
81
    uint8_t     day;
82
    uint8_t     month;
83
    uint16_t    year;
84
}  PKTdatetime_t;
85
 
86
 
87
#define KEY_ALL             ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC))
88
#define LONG_MASK           ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC))
89
#define REPEAT_MASK         ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC))
90
#define LONG_REPEAT_MASK    ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC))
91
#define LONG_REPEAT_SP_MASK ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC))
92
 
93
#define REPEAT_START       70   // after 700ms
94
#define REPEAT_NEXT        15   // every 150ms
95
#define REPEAT_SPEED_1     20   // every 200ms
96
#define REPEAT_SPEED_2      8   // every  80ms
97
#define REPEAT_SPEED_3      1   // every  10ms
98
 
99
#define BeepNormal          0   // Normal Beep
100
#define BeepSevere          1   // schwerer Fehler, Beep nicht unterbrechbar
101
#define BeepOff             2   // Beep aus
102
 
103
extern volatile uint8_t Display_on;
104
 
105
extern volatile PKTdatetime_t   UTCTime;
106
 
107
//----------------------
108
// generische Timer
109
//----------------------
110
extern volatile uint16_t timer;
111
extern volatile uint16_t timer1;
112
extern volatile uint16_t timer2;
113
extern volatile uint16_t timer3;
114
 
115
//----------------------
116
// spezielle Timer
117
//----------------------
118
extern volatile uint32_t timer_pkt_uptime;
119
extern volatile uint16_t timer_pktupdatecheck;      // verwendet von pkt.c (!EXKLUSIV! FUER NICHTS ANDERES!)
120
extern volatile uint16_t timer_osd_refresh;
121
extern volatile uint16_t timer_get_bldata;
122
extern volatile uint16_t timer_get_tidata;
123
extern volatile uint16_t timer_get_displaydata;
124
extern volatile uint16_t timer_mk_timeout;          // verwendet u.a. in osd.c
125
extern volatile uint16_t timer_gauge;              // verwendet in pkt.c fuer den rotierenden Wartekreisel
126
extern volatile uint16_t abo_timer;
127
extern volatile uint16_t timer_nmea_timeout;       // verwendet in nmea.c
128
 
129
extern volatile uint16_t sound_timer;
130
extern volatile uint16_t soundpause_timer;
131
//extern volatile uint16_t WarnCount;
132
 
133
 
134
 
135
 
136
//extern volatile unsigned int BeepTime;
137
extern unsigned int BeepTime;
138
extern unsigned int BeepMuster;
139
 
140
 
141
/**
142
* Get the value of the system timer counter.
143
*
144
* @return The value of the system timer counter.
145
*/
146
uint16_t timer_get_system_count(void);
147
 
148
void Timer0_Init (void);  // Systeminterrupt
149
void Timer1_Init (void);  // Servotester
150
void Timer2_Init (void);  // Displayhelligkeit
151
void Timer3_Init (void);  // Überwachung
152
uint8_t get_key_press (uint8_t key_mask);  // sofort beim drücken
153
uint8_t get_key_short (uint8_t key_mask);  // erst beim loslassen
154
uint8_t get_key_long (uint8_t key_mask);  // verzögert
155
uint8_t get_key_rpt (uint8_t key_mask);  // mit verzögerung
156
uint8_t get_key_long_rpt (uint8_t key_mask);  //
157
uint8_t get_key_long_rpt_sp (uint8_t key_mask, uint8_t key_speed);  // mit verzögerung und 3 versch. geschw.
158
void clear_key_all( void );
159
 
160
void set_beep ( uint16_t Time, uint16_t Muster, uint8_t Prio);
161
extern volatile unsigned int CountMilliseconds;
162
 
163
 
164
void Delay_ms(unsigned int);
165
unsigned int SetDelay (unsigned int t);
166
char CheckDelay (unsigned int t);
167
void LipoCheck (void); // Lowbatpin des Spannungswandlers prüfen
168
 
169
 
170
#endif