Merge pull request #59 from bobbycar-graz/58-configurable-debounce-time
Make debounce time configurable
This commit is contained in:
@ -65,6 +65,16 @@ using BremsMaxChangeScreen = makeComponent<
|
|||||||
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
using DPadDebounceChangeScreen = makeComponent<
|
||||||
|
ChangeValueDisplay<uint8_t>,
|
||||||
|
StaticText<TEXT_SETDPADDEBOUNCE>,
|
||||||
|
DPadDebounceAccessor,
|
||||||
|
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||||
|
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
|
||||||
|
>;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
struct GametrakXText : public virtual TextInterface {
|
struct GametrakXText : public virtual TextInterface {
|
||||||
public:
|
public:
|
||||||
@ -136,6 +146,9 @@ class BoardcomputerHardwareSettingsMenu :
|
|||||||
makeComponent<MenuItem, StaticText<TEXT_SETGASMAX>, SwitchScreenAction<GasMaxChangeScreen>>,
|
makeComponent<MenuItem, StaticText<TEXT_SETGASMAX>, SwitchScreenAction<GasMaxChangeScreen>>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_SETBREMSMIN>, SwitchScreenAction<BremsMinChangeScreen>>,
|
makeComponent<MenuItem, StaticText<TEXT_SETBREMSMIN>, SwitchScreenAction<BremsMinChangeScreen>>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_SETBREMSMAX>, SwitchScreenAction<BremsMaxChangeScreen>>,
|
makeComponent<MenuItem, StaticText<TEXT_SETBREMSMAX>, SwitchScreenAction<BremsMaxChangeScreen>>,
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
makeComponent<MenuItem, StaticText<TEXT_SETDPADDEBOUNCE>, SwitchScreenAction<DPadDebounceChangeScreen>>,
|
||||||
|
#endif
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
||||||
makeComponent<MenuItem, GametrakXText, DisabledColor, StaticFont<2>, DummyAction>,
|
makeComponent<MenuItem, GametrakXText, DisabledColor, StaticFont<2>, DummyAction>,
|
||||||
|
@ -78,8 +78,6 @@ void setup()
|
|||||||
{
|
{
|
||||||
uint8_t macAddress[6];
|
uint8_t macAddress[6];
|
||||||
WiFi.macAddress(&macAddress[0]);
|
WiFi.macAddress(&macAddress[0]);
|
||||||
#define STRING2(s) #s
|
|
||||||
#define STRING(s) STRING2(s)
|
|
||||||
std::sprintf(deviceName, STRING(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]);
|
std::sprintf(deviceName, STRING(DEVICE_PREFIX) "_%02hhx%02hhx%02hhx", macAddress[3], macAddress[4], macAddress[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,9 @@ constexpr Settings::BoardcomputerHardware defaultBoardcomputerHardware {
|
|||||||
.gasMax = DEFAULT_GASMAX,
|
.gasMax = DEFAULT_GASMAX,
|
||||||
.bremsMin = DEFAULT_BREMSMIN,
|
.bremsMin = DEFAULT_BREMSMIN,
|
||||||
.bremsMax = DEFAULT_BREMSMAX,
|
.bremsMax = DEFAULT_BREMSMAX,
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
.dpadDebounce = 25,
|
||||||
|
#endif
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
.gametrakXMin = DEFAULT_GAMETRAKXMIN,
|
.gametrakXMin = DEFAULT_GAMETRAKXMIN,
|
||||||
.gametrakXMax = DEFAULT_GAMETRAKXMAX,
|
.gametrakXMax = DEFAULT_GAMETRAKXMAX,
|
||||||
|
@ -165,6 +165,9 @@ union X {
|
|||||||
GasMaxChangeScreen changeGasMax;
|
GasMaxChangeScreen changeGasMax;
|
||||||
BremsMinChangeScreen changeBremsMin;
|
BremsMinChangeScreen changeBremsMin;
|
||||||
BremsMaxChangeScreen changeBremsMax;
|
BremsMaxChangeScreen changeBremsMax;
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
DPadDebounceChangeScreen dPadDebounceChangeScreen;
|
||||||
|
#endif
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
GametrakXMinChangeScreen changeGametrakXMin;
|
GametrakXMinChangeScreen changeGametrakXMin;
|
||||||
GametrakXMaxChangeScreen changeGametrakXMax;
|
GametrakXMaxChangeScreen changeGametrakXMax;
|
||||||
@ -305,6 +308,9 @@ template<> decltype(displays.changeGasMin) &
|
|||||||
template<> decltype(displays.changeGasMax) &getRefByType<decltype(displays.changeGasMax)>() { return displays.changeGasMax; }
|
template<> decltype(displays.changeGasMax) &getRefByType<decltype(displays.changeGasMax)>() { return displays.changeGasMax; }
|
||||||
template<> decltype(displays.changeBremsMin) &getRefByType<decltype(displays.changeBremsMin)>() { return displays.changeBremsMin; }
|
template<> decltype(displays.changeBremsMin) &getRefByType<decltype(displays.changeBremsMin)>() { return displays.changeBremsMin; }
|
||||||
template<> decltype(displays.changeBremsMax) &getRefByType<decltype(displays.changeBremsMax)>() { return displays.changeBremsMax; }
|
template<> decltype(displays.changeBremsMax) &getRefByType<decltype(displays.changeBremsMax)>() { return displays.changeBremsMax; }
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
template<> decltype(displays.dPadDebounceChangeScreen) &getRefByType<decltype(displays.dPadDebounceChangeScreen)>() { return displays.dPadDebounceChangeScreen; }
|
||||||
|
#endif
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
template<> decltype(displays.changeGametrakXMin) &getRefByType<decltype(displays.changeGametrakXMin)>() { return displays.changeGametrakXMin; }
|
template<> decltype(displays.changeGametrakXMin) &getRefByType<decltype(displays.changeGametrakXMin)>() { return displays.changeGametrakXMin; }
|
||||||
template<> decltype(displays.changeGametrakXMax) &getRefByType<decltype(displays.changeGametrakXMax)>() { return displays.changeGametrakXMax; }
|
template<> decltype(displays.changeGametrakXMax) &getRefByType<decltype(displays.changeGametrakXMax)>() { return displays.changeGametrakXMax; }
|
||||||
|
@ -44,6 +44,9 @@ struct Settings
|
|||||||
struct BoardcomputerHardware {
|
struct BoardcomputerHardware {
|
||||||
int16_t sampleCount;
|
int16_t sampleCount;
|
||||||
int16_t gasMin, gasMax, bremsMin, bremsMax;
|
int16_t gasMin, gasMax, bremsMin, bremsMax;
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
uint8_t dpadDebounce;
|
||||||
|
#endif
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
int16_t gametrakXMin, gametrakXMax, gametrakYMin, gametrakYMax, gametrakDistMin, gametrakDistMax;
|
int16_t gametrakXMin, gametrakXMax, gametrakYMin, gametrakYMax, gametrakDistMin, gametrakDistMax;
|
||||||
#endif
|
#endif
|
||||||
@ -116,6 +119,9 @@ void Settings::executeForEverySetting(T &&callable)
|
|||||||
callable("gasMax", boardcomputerHardware.gasMax);
|
callable("gasMax", boardcomputerHardware.gasMax);
|
||||||
callable("bremsMin", boardcomputerHardware.bremsMin);
|
callable("bremsMin", boardcomputerHardware.bremsMin);
|
||||||
callable("bremsMax", boardcomputerHardware.bremsMax);
|
callable("bremsMax", boardcomputerHardware.bremsMax);
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
callable("dpadDebounce", boardcomputerHardware.dpadDebounce);
|
||||||
|
#endif
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
callable("gametrakXMin", boardcomputerHardware.gametrakXMin);
|
callable("gametrakXMin", boardcomputerHardware.gametrakXMin);
|
||||||
callable("gametrakXMax", boardcomputerHardware.gametrakXMax);
|
callable("gametrakXMax", boardcomputerHardware.gametrakXMax);
|
||||||
|
@ -60,6 +60,9 @@ struct GasMinAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRe
|
|||||||
struct GasMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gasMax; } };
|
struct GasMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gasMax; } };
|
||||||
struct BremsMinAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.bremsMin; } };
|
struct BremsMinAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.bremsMin; } };
|
||||||
struct BremsMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.bremsMax; } };
|
struct BremsMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.bremsMax; } };
|
||||||
|
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||||
|
struct DPadDebounceAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.boardcomputerHardware.dpadDebounce; } };
|
||||||
|
#endif
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
struct GametrakXMinAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gametrakXMin; } };
|
struct GametrakXMinAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gametrakXMin; } };
|
||||||
struct GametrakXMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gametrakXMax; } };
|
struct GametrakXMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gametrakXMax; } };
|
||||||
|
@ -234,6 +234,7 @@ constexpr char TEXT_SETGASMIN[] = "Set gasMin";
|
|||||||
constexpr char TEXT_SETGASMAX[] = "Set gasMax";
|
constexpr char TEXT_SETGASMAX[] = "Set gasMax";
|
||||||
constexpr char TEXT_SETBREMSMIN[] = "Set bremsMin";
|
constexpr char TEXT_SETBREMSMIN[] = "Set bremsMin";
|
||||||
constexpr char TEXT_SETBREMSMAX[] = "Set bremsMax";
|
constexpr char TEXT_SETBREMSMAX[] = "Set bremsMax";
|
||||||
|
constexpr char TEXT_SETDPADDEBOUNCE[] = "Set dpadDebounce";
|
||||||
constexpr char TEXT_GAMETRAKCALIBRATE[] = "Gametrak calibrate";
|
constexpr char TEXT_GAMETRAKCALIBRATE[] = "Gametrak calibrate";
|
||||||
constexpr char TEXT_SETGAMETRAKXMIN[] = "Set gametrakXMin";
|
constexpr char TEXT_SETGAMETRAKXMIN[] = "Set gametrakXMin";
|
||||||
constexpr char TEXT_SETGAMETRAKXMAX[] = "Set gametrakXMax";
|
constexpr char TEXT_SETGAMETRAKXMAX[] = "Set gametrakXMax";
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
|
// macros are a shit piece of software
|
||||||
|
#define STRING2(s) #s
|
||||||
|
#define STRING(s) STRING2(s)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool currentlyReverseBeeping;
|
bool currentlyReverseBeeping;
|
||||||
bool reverseBeepToggle;
|
bool reverseBeepToggle;
|
||||||
|
Reference in New Issue
Block a user