new file: .gitignore new file: .vscode/extensions.json new file: ErsterTest.code-workspace new file: include/README new file: lib/AnalogFiveButtons/AnalogFiveButtons.cpp new file: lib/AnalogFiveButtons/AnalogFiveButtons.h new file: lib/Imotor/Imotor.cpp new file: lib/Imotor/Imotor.h new file: lib/L298n/L298n.cpp new file: lib/L298n/L298n.h new file: lib/README new file: lib/fahrt/fahrt.cpp new file: lib/fahrt/fahrt.h new file: lib/gleis/gleis.cpp new file: lib/gleis/gleis.h new file: lib/gleisabschnitt/gleisabschnitt.cpp new file: lib/gleisabschnitt/gleisabschnitt.h new file: lib/locomotive/locomotive.cpp new file: lib/locomotive/locomotive.h new file: lib/motor/dfquad.h new file: lib/motor/motor.cpp new file: lib/motor/motor.h new file: lib/weiche/weiche.cpp new file: lib/weiche/weiche.h new file: platformio.ini new file: src/main.cpp new file: test/README
65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
// ensure this library description is only included once
|
|
#ifndef A5Bdb_h
|
|
#define A5Bdb_h
|
|
|
|
#include <inttypes.h>
|
|
|
|
#define SW1 1
|
|
#define SW2 2
|
|
#define SW3 3
|
|
#define SW4 4
|
|
#define SW5 5
|
|
#define SW_NO_PUSH 0
|
|
#define SW_NO_CHANGE 255
|
|
|
|
#define BTN_LEFT 1
|
|
#define BTN_UP 2
|
|
#define BTN_DOWN 3
|
|
#define BTN_RIGHT 4
|
|
#define BTN_FIRE 5
|
|
#define BTN_SELECT 5
|
|
#define BTN_NO_PUSH 0
|
|
#define BTN_NO_CHANGE 255
|
|
|
|
|
|
// Module selection
|
|
#define KEYES_AD_KEY 0
|
|
#define LCD_KEYPAD 1
|
|
|
|
|
|
class AnalogFiveButtonsDebounce
|
|
{
|
|
public:
|
|
// analogPin : where is the keypad analog pin is connected (A0, A1..)
|
|
// typeOfModule: 0-red Keyes_AD_Key module, 1-LCD Keypad module
|
|
AnalogFiveButtonsDebounce(uint8_t , uint8_t );
|
|
// Custom defined module
|
|
// Parameters: analogue pin, failure rate, left value, up value, down value, right value, fire value
|
|
AnalogFiveButtonsDebounce(uint8_t , uint8_t , int , int , int , int , int );
|
|
// Returns: - actually pressed key (1-5)
|
|
// - 0 if no key is pressed
|
|
uint8_t getButton();
|
|
// Returns: - the changed key (1-5)
|
|
// - 0 if no key is pressed
|
|
// - 255 if nothing is changed
|
|
uint8_t changedButton();
|
|
|
|
private:
|
|
// Values of buttons
|
|
int _sw1Value, _sw2Value, _sw3Value, _sw4Value, _sw5Value;
|
|
// The analog pin number (A0, A1...)
|
|
uint8_t _analogPin;
|
|
// Failure Rate, default 10
|
|
uint8_t _failureRate;
|
|
// Analog port value
|
|
int sensorValue;
|
|
uint8_t oldKey, newKey, lastflickerablekey;
|
|
unsigned long lastdebouncetime;
|
|
const uint8_t DEBOUNCEDELAY=50;
|
|
void init(uint8_t , uint8_t , int , int , int , int , int );
|
|
void evalButton();
|
|
|
|
};
|
|
|
|
#endif
|