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>
|
||||
>;
|
||||
|
||||
#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
|
||||
struct GametrakXText : public virtual TextInterface {
|
||||
public:
|
||||
@ -136,6 +146,9 @@ class BoardcomputerHardwareSettingsMenu :
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETGASMAX>, SwitchScreenAction<GasMaxChangeScreen>>,
|
||||
makeComponent<MenuItem, StaticText<TEXT_SETBREMSMIN>, SwitchScreenAction<BremsMinChangeScreen>>,
|
||||
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
|
||||
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
||||
makeComponent<MenuItem, GametrakXText, DisabledColor, StaticFont<2>, DummyAction>,
|
||||
|
@ -78,8 +78,6 @@ void setup()
|
||||
{
|
||||
uint8_t macAddress[6];
|
||||
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]);
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,9 @@ constexpr Settings::BoardcomputerHardware defaultBoardcomputerHardware {
|
||||
.gasMax = DEFAULT_GASMAX,
|
||||
.bremsMin = DEFAULT_BREMSMIN,
|
||||
.bremsMax = DEFAULT_BREMSMAX,
|
||||
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||
.dpadDebounce = 25,
|
||||
#endif
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
.gametrakXMin = DEFAULT_GAMETRAKXMIN,
|
||||
.gametrakXMax = DEFAULT_GAMETRAKXMAX,
|
||||
|
@ -165,6 +165,9 @@ union X {
|
||||
GasMaxChangeScreen changeGasMax;
|
||||
BremsMinChangeScreen changeBremsMin;
|
||||
BremsMaxChangeScreen changeBremsMax;
|
||||
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||
DPadDebounceChangeScreen dPadDebounceChangeScreen;
|
||||
#endif
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
GametrakXMinChangeScreen changeGametrakXMin;
|
||||
GametrakXMaxChangeScreen changeGametrakXMax;
|
||||
@ -305,6 +308,9 @@ template<> decltype(displays.changeGasMin) &
|
||||
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.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
|
||||
template<> decltype(displays.changeGametrakXMin) &getRefByType<decltype(displays.changeGametrakXMin)>() { return displays.changeGametrakXMin; }
|
||||
template<> decltype(displays.changeGametrakXMax) &getRefByType<decltype(displays.changeGametrakXMax)>() { return displays.changeGametrakXMax; }
|
||||
|
@ -44,6 +44,9 @@ struct Settings
|
||||
struct BoardcomputerHardware {
|
||||
int16_t sampleCount;
|
||||
int16_t gasMin, gasMax, bremsMin, bremsMax;
|
||||
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||
uint8_t dpadDebounce;
|
||||
#endif
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
int16_t gametrakXMin, gametrakXMax, gametrakYMin, gametrakYMax, gametrakDistMin, gametrakDistMax;
|
||||
#endif
|
||||
@ -116,6 +119,9 @@ void Settings::executeForEverySetting(T &&callable)
|
||||
callable("gasMax", boardcomputerHardware.gasMax);
|
||||
callable("bremsMin", boardcomputerHardware.bremsMin);
|
||||
callable("bremsMax", boardcomputerHardware.bremsMax);
|
||||
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW)
|
||||
callable("dpadDebounce", boardcomputerHardware.dpadDebounce);
|
||||
#endif
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
callable("gametrakXMin", boardcomputerHardware.gametrakXMin);
|
||||
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 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; } };
|
||||
#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
|
||||
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; } };
|
||||
|
@ -234,6 +234,7 @@ constexpr char TEXT_SETGASMIN[] = "Set gasMin";
|
||||
constexpr char TEXT_SETGASMAX[] = "Set gasMax";
|
||||
constexpr char TEXT_SETBREMSMIN[] = "Set bremsMin";
|
||||
constexpr char TEXT_SETBREMSMAX[] = "Set bremsMax";
|
||||
constexpr char TEXT_SETDPADDEBOUNCE[] = "Set dpadDebounce";
|
||||
constexpr char TEXT_GAMETRAKCALIBRATE[] = "Gametrak calibrate";
|
||||
constexpr char TEXT_SETGAMETRAKXMIN[] = "Set gametrakXMin";
|
||||
constexpr char TEXT_SETGAMETRAKXMAX[] = "Set gametrakXMax";
|
||||
|
@ -9,6 +9,10 @@
|
||||
#include "display.h"
|
||||
#include "globals.h"
|
||||
|
||||
// macros are a shit piece of software
|
||||
#define STRING2(s) #s
|
||||
#define STRING(s) STRING2(s)
|
||||
|
||||
namespace {
|
||||
bool currentlyReverseBeeping;
|
||||
bool reverseBeepToggle;
|
||||
|
Reference in New Issue
Block a user