Better tactile processing

This commit is contained in:
Pawel Spychalski
2018-05-14 16:17:38 +02:00
parent 2fc84c78c5
commit b5cc91c814
4 changed files with 86 additions and 46 deletions

30
crossbow/tactile.h Normal file
View File

@@ -0,0 +1,30 @@
#pragma once
#ifndef TACTILE_H
#define TACTILE_H
#include "Arduino.h"
enum tactileStateFlags {
TACTILE_STATE_NONE,
TACTILE_STATE_SHORT_PRESS,
TACTILE_STATE_LONG_PRESS
};
#define TACTILE_MIN_PRESS_TIME 50
#define TACTILE_LONG_PRESS_TIME 1000
class Tactile {
public:
Tactile(uint8_t pin);
void loop(void);
void start(void);
uint8_t getState(void);
private:
uint8_t _pin;
uint8_t _previousPinState = HIGH;
uint32_t _pressMillis = 0;
uint8_t _state = TACTILE_STATE_NONE;
};
#endif