Removed InputDispatcher, add lots of more changevaluedisplays for wifi

This commit is contained in:
2021-12-30 06:00:04 +01:00
parent 973fb66985
commit b1de1de93a
33 changed files with 762 additions and 1342 deletions

View File

@@ -1,7 +1,20 @@
#include "bobbybuttons.h"
// esp-idf includes
#include <esp_log.h>
// local includes
#include "newsettings.h"
#include "settingsutils.h"
#include "modes/defaultmode.h"
#ifdef FEATURE_LEDSTRIP
#include "ledstripdefines.h"
#include "ledstrip.h"
#endif
namespace {
constexpr const char TAG[] = "BUTTONS";
} // namespace
[[nodiscard]] std::optional<espgui::Button> translateRawButton(uint8_t button)
{
@@ -35,6 +48,8 @@
if (configs.dpadMappingDown2.value == button)
return Button(BobbyButton::Down2);
ESP_LOGW(TAG, "unknown raw button %hhu", button);
return std::nullopt;
}
@@ -42,14 +57,64 @@ void buttonPressedCommon(espgui::Button button)
{
switch (BobbyButton(button))
{
case BobbyButton::Profile0: /* TODO */ break;
case BobbyButton::Profile1: /* TODO */ break;
case BobbyButton::Profile2: /* TODO */ break;
case BobbyButton::Profile3: /* TODO */ break;
case BobbyButton::Left2: /* TODO */ break;
case BobbyButton::Right2: /* TODO */ break;
case BobbyButton::Up2: /* TODO */ break;
case BobbyButton::Down2: /* TODO */ break;
case BobbyButton::Profile0:
settingsutils::switchProfile(0);
break;
case BobbyButton::Profile1:
settingsutils::switchProfile(1);
break;
case BobbyButton::Profile2:
settingsutils::switchProfile(2);
break;
case BobbyButton::Profile3:
settingsutils::switchProfile(3);
break;
case BobbyButton::Left2:
#ifdef FEATURE_LEDSTRIP
if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to left
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
}
else if (blinkAnimation == LEDSTRIP_OVERWRITE_BLINKRIGHT) // transition to warning
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH;
}
else // transition to off
{
blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
}
#endif
break;
case BobbyButton::Right2:
#ifdef FEATURE_LEDSTRIP
if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to right
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
}
else if (blinkAnimation == LEDSTRIP_OVERWRITE_BLINKLEFT) // transition to warning
{
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH;
}
else // transition to off
{
blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
}
#endif
break;
case BobbyButton::Up2:
if (settings.handbremse.enable)
{
using namespace handbremse;
if (stateWish == StateWish::brake || angezogen)
stateWish = StateWish::release;
else
stateWish = StateWish::brake;
wishTimer = espchrono::millis_clock::now();
}
break;
case BobbyButton::Down2:
/* TODO */
break;
default:;
}
}