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>
|
2019-04-13 09:05:53 +00:00
|
|
|
#include "../Utility/Debounce.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);
|
2019-04-13 09:05:53 +00:00
|
|
|
CDebounce _Debounce;
|
2018-11-21 19:40:31 +00:00
|
|
|
// handler usage
|
|
|
|
uint8_t _lastKey;
|
|
|
|
unsigned long _lastHoldTime;
|
|
|
|
unsigned long _holdTimeout;
|
|
|
|
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
|