-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLCD_Keypad.h
65 lines (58 loc) · 1.61 KB
/
LCD_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
/**
* @file LCD_Keypad.h
* @version 1.0
*
* @section License
* Copyright (C) 2017, Mikael Patel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#ifndef LCD_KEYPAD_H
#define LCD_KEYPAD_H
#include "LCD.h"
#include "GPIO.h"
#include "Keypad.h"
#include "Driver/HD44780.h"
#include "Adapter/PP7W.h"
/**
* Device driver for the LCD_Keypad Shield with HD44780 16x2 display
* and five keys (SELECT, UP, DOWN, LEFT, and RIGHT).
*/
class LCD_Keypad : public Keypad<A0>, public HD44780 {
public:
enum {
NO_KEY = 0,
SELECT_KEY,
LEFT_KEY,
DOWN_KEY,
UP_KEY,
RIGHT_KEY
} __attribute__((packed));
/** Construct shield with device driver and keypad handler. **/
LCD_Keypad() : Keypad(keymap()), HD44780(m_io) {}
protected:
/** Parallel Port Adapter for shield. */
LCD::PP7W<BOARD::D4, BOARD::D5, BOARD::D6, BOARD::D7,
BOARD::D8, BOARD::D9, BOARD::D10> m_io;
/**
* Return key map, program memory vector in descent order.
* @return key map.
*/
const uint16_t* keymap()
__attribute__((always_inline))
{
static const uint16_t map[] PROGMEM = {
1000, 700, 400, 300, 100, 0
};
return (map);
}
};
#endif