Combine rotary with canned messages.

This commit is contained in:
Balazs Kelemen
2022-01-09 10:08:31 +01:00
parent c7e62142e9
commit 772dfe39dc
7 changed files with 184 additions and 218 deletions

View File

@@ -1,28 +1,30 @@
#pragma once
//#include <Arduino.h>
//#include "Observer.h"
#include "SinglePortPlugin.h"
#include "HardwareInput.h"
enum RotaryEncoderInterruptBaseStateType
{
EVENT_OCCURRED,
EVENT_CLEARED
ROTARY_EVENT_OCCURRED,
ROTARY_EVENT_CLEARED
};
enum RotaryEncoderInterruptBaseActionType
{
ACTION_NONE,
ACTION_PRESSED,
ACTION_CW,
ACTION_CCW
ROTARY_ACTION_NONE,
ROTARY_ACTION_PRESSED,
ROTARY_ACTION_CW,
ROTARY_ACTION_CCW
};
class RotaryEncoderInterruptBase :
public SinglePortPlugin,
public Observable<const InputEvent *>,
private concurrency::OSThread
{
public:
RotaryEncoderInterruptBase(
const char *name,
uint8_t pinA, uint8_t pinB, uint8_t pinPress,
char eventCw, char eventCcw, char eventPressed,
// std::function<void(void)> onIntA, std::function<void(void)> onIntB, std::function<void(void)> onIntPress);
@@ -33,11 +35,11 @@ class RotaryEncoderInterruptBase :
protected:
virtual int32_t runOnce();
volatile RotaryEncoderInterruptBaseStateType rotaryStateCW = EVENT_CLEARED;
volatile RotaryEncoderInterruptBaseStateType rotaryStateCCW = EVENT_CLEARED;
volatile RotaryEncoderInterruptBaseStateType rotaryStateCW = ROTARY_EVENT_CLEARED;
volatile RotaryEncoderInterruptBaseStateType rotaryStateCCW = ROTARY_EVENT_CLEARED;
volatile int rotaryLevelA = LOW;
volatile int rotaryLevelB = LOW;
volatile RotaryEncoderInterruptBaseActionType action = ACTION_NONE;
volatile RotaryEncoderInterruptBaseActionType action = ROTARY_ACTION_NONE;
private:
uint8_t _pinA;
@@ -45,6 +47,4 @@ class RotaryEncoderInterruptBase :
char _eventCw;
char _eventCcw;
char _eventPressed;
};
RotaryEncoderInterruptBase *RotaryEncoderInterruptBase;
};