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