2018-11-26 11:58:15 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the "bluetoothheater" distribution
|
|
|
|
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-11-21 09:53:12 +00:00
|
|
|
#ifndef __BTC_KEYPAD_H__
|
|
|
|
#define __BTC_KEYPAD_H__
|
|
|
|
|
2018-12-16 07:34:39 +00:00
|
|
|
#include <stdint.h>
|
2018-11-21 09:53:12 +00:00
|
|
|
|
|
|
|
|
2018-11-22 10:30:51 +00:00
|
|
|
const uint8_t key_Left = 0x01;
|
|
|
|
const uint8_t key_Right = 0x02;
|
|
|
|
const uint8_t key_Centre = 0x04;
|
|
|
|
const uint8_t key_Up = 0x08;
|
|
|
|
const uint8_t key_Down = 0x10;
|
|
|
|
const uint8_t keyPressed = 0x20; // action flag
|
|
|
|
const uint8_t keyReleased = 0x40; // action flag
|
|
|
|
const uint8_t keyRepeat = 0x80; // action flag
|
2018-11-21 19:40:31 +00:00
|
|
|
|
|
|
|
class CKeyPad {
|
|
|
|
private:
|
|
|
|
void (*_keyCallback)(uint8_t event);
|
|
|
|
uint8_t _pins[5]; //0:L, 1:R, 2:C, 3:U, 4:D
|
|
|
|
// pin scanning usage
|
|
|
|
uint8_t _prevPins;
|
|
|
|
uint8_t _debouncedPins;
|
|
|
|
// handler usage
|
|
|
|
uint8_t _lastKey;
|
|
|
|
unsigned long _lastHoldTime;
|
|
|
|
unsigned long _holdTimeout;
|
|
|
|
uint8_t scanPins();
|
|
|
|
unsigned long _lastDebounceTime;
|
|
|
|
unsigned long _debounceDelay;
|
|
|
|
public:
|
|
|
|
CKeyPad();
|
2018-12-12 10:37:02 +00:00
|
|
|
void begin(int Lkey, int Rkey, int Ckey, int Ukey, int Dkey);
|
2018-11-21 19:40:31 +00:00
|
|
|
uint8_t update();
|
|
|
|
void setCallback(void (*Callback)(uint8_t event));
|
|
|
|
};
|
2018-11-21 09:53:12 +00:00
|
|
|
|
2018-11-22 10:30:51 +00:00
|
|
|
extern CKeyPad KeyPad;
|
|
|
|
|
2018-11-21 09:53:12 +00:00
|
|
|
#endif
|