-
Notifications
You must be signed in to change notification settings - Fork 1
/
keypad.h
70 lines (57 loc) · 1.6 KB
/
keypad.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* File: keypad.h
* Author: Steffis PC
*
* Created on 18. April 2013, 14:45
*/
#ifndef KEYPAD_H
#define KEYPAD_H
#ifdef __cplusplus
extern "C" {
#endif
#define Scanlines 3 // Digital Output Pins
#define Keyrows 6 // A/D-Levels to use
#define Keynum 19 // Keys on Pad + 2 for Wheel
#define KP_0 0
#define KP_1 1
#define KP_2 2
#define KP_3 3
#define KP_4 4
#define KP_5 5
#define KP_6 6
#define KP_7 7
#define KP_8 8
#define KP_9 9
#define KP_ST 10
#define KP_HT 11
#define KP_L 12
#define KP_R 13
#define KP_C 16
#define KP_GN 14
#define KP_RT 15
#define WH_U 17
#define WH_D 18
// <editor-fold defaultstate="collapsed" desc="Keypad Data struct Deklaration">
#pragma udata KP_Data
extern struct Keypad {
unsigned char Key[Keynum]; // 1 counter for each key
volatile unsigned int Scanline[Scanlines];//Buffer for the AD-Values.
volatile char DataReady;
struct { // This is the Layout and Calibration values.
char line;
unsigned int limit0;
unsigned int limit1;
} Matrix[Keynum];
} KP;
#pragma udata
// </editor-fold>
char ScanKeys(void); // Take ADC-Value and Check for Keypress
char SetKeylimit(char code, char line, unsigned int value, char limit);
void InitKeypad(void); // just set all to save values
void ScanKeypad(void); // Start the IRQ-driven Scan Process
unsigned char LoadEEPROM_KP(unsigned char block);
unsigned char SaveEEPROM_KP(unsigned char block);
#ifdef __cplusplus
}
#endif
#endif /* KEYPAD_H */