mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-16 01:52:04 +00:00
Drop the wrapper classes
This commit is contained in:
parent
f12145908d
commit
bc934e3659
@ -31,6 +31,8 @@ bool ButtonThread::initButton(uint8_t pinNumber, bool activeLow, bool activePull
|
||||
input_broker_event singlePress, input_broker_event longPress, input_broker_event doublePress,
|
||||
input_broker_event triplePress, input_broker_event shortLong, bool touchQuirk)
|
||||
{
|
||||
if (inputBroker)
|
||||
inputBroker->registerSource(this);
|
||||
_pinNum = pinNumber;
|
||||
_activeLow = activeLow;
|
||||
_touchQuirk = touchQuirk;
|
||||
|
@ -1,15 +0,0 @@
|
||||
#include "ButtonThreadImpl.h"
|
||||
#include "InputBroker.h"
|
||||
#include "configuration.h"
|
||||
|
||||
ButtonThreadImpl::ButtonThreadImpl(char *_name) : ButtonThread(_name) {}
|
||||
|
||||
void ButtonThreadImpl::init(uint8_t pinNumber, bool activeLow, bool activePullup, uint32_t pullupSense, voidFuncPtr intRoutine,
|
||||
input_broker_event singlePress, input_broker_event longPress, input_broker_event doublePress,
|
||||
input_broker_event triplePress, input_broker_event shortLong, bool touchQuirk)
|
||||
{
|
||||
if (inputBroker)
|
||||
inputBroker->registerSource(this);
|
||||
initButton(pinNumber, activeLow, activePullup, pullupSense, intRoutine, singlePress, longPress, doublePress, triplePress,
|
||||
shortLong, touchQuirk);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include "ButtonThread.h"
|
||||
#include "main.h"
|
||||
|
||||
/**
|
||||
* @brief The idea behind this class to have static methods for the event handlers.
|
||||
* Check attachInterrupt() at RotaryEncoderInteruptBase.cpp
|
||||
* Technically you can have as many rotary encoders hardver attached
|
||||
* to your device as you wish, but you always need to have separate event
|
||||
* handlers, thus you need to have a RotaryEncoderInterrupt implementation.
|
||||
*/
|
||||
class ButtonThreadImpl : public ButtonThread
|
||||
{
|
||||
public:
|
||||
ButtonThreadImpl(char *);
|
||||
void init(uint8_t pinNumber, bool activeLow, bool activePullup, uint32_t pullupSense, voidFuncPtr intRoutine,
|
||||
input_broker_event singlePress, input_broker_event longPress = INPUT_BROKER_NONE,
|
||||
input_broker_event doublePress = INPUT_BROKER_NONE, input_broker_event triplePress = INPUT_BROKER_NONE,
|
||||
input_broker_event shortLong = INPUT_BROKER_NONE, bool touchQuirk = false);
|
||||
};
|
22
src/main.cpp
22
src/main.cpp
@ -99,18 +99,18 @@ NRF52Bluetooth *nrf52Bluetooth = nullptr;
|
||||
#endif
|
||||
|
||||
#if HAS_BUTTON || defined(ARCH_PORTDUINO)
|
||||
#include "input/ButtonThreadImpl.h"
|
||||
#include "input/ButtonThread.h"
|
||||
|
||||
#if defined(BUTTON_PIN_TOUCH)
|
||||
ButtonThreadImpl *TouchButtonThread = nullptr;
|
||||
ButtonThread *TouchButtonThread = nullptr;
|
||||
#endif
|
||||
|
||||
#if defined(BUTTON_PIN)
|
||||
ButtonThreadImpl *UserButtonThread = nullptr;
|
||||
ButtonThread *UserButtonThread = nullptr;
|
||||
#endif
|
||||
|
||||
#if defined(BACK_BUTTON_PIN)
|
||||
ButtonThreadImpl *BackButtonThread = nullptr;
|
||||
ButtonThread *BackButtonThread = nullptr;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -901,8 +901,8 @@ void setup()
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_PIN_TOUCH
|
||||
TouchButtonThread = new ButtonThreadImpl("BackButton");
|
||||
TouchButtonThread->init(
|
||||
TouchButtonThread = new ButtonThread("BackButton");
|
||||
TouchButtonThread->initButton(
|
||||
BUTTON_PIN_TOUCH, true, true, pullup_sense,
|
||||
[]() {
|
||||
TouchButtonThread->userButton.tick();
|
||||
@ -915,8 +915,8 @@ void setup()
|
||||
|
||||
#if defined(BACK_BUTTON_PIN)
|
||||
// Buttons. Moved here cause we need NodeDB to be initialized
|
||||
BackButtonThread = new ButtonThreadImpl("BackButton");
|
||||
BackButtonThread->init(
|
||||
BackButtonThread = new ButtonThread("BackButton");
|
||||
BackButtonThread->initButton(
|
||||
BACK_BUTTON_PIN, BACK_BUTTON_ACTIVE_LOW, BACK_BUTTON_ACTIVE_PULLUP, pullup_sense,
|
||||
[]() {
|
||||
BackButtonThread->userButton.tick();
|
||||
@ -942,9 +942,9 @@ void setup()
|
||||
|
||||
// Buttons. Moved here cause we need NodeDB to be initialized
|
||||
// If your variant.h has a BUTTON_PIN defined, go ahead and define BUTTON_ACTIVE_LOW and BUTTON_ACTIVE_PULLUP
|
||||
UserButtonThread = new ButtonThreadImpl("UserButton");
|
||||
UserButtonThread = new ButtonThread("UserButton");
|
||||
if (screen)
|
||||
UserButtonThread->init(
|
||||
UserButtonThread->initButton(
|
||||
_pinNum, BUTTON_ACTIVE_LOW, BUTTON_ACTIVE_PULLUP, pullup_sense,
|
||||
[]() {
|
||||
UserButtonThread->userButton.tick();
|
||||
@ -954,7 +954,7 @@ void setup()
|
||||
},
|
||||
INPUT_BROKER_USER_PRESS, INPUT_BROKER_SELECT);
|
||||
else
|
||||
UserButtonThread->init(
|
||||
UserButtonThread->initButton(
|
||||
_pinNum, BUTTON_ACTIVE_LOW, BUTTON_ACTIVE_PULLUP, pullup_sense,
|
||||
[]() {
|
||||
UserButtonThread->userButton.tick();
|
||||
|
Loading…
Reference in New Issue
Block a user