Fixes
This commit is contained in:
Binary file not shown.
@@ -105,6 +105,14 @@ void BatteryMenu::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw(tft);
|
||||
|
||||
if (m_fullRedraw)
|
||||
{
|
||||
m_fullRedraw = false;
|
||||
m_doubleProgressBarBatPercentage.start(tft);
|
||||
m_batPercentBootLabel.clear(tft, espgui::TFT_BLACK);
|
||||
m_batPercentNowLabel.clear(tft, espgui::TFT_BLACK);
|
||||
}
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
const auto batPercent = getBatteryPercentage(*avgVoltage, BatteryCellType(configs.battery.cellType.value()));
|
||||
@@ -118,6 +126,20 @@ void BatteryMenu::redraw(espgui::TftInterface &tft)
|
||||
}
|
||||
}
|
||||
|
||||
void BatteryMenu::buttonPressed(espgui::Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
case espgui::Up:
|
||||
case espgui::Down:
|
||||
m_fullRedraw = true;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
void BatteryMenu::back()
|
||||
{
|
||||
espgui::popScreen();
|
||||
|
@@ -24,10 +24,14 @@ public:
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
void back() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
private:
|
||||
bobby::DoubleProgressBar m_doubleProgressBarBatPercentage{75, 68, 90, 24, 0, 100, espgui::TFT_RED, espgui::TFT_GREEN};
|
||||
espgui::Label m_batPercentNowLabel {170, 68};
|
||||
espgui::Label m_batPercentBootLabel{170, 82};
|
||||
|
||||
bool m_fullRedraw{true};
|
||||
};
|
||||
|
||||
} // namespace bobby
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "qrimportdisplay.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <espwifistack.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
namespace bobby {
|
||||
@@ -16,18 +17,8 @@ void QrImportDisplay::initScreen(espgui::TftInterface &tft)
|
||||
|
||||
m_statuslabel.start(tft);
|
||||
|
||||
qrimport::setup_request();
|
||||
|
||||
if (const auto result = qrimport::start_qr_request(); result)
|
||||
{
|
||||
ESP_LOGI(TAG, "started request, waiting for result");
|
||||
m_waitingForResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "could not start request: %.*s", result.error().size(), result.error().data());
|
||||
m_result = tl::make_unexpected(std::move(result).error());
|
||||
}
|
||||
if (!m_requestStarted)
|
||||
start_request();
|
||||
}
|
||||
|
||||
void QrImportDisplay::update()
|
||||
@@ -51,7 +42,10 @@ void QrImportDisplay::update()
|
||||
m_result = tl::make_unexpected(fmt::format("saving qr failed: {}", esp_err_to_name(result.error())));
|
||||
}
|
||||
else
|
||||
ESP_LOGW(TAG, "failed %.*s => %.*s", m_nvs_key.size(), m_nvs_key.data(), m_result.error().size(), m_result.error().data());
|
||||
{
|
||||
ESP_LOGW(TAG, "failed %.*s => %.*s", m_nvs_key.size(), m_nvs_key.data(), m_result.error().size(),
|
||||
m_result.error().data());
|
||||
}
|
||||
}
|
||||
|
||||
void QrImportDisplay::redraw(espgui::TftInterface &tft)
|
||||
@@ -66,9 +60,10 @@ void QrImportDisplay::redraw(espgui::TftInterface &tft)
|
||||
else if (!m_result && !m_result.error().empty())
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("&1Error: {}&6", m_result.error()));
|
||||
m_statuslabel.redraw(tft, fmt::format("Error: {}", m_result.error()), TFT_RED, TFT_BLACK, 4);
|
||||
m_result.error().clear();
|
||||
}
|
||||
else
|
||||
else if (m_result && !m_result->empty())
|
||||
{
|
||||
m_statuslabel.redraw(tft, "OK", TFT_GREEN, TFT_BLACK, 4);
|
||||
popScreen();
|
||||
@@ -92,4 +87,28 @@ void QrImportDisplay::buttonPressed(espgui::Button button)
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
void QrImportDisplay::start_request()
|
||||
{
|
||||
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
|
||||
{
|
||||
m_result = tl::make_unexpected(std::string{"not connected to wifi"});
|
||||
return;
|
||||
}
|
||||
|
||||
m_requestStarted = true;
|
||||
|
||||
qrimport::setup_request();
|
||||
|
||||
if (const auto result = qrimport::start_qr_request(); result)
|
||||
{
|
||||
ESP_LOGI(TAG, "started request, waiting for result");
|
||||
m_waitingForResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "could not start request: %.*s", result.error().size(), result.error().data());
|
||||
m_result = tl::make_unexpected(result.error());
|
||||
}
|
||||
}
|
||||
} // namespace bobby
|
||||
|
@@ -37,8 +37,11 @@ public:
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
void start_request();
|
||||
|
||||
private:
|
||||
bool m_waitingForResult{false};
|
||||
bool m_requestStarted{false};
|
||||
espgui::Label m_statuslabel;
|
||||
|
||||
tl::expected<std::string, std::string> m_result;
|
||||
|
@@ -47,9 +47,10 @@ void SetupBasicButtonsDisplay::update()
|
||||
m_button_cal_finished = false;
|
||||
saveButtons();
|
||||
|
||||
setup::unlock();
|
||||
|
||||
if (m_early_return)
|
||||
{
|
||||
setup::unlock();
|
||||
espgui::popScreen();
|
||||
}
|
||||
else
|
||||
|
@@ -70,7 +70,6 @@ public:
|
||||
using namespace espgui;
|
||||
using namespace typesafeenumchangemenu;
|
||||
constructMenuItem<TypesafeEnumCurrentValueMenuItem<TEnum>>(m_config);
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
iterateEnum<TEnum>::iterate([&](TEnum enum_value, const auto &string_value){
|
||||
constructMenuItem<TypesafeEnumSetterMenuItem<TEnum>>(enum_value, m_config);
|
||||
});
|
||||
|
@@ -11,16 +11,24 @@ IgnoreInputMode setup_mode{0, bobbycar::protocol::ControlType::FieldOrientedCont
|
||||
void lock()
|
||||
{
|
||||
if (currently_locked)
|
||||
{
|
||||
ESP_LOGI("setup", "already locked");
|
||||
return;
|
||||
}
|
||||
|
||||
oldMode = currentMode;
|
||||
currentMode = &setup_mode;
|
||||
|
||||
currently_locked = true;
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
if (!currently_locked)
|
||||
{
|
||||
ESP_LOGI("setup", "already unlocked");
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentMode == &setup_mode)
|
||||
{
|
||||
@@ -30,6 +38,8 @@ void unlock()
|
||||
|
||||
currentMode = oldMode;
|
||||
}
|
||||
|
||||
currently_locked = false;
|
||||
}
|
||||
|
||||
bool isLocked()
|
||||
|
Reference in New Issue
Block a user