Add button calibrate display
This commit is contained in:
@ -109,7 +109,7 @@ set(headers
|
||||
displays/bobbymenudisplay.h
|
||||
displays/bobbypopupdisplay.h
|
||||
displays/bobbysplitgraphdisplay.h
|
||||
displays/calibratedisplay.h
|
||||
displays/buttoncalibratedisplay.h
|
||||
displays/calibratevoltagedisplay.h
|
||||
displays/gameoflifedisplay.h
|
||||
displays/gametrakcalibratedisplay.h
|
||||
@ -181,6 +181,7 @@ set(headers
|
||||
displays/menus/wifistasettingsmenu.h
|
||||
displays/metersdisplay.h
|
||||
displays/pingpongdisplay.h
|
||||
displays/potiscalibratedisplay.h
|
||||
displays/poweroffdisplay.h
|
||||
displays/powersupplydisplay.h
|
||||
displays/qrcodedebug.h
|
||||
@ -334,7 +335,7 @@ set(sources
|
||||
displays/bobbymenudisplay.cpp
|
||||
displays/bobbypopupdisplay.cpp
|
||||
displays/bobbysplitgraphdisplay.cpp
|
||||
displays/calibratedisplay.cpp
|
||||
displays/buttoncalibratedisplay.cpp
|
||||
displays/calibratevoltagedisplay.cpp
|
||||
displays/gameoflifedisplay.cpp
|
||||
displays/gametrakcalibratedisplay.cpp
|
||||
@ -404,6 +405,7 @@ set(sources
|
||||
displays/menus/wifistasettingsmenu.cpp
|
||||
displays/metersdisplay.cpp
|
||||
displays/pingpongdisplay.cpp
|
||||
displays/potiscalibratedisplay.cpp
|
||||
displays/poweroffdisplay.cpp
|
||||
displays/powersupplydisplay.cpp
|
||||
displays/qrcodedebug.cpp
|
||||
|
@ -14,6 +14,9 @@
|
||||
struct AutoConnectBmsAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.autoConnectBms; } };
|
||||
#endif
|
||||
|
||||
// Bluetooth
|
||||
struct BluetoothNameAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.bluetoothName; } };
|
||||
|
||||
// Buzzer
|
||||
struct ReverseBeepAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.reverseBeep; } };
|
||||
struct ReverseBeepFreq0Accessor : public NewSettingsAccessor<uint8_t> { ConfigWrapper<uint8_t> &getConfig() const override { return configs.reverseBeepFreq0; } };
|
||||
|
51
main/displays/buttoncalibratedisplay.cpp
Normal file
51
main/displays/buttoncalibratedisplay.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "buttoncalibratedisplay.h"
|
||||
|
||||
std::string ButtonCalibrateDisplay::text() const
|
||||
{
|
||||
return "TODO";
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::start()
|
||||
{
|
||||
Base::start();
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::initScreen()
|
||||
{
|
||||
Base::initScreen();
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::update()
|
||||
{
|
||||
Base::update();
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::redraw()
|
||||
{
|
||||
Base::redraw();
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::stop()
|
||||
{
|
||||
Base::stop();
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::rawButtonPressed(uint8_t button)
|
||||
{
|
||||
//Base::rawButtonPressed(button);
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::rawButtonReleased(uint8_t button)
|
||||
{
|
||||
//Base::rawButtonReleased(button);
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
//Base::buttonPressed(button);
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::buttonReleased(espgui::Button button)
|
||||
{
|
||||
//Base::buttonReleased(button);
|
||||
}
|
35
main/displays/buttoncalibratedisplay.h
Normal file
35
main/displays/buttoncalibratedisplay.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <displaywithtitle.h>
|
||||
|
||||
// local includes
|
||||
#include "globals.h"
|
||||
#include "modeinterface.h"
|
||||
#include "modes/ignoreinputmode.h"
|
||||
|
||||
class ButtonCalibrateDisplay : public espgui::DisplayWithTitle
|
||||
{
|
||||
using Base = espgui::DisplayWithTitle;
|
||||
|
||||
public:
|
||||
ButtonCalibrateDisplay() = default;
|
||||
explicit ButtonCalibrateDisplay(bool bootup) : m_bootup{bootup} {}
|
||||
|
||||
std::string text() const override;
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
void update() override;
|
||||
void redraw() override;
|
||||
void stop() override;
|
||||
|
||||
void rawButtonPressed(uint8_t button) override;
|
||||
void rawButtonReleased(uint8_t button) override;
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
void buttonReleased(espgui::Button button) override;
|
||||
|
||||
private:
|
||||
const bool m_bootup{false};
|
||||
ModeInterface *m_oldMode;
|
||||
IgnoreInputMode m_mode{0, bobbycar::protocol::ControlType::FieldOrientedControl, bobbycar::protocol::ControlMode::Torque};
|
||||
};
|
@ -8,7 +8,7 @@
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "displays/calibratedisplay.h"
|
||||
#include "displays/potiscalibratedisplay.h"
|
||||
#include "bobbybuttons.h"
|
||||
#ifdef LOCKSCREEN_PLUGIN
|
||||
#include "ledstripdefines.h"
|
||||
@ -88,7 +88,7 @@ void Lockscreen::redraw()
|
||||
if (m_numbers == settings.lockscreen.pin)
|
||||
{
|
||||
if (!gas || !brems || *gas > 200.f || *brems > 200.f)
|
||||
espgui::switchScreen<CalibrateDisplay>(true);
|
||||
espgui::switchScreen<PotisCalibrateDisplay>(true);
|
||||
else
|
||||
espgui::switchScreen<MainMenu>();
|
||||
#ifdef LOCKSCREEN_PLUGIN
|
||||
|
@ -1,11 +1,15 @@
|
||||
#include "blesettingsmenu.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include "actions/dummyaction.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "icons/back.h"
|
||||
#include <actions/dummyaction.h>
|
||||
#include <actions/switchscreenaction.h>
|
||||
#include <icons/back.h>
|
||||
#include <changevaluedisplay.h>
|
||||
#include <changevaluedisplay_string.h>
|
||||
#include <textwithvaluehelper.h>
|
||||
|
||||
// local includes
|
||||
#include "displays/bobbychangevaluedisplay.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
#include "bletexthelpers.h"
|
||||
#include "displays/menus/settingsmenu.h"
|
||||
@ -14,16 +18,27 @@
|
||||
#ifdef FEATURE_BLE
|
||||
namespace {
|
||||
constexpr char TEXT_BLESETTINGS[] = "BLE settings";
|
||||
constexpr char TEXT_BLEENABLED[] = "BLE enabled";
|
||||
constexpr char TEXT_ENABLED[] = "Enabled";
|
||||
constexpr char TEXT_NAME[] = "Name";
|
||||
constexpr char TEXT_NAME_FORMATTED[] = "Name: &s";
|
||||
constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
using ApSsidChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<std::string>,
|
||||
espgui::StaticText<TEXT_NAME>,
|
||||
BluetoothNameAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<BleSettingsMenu>>,
|
||||
espgui::BackActionInterface<espgui::SwitchScreenAction<BleSettingsMenu>>
|
||||
>;
|
||||
} // namespace
|
||||
|
||||
BleSettingsMenu::BleSettingsMenu()
|
||||
{
|
||||
using namespace espgui;
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLEENABLED>, BobbyCheckbox, BleEnabledAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLED>, BobbyCheckbox, BleEnabledAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, BleServerPeerDevicesText, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, BleCharacSubscribedText, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_NAME_FORMATTED, BluetoothNameAccessor>, SwitchScreenAction<ApSsidChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
|
@ -14,14 +14,14 @@
|
||||
#include "icons/lock.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
#include "displays/menus/lockscreensettingsmenu.h"
|
||||
#include "displays/calibratedisplay.h"
|
||||
#include "displays/potiscalibratedisplay.h"
|
||||
#include "displays/menus/timersmenu.h"
|
||||
#include "displays/menus/settingsmenu.h"
|
||||
|
||||
namespace {
|
||||
constexpr char TEXT_BOARDCOMPUTERHARDWARESETTINGS[] = "Boardcomputer H/W settings";
|
||||
constexpr char TEXT_LOCKSCREENSETTINGS[] = "Lockscreen Settings";
|
||||
constexpr char TEXT_CALIBRATE[] = "Calibrate";
|
||||
constexpr char TEXT_POTISCALIBRATE[] = "Potis Calibrate";
|
||||
constexpr char TEXT_SAMPLECOUNT[] = "sampleCount";
|
||||
constexpr char TEXT_GASMIN[] = "gasMin";
|
||||
constexpr char TEXT_GASMAX[] = "gasMax";
|
||||
@ -173,7 +173,7 @@ BoardcomputerHardwareSettingsMenu::BoardcomputerHardwareSettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKSCREENSETTINGS>, SwitchScreenAction<LockscreenSettingsMenu>, StaticMenuItemIcon<&bobbyicons::lock>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, GasText, DisabledColor, StaticFont<2>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, BremsText, DisabledColor, StaticFont<2>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CALIBRATE>, SwitchScreenAction<CalibrateDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POTISCALIBRATE>, SwitchScreenAction<PotisCalibrateDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SAMPLECOUNT, SampleCountAccessor>, SwitchScreenAction<SampleCountChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_GASMIN, GasMinAccessor>, SwitchScreenAction<GasMinChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_GASMAX, GasMaxAccessor>, SwitchScreenAction<GasMaxChangeScreen>>>();
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "calibratedisplay.h"
|
||||
#include "potiscalibratedisplay.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
@ -9,22 +9,19 @@
|
||||
#include "displays/statusdisplay.h"
|
||||
#include "displays/menus/boardcomputerhardwaresettingsmenu.h"
|
||||
#include "newsettings.h"
|
||||
#include "utils.h"
|
||||
#include "globals.h"
|
||||
|
||||
namespace {
|
||||
constexpr char TEXT_CALIBRATE[] = "Calibrate";
|
||||
constexpr char TEXT_CALIBRATE[] = "Potis Calibrate";
|
||||
} // namespace
|
||||
|
||||
CalibrateDisplay::CalibrateDisplay(bool bootup) :
|
||||
m_bootup{bootup}
|
||||
{
|
||||
}
|
||||
|
||||
std::string CalibrateDisplay::text() const
|
||||
std::string PotisCalibrateDisplay::text() const
|
||||
{
|
||||
return TEXT_CALIBRATE;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::start()
|
||||
void PotisCalibrateDisplay::start()
|
||||
{
|
||||
Base::start();
|
||||
|
||||
@ -37,7 +34,7 @@ void CalibrateDisplay::start()
|
||||
m_brems = std::nullopt;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::initScreen()
|
||||
void PotisCalibrateDisplay::initScreen()
|
||||
{
|
||||
Base::initScreen();
|
||||
|
||||
@ -56,7 +53,7 @@ void CalibrateDisplay::initScreen()
|
||||
m_renderedButton = -1;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::update()
|
||||
void PotisCalibrateDisplay::update()
|
||||
{
|
||||
Base::update();
|
||||
|
||||
@ -71,7 +68,7 @@ void CalibrateDisplay::update()
|
||||
m_brems = std::nullopt;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::redraw()
|
||||
void PotisCalibrateDisplay::redraw()
|
||||
{
|
||||
Base::redraw();
|
||||
|
||||
@ -159,7 +156,7 @@ void CalibrateDisplay::redraw()
|
||||
m_renderedButton = m_selectedButton;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::stop()
|
||||
void PotisCalibrateDisplay::stop()
|
||||
{
|
||||
Base::stop();
|
||||
|
||||
@ -173,7 +170,7 @@ void CalibrateDisplay::stop()
|
||||
}
|
||||
}
|
||||
|
||||
void CalibrateDisplay::buttonPressed(espgui::Button button)
|
||||
void PotisCalibrateDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
|
||||
@ -277,7 +274,7 @@ void CalibrateDisplay::buttonPressed(espgui::Button button)
|
||||
}
|
||||
}
|
||||
|
||||
void CalibrateDisplay::copyFromSettings()
|
||||
void PotisCalibrateDisplay::copyFromSettings()
|
||||
{
|
||||
m_gasMin = configs.gasMin.value;
|
||||
m_gasMax = configs.gasMax.value;
|
||||
@ -285,7 +282,7 @@ void CalibrateDisplay::copyFromSettings()
|
||||
m_bremsMax = configs.bremsMax.value;
|
||||
}
|
||||
|
||||
void CalibrateDisplay::copyToSettings()
|
||||
void PotisCalibrateDisplay::copyToSettings()
|
||||
{
|
||||
configs.write_config(configs.gasMin, m_gasMin);
|
||||
configs.write_config(configs.gasMax, m_gasMax);
|
@ -13,17 +13,16 @@
|
||||
|
||||
// local includes
|
||||
#include "bobbydisplaywithtitle.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "modeinterface.h"
|
||||
#include "modes/ignoreinputmode.h"
|
||||
|
||||
class CalibrateDisplay : public BobbyDisplayWithTitle
|
||||
class PotisCalibrateDisplay : public BobbyDisplayWithTitle
|
||||
{
|
||||
using Base = BobbyDisplayWithTitle;
|
||||
|
||||
public:
|
||||
CalibrateDisplay() = default;
|
||||
explicit CalibrateDisplay(bool bootup);
|
||||
PotisCalibrateDisplay() = default;
|
||||
explicit PotisCalibrateDisplay(bool bootup) : m_bootup{bootup} {}
|
||||
|
||||
std::string text() const override;
|
||||
void start() override;
|
@ -23,7 +23,8 @@ using namespace std::chrono_literals;
|
||||
#include "modes/defaultmode.h"
|
||||
#include "displays/statusdisplay.h"
|
||||
#include "displays/lockscreen.h"
|
||||
#include "displays/calibratedisplay.h"
|
||||
#include "displays/potiscalibratedisplay.h"
|
||||
#include "displays/buttoncalibratedisplay.h"
|
||||
#include "newsettings.h"
|
||||
#include "taskmanager.h"
|
||||
|
||||
@ -71,14 +72,21 @@ extern "C" void app_main()
|
||||
|
||||
bootLabel.redraw("switchScreen");
|
||||
|
||||
if (settings.lockscreen.keepLockedAfterReboot && settings.lockscreen.locked)
|
||||
if (configs.dpadMappingLeft.value == INPUT_MAPPING_NONE ||
|
||||
configs.dpadMappingRight.value == INPUT_MAPPING_NONE ||
|
||||
configs.dpadMappingUp.value == INPUT_MAPPING_NONE ||
|
||||
configs.dpadMappingDown.value == INPUT_MAPPING_NONE)
|
||||
{
|
||||
espgui::switchScreen<ButtonCalibrateDisplay>(true);
|
||||
}
|
||||
else if (settings.lockscreen.keepLockedAfterReboot && settings.lockscreen.locked)
|
||||
{
|
||||
espgui::switchScreen<Lockscreen>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gas || !brems || *gas > 200.f || *brems > 200.f)
|
||||
espgui::switchScreen<CalibrateDisplay>(true);
|
||||
espgui::switchScreen<PotisCalibrateDisplay>(true);
|
||||
else
|
||||
{
|
||||
espgui::switchScreen<StatusDisplay>();
|
||||
|
Reference in New Issue
Block a user