Updated to newest idf

This commit is contained in:
2023-08-13 20:13:05 +02:00
parent 1a7e83de83
commit a9794b13bd
60 changed files with 6169 additions and 1950 deletions

View File

@@ -530,7 +530,7 @@ set(dependencies
freertos nvs_flash esp_http_server esp_https_ota mdns app_update esp_system esp_websocket_client driver esp_adc
arduino-esp32 ArduinoJson esp-nimble-cpp FastLED-idf TFT_eSPI QRCode-esp32
bobbycar-protocol cpputils cxx-ring-buffer date sunset
espasynchttpreq espasyncota espchrono espcpputils espconfiglib esp-gui-lib esphttpdutils espwifistack expected fmt
espasynchttpreq espasyncota espchrono espcpputils espconfiglib esp-gui-lib esphttpdutils espwifistack fmt
)
idf_component_register(

View File

@@ -2,6 +2,7 @@
// system includes
#include <cstdint>
#include <expected>
// 3rdparty lib includes
#include <accessorinterface.h>

View File

@@ -1,5 +1,8 @@
#pragma once
// system includes
#include <expected>
// 3rdparty lib includes
#include <accessorinterface.h>

View File

@@ -4,7 +4,7 @@
#include <esp_system.h>
// 3rdparty lib includes
#include <tftinstance.h>
#include <TFT_eSPI.h>
void RebootAction::triggered()
{

View File

@@ -9,6 +9,6 @@
void BobbyErrorHandler::errorOccurred(std::string &&error)
{
auto newDisplay = std::make_unique<BobbyPopupDisplay>(std::move(error), std::move(espgui::currentDisplay));
newDisplay->initOverlay();
newDisplay->initOverlay(tft);
espgui::currentDisplay = std::move(newDisplay);
}

View File

@@ -2,6 +2,7 @@
// system includes
#include <optional>
#include <expected>
// esp-idf includes
#include <esp_log.h>
@@ -13,7 +14,6 @@
#include <menudisplay.h>
#include <numberparsing.h>
#include <screenmanager.h>
#include <tftinstance.h>
#include <tickchrono.h>
#include <wrappers/websocket_client.h>
@@ -196,7 +196,7 @@ typename std::enable_if<
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, BobbyQuickActions> &&
!std::is_same_v<T, BatteryCellType>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
return tl::make_unexpected("Unsupported config type");
@@ -205,7 +205,7 @@ set_config(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, bool>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
if (cpputils::is_in(newValue, "true", "false"))
@@ -218,7 +218,7 @@ template<typename T>
typename std::enable_if<
!std::is_same_v<T, bool> &&
std::is_integral_v<T>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
if (auto parsed = cpputils::fromString<T>(newValue))
@@ -230,7 +230,7 @@ set_config(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, std::string>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
return configs.write_config(config, std::string{newValue});
@@ -239,7 +239,7 @@ set_config(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, wifi_stack::ip_address_t>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
if (const auto parsed = wifi_stack::fromString<wifi_stack::ip_address_t>(newValue); parsed)
@@ -251,7 +251,7 @@ set_config(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, wifi_stack::mac_t>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
if (const auto parsed = wifi_stack::fromString<wifi_stack::mac_t>(newValue); parsed)
@@ -263,7 +263,7 @@ set_config(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, std::optional<wifi_stack::mac_t>>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
if (newValue.empty())
@@ -284,7 +284,7 @@ typename std::enable_if<
std::is_same_v<T, HandbremseMode> ||
std::is_same_v<T, BobbyQuickActions> ||
std::is_same_v<T, BatteryCellType>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &config, std::string_view newValue)
{
if (auto parsed = cpputils::fromString<std::underlying_type_t<T>>(newValue))

View File

@@ -53,9 +53,9 @@ void Lockscreen::start()
}
}
void Lockscreen::initScreen()
void Lockscreen::initScreen(espgui::TftInterface &tft)
{
Base::initScreen();
Base::initScreen(tft);
espgui::tft.fillScreen(TFT_BLACK);
espgui::tft.setTextFont(4);
@@ -93,9 +93,9 @@ void Lockscreen::update()
Base::update();
}
void Lockscreen::redraw()
void Lockscreen::redraw(espgui::TftInterface &tft)
{
Base::redraw();
Base::redraw(tft);
if (m_pressed || m_back_pressed)
{

View File

@@ -24,9 +24,9 @@ class Lockscreen : public BobbyDisplay
public:
void start() override;
void initScreen() override;
void initScreen(espgui::TftInterface &tft) override;
void update() override;
void redraw() override;
void redraw(espgui::TftInterface &tft) override;
void stop() override;
void buttonPressed(espgui::Button button) override;

View File

@@ -1,7 +1,6 @@
#include "menudisplaywithtime.h"
// 3rdparty lib includes
#include <tftinstance.h>
#include <fmt/core.h>
// local includes
@@ -16,9 +15,9 @@ void MenuDisplayWithTime::start()
m_label_currentTime.start();
}
void MenuDisplayWithTime::redraw()
void MenuDisplayWithTime::redraw(espgui::TftInterface &tft)
{
Base::redraw();
Base::redraw(tft);
tft.setTextFont(use_big_font() ? 4 : 2);
m_label_currentTime.redraw(fmt::format("&7Time: {}", local_clock_string()));
}

View File

@@ -11,7 +11,7 @@ class MenuDisplayWithTime :
public:
void start() override;
void redraw() override;
void redraw(espgui::TftInterface &tft) override;
espgui::Label m_label_currentTime{145, 6};
private:

View File

@@ -49,7 +49,7 @@ std::string toString(twai_state_t val)
class CanStatusText : public virtual espgui::TextInterface
{
public:
explicit CanStatusText(const tl::expected<twai_status_info_t, esp_err_t> &last_can_status_info) :
explicit CanStatusText(const std::expected<twai_status_info_t, esp_err_t> &last_can_status_info) :
m_last_can_status_info{last_can_status_info}
{
}
@@ -67,7 +67,7 @@ protected:
virtual std::string canStatusText(const twai_status_info_t &can_status_info) const = 0;
private:
const tl::expected<twai_status_info_t, esp_err_t> &m_last_can_status_info;
const std::expected<twai_status_info_t, esp_err_t> &m_last_can_status_info;
};
class CanStatusStateText : public CanStatusText

View File

@@ -5,12 +5,12 @@
#ifdef FEATURE_CAN
// system includes
#include <expected>
// esp-idf includes
#include <driver/twai.h>
// 3rdparty lib includes
#include <tl/expected.hpp>
class CanDebugMenu : public BobbyMenuDisplay
{
using Base = BobbyMenuDisplay;
@@ -25,7 +25,7 @@ public:
void back() override;
private:
tl::expected<twai_status_info_t, esp_err_t> m_last_can_status_info;
std::expected<twai_status_info_t, esp_err_t> m_last_can_status_info;
};
#endif

View File

@@ -3,6 +3,7 @@
// system includes
#include <string>
#include <optional>
#include <expected>
// 3rdparty lib includes
#include <espchrono.h>
@@ -85,7 +86,7 @@ struct ToggleAccessor : public virtual AccessorInterface<bool>
{
public:
bool getValue() const override { return toggle; };
tl::expected<void, std::string> setValue(bool value) override;
std::expected<void, std::string> setValue(bool value) override;
};
using ToggleChangeValueDisplay = espgui::makeComponent<
@@ -199,7 +200,7 @@ const MenuItemIcon *RandomIcon::icon() const
return m_icon;
}
tl::expected<void, std::string> ToggleAccessor::setValue(bool value)
std::expected<void, std::string> ToggleAccessor::setValue(bool value)
{
if (toggleLocked)
return tl::make_unexpected("cannot be changed while is locked!");

View File

@@ -3,7 +3,8 @@
// 3rd party includes
#include <qrcode.h>
#include <screenmanager.h>
#include <tftinstance.h>
#include <tftinterface.h>
#include <TFT_eSPI.h>
// local includes
#include "bobbydisplay.h"
@@ -17,7 +18,7 @@ class QrDisplay : public BobbyDisplay
public:
explicit QrDisplay(std::string_view msg) : m_msg{msg} {}
void initScreen() override
void initScreen(espgui::TftInterface &tft) override
{
using namespace espgui;
QRCode qrcode;

View File

@@ -49,10 +49,10 @@ void QrImportDisplay::update()
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()
void QrImportDisplay::redraw(espgui::TftInterface &tft)
{
using namespace espgui;
Base::redraw();
Base::redraw(tft);
if (m_waitingForResult)
{

View File

@@ -1,10 +1,11 @@
#pragma once
// system includes
#include <expected>
// 3rd party includes
#include <esp_log.h>
#include <fmt/core.h>
#include <tftinstance.h>
#include <tl/expected.hpp>
#include <widgets/label.h>
// local includes
@@ -23,13 +24,13 @@ public:
void start() override;
void update() override;
void redraw() override;
void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override;
private:
bool m_waitingForResult{false};
espgui::Label m_statuslabel{5,(espgui::tft.height() / 2)-espgui::tft.fontHeight(4)};
tl::expected<std::string, std::string> m_result;
std::expected<std::string, std::string> m_result;
std::string m_nvs_key;
};

View File

@@ -18,9 +18,9 @@ constexpr char const buttonText[] = "Please press the highlighted\n buttons!";
constexpr const char * const TAG = "SETUP-BUTTONS";
}
void SetupBasicButtonsDisplay::initScreen()
void SetupBasicButtonsDisplay::initScreen(espgui::TftInterface &tft)
{
Base::initScreen();
Base::initScreen(tft);
drawLargeText(buttonText);
drawButtons(m_button_cal_status);
@@ -58,9 +58,9 @@ void SetupBasicButtonsDisplay::update()
Base::update();
}
void SetupBasicButtonsDisplay::redraw()
void SetupBasicButtonsDisplay::redraw(espgui::TftInterface &tft)
{
Base::redraw();
Base::redraw(tft);
}
void SetupBasicButtonsDisplay::rawButtonPressed(uint8_t button)
@@ -122,7 +122,7 @@ void SetupBasicButtonsDisplay::buttonReleased(espgui::Button button)
// Base::buttonReleased(button);
}
std::string SetupBasicButtonsDisplay::text() const
std::string SetupBasicButtonsDisplay::title() const
{
return "Calibrate Buttons";
}

View File

@@ -23,17 +23,17 @@ public:
m_early_return{early_return}
{}
void initScreen() override;
void initScreen(espgui::TftInterface &tft) override;
void start() override;
void update() override;
void redraw() override;
void redraw(espgui::TftInterface &tft) 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;
[[nodiscard]] std::string text() const override;
[[nodiscard]] std::string title() const override;
private:
const bool m_early_return;

View File

@@ -12,9 +12,9 @@
using namespace espgui;
void SetupCalibratePotisDisplay::initScreen()
void SetupCalibratePotisDisplay::initScreen(espgui::TftInterface &tft)
{
Base::initScreen();
Base::initScreen(tft);
tft.setTextFont(4);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -58,9 +58,9 @@ void SetupCalibratePotisDisplay::update()
m_brems = std::nullopt;
}
void SetupCalibratePotisDisplay::redraw()
void SetupCalibratePotisDisplay::redraw(espgui::TftInterface &tft)
{
Base::redraw();
Base::redraw(tft);
m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?");
m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?");
@@ -279,7 +279,7 @@ void SetupCalibratePotisDisplay::buttonPressed(espgui::Button button)
}
};
std::string SetupCalibratePotisDisplay::text() const
std::string SetupCalibratePotisDisplay::title() const
{
return "Calibrate Potis";
}

View File

@@ -19,15 +19,15 @@ public:
m_early_return{early_return}
{}
void initScreen() override;
void initScreen(espgui::TftInterface &tft) override;
void start() override;
void update() override;
void redraw() override;
void redraw(espgui::TftInterface &tft) override;
void stop() override;
void buttonPressed(espgui::Button button) override;
[[nodiscard]] std::string text() const override;
[[nodiscard]] std::string title() const override;
private:
void copyFromSettings();

View File

@@ -26,7 +26,7 @@ void handleOta()
asyncOta->update();
}
tl::expected<void, std::string> triggerOta(std::string_view url)
std::expected<void, std::string> triggerOta(std::string_view url)
{
if (!configs.feature.ota.isEnabled.value())
return tl::make_unexpected("OTA is not enabled!");

View File

@@ -1,5 +1,8 @@
#pragma once
// system includes
#include <expected>
// 3rdparty lib includes
#include <espasyncota.h>
#include <delayedconstruction.h>
@@ -9,4 +12,4 @@ extern bool asyncOtaTaskStarted;
void initOta();
void handleOta();
tl::expected<void, std::string> triggerOta(std::string_view url);
std::expected<void, std::string> triggerOta(std::string_view url);

View File

@@ -37,7 +37,7 @@ bool has_qr_code(std::string_view key)
return length;
}
tl::expected<std::string, esp_err_t> get_qr_code(std::string_view key)
std::expected<std::string, esp_err_t> get_qr_code(std::string_view key)
{
const auto handle = configs.nvs_handle_user;
@@ -67,7 +67,7 @@ tl::expected<std::string, esp_err_t> get_qr_code(std::string_view key)
return buf; // no std::move needed as return is optimized
}
tl::expected<void, esp_err_t> set_qr_code(std::string_view key, std::string_view qrcode)
std::expected<void, esp_err_t> set_qr_code(std::string_view key, std::string_view qrcode)
{
const auto handle = configs.nvs_handle_user;
@@ -80,7 +80,7 @@ tl::expected<void, esp_err_t> set_qr_code(std::string_view key, std::string_view
return {};
}
tl::expected<void, esp_err_t> delete_qr_code(std::string_view key)
std::expected<void, esp_err_t> delete_qr_code(std::string_view key)
{
const auto handle = configs.nvs_handle_user;
@@ -102,7 +102,7 @@ void setup_request()
}
}
tl::expected<void, std::string> start_qr_request()
std::expected<void, std::string> start_qr_request()
{
if (!http_request.constructed())
{
@@ -116,7 +116,7 @@ tl::expected<void, std::string> start_qr_request()
return{};
}
tl::expected<std::string, std::string> check_request()
std::expected<std::string, std::string> check_request()
{
if (!http_request.constructed())
{

View File

@@ -6,25 +6,24 @@
*/
// system includes
//#include <string>
#include <string>
#include <expected>
// 3rd party includes
#include <esp_err.h>
#include <tl/expected.hpp>
// local includes
namespace qrimport {
// nvs
bool has_qr_code(std::string_view key);
tl::expected<std::string, esp_err_t> get_qr_code(std::string_view key);
tl::expected<void, esp_err_t> set_qr_code(std::string_view key, std::string_view qrcode);
tl::expected<void, esp_err_t> delete_qr_code(std::string_view key);
std::expected<std::string, esp_err_t> get_qr_code(std::string_view key);
std::expected<void, esp_err_t> set_qr_code(std::string_view key, std::string_view qrcode);
std::expected<void, esp_err_t> delete_qr_code(std::string_view key);
// web request
void setup_request();
tl::expected<void, std::string> start_qr_request();
tl::expected<std::string, std::string> check_request();
std::expected<void, std::string> start_qr_request();
std::expected<std::string, std::string> check_request();
bool get_request_running();
} // namespace

View File

@@ -115,7 +115,7 @@ void sched_pushStats(bool printTasks)
ESP_LOGI(TAG, "end listing tasks");
}
tl::expected<bool, std::string> checkInitializedByName(const std::string& name)
std::expected<bool, std::string> checkInitializedByName(const std::string& name)
{
for (auto &schedulerTask : schedulerTasks)
{

View File

@@ -2,10 +2,10 @@
// system includes
#include <optional>
#include <expected>
// 3rdparty lib includes
#include <arrayview.h>
#include <tl/expected.hpp>
// local includes
#include "bobbyschedulertask.h"
@@ -16,7 +16,7 @@ extern const BobbySchedulerTask &drivingModeTask;
void sched_pushStats(bool printTasks);
tl::expected<bool, std::string> checkInitializedByName(const std::string& name);
std::expected<bool, std::string> checkInitializedByName(const std::string& name);
bool checkEnabledByName(const std::string& name);

View File

@@ -1,5 +1,8 @@
#include "time_bobbycar.h"
// system includes
#include <expected>
// esp-idf includes
#include <esp_log.h>
#include <lwip/apps/snmp.h>
@@ -95,7 +98,7 @@ void updateTime()
}
}
tl::expected<void, std::string> time_requestSync()
std::expected<void, std::string> time_requestSync()
{
ESP_LOGI("BOBBY", "called");
if (!sntp_restart())

View File

@@ -3,6 +3,7 @@
// system includes
#include <limits>
#include <utility>
#include <expected>
// esp-idf includes
#include <esp_http_server.h>
@@ -354,7 +355,7 @@ typename std::enable_if<
!std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, BobbyQuickActions>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
return tl::make_unexpected("Unsupported config type");
@@ -363,7 +364,7 @@ saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, bool>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
if (cpputils::is_in(newValue, "true", "false"))
@@ -376,7 +377,7 @@ template<typename T>
typename std::enable_if<
!std::is_same_v<T, bool> &&
std::is_integral_v<T>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
if (auto parsed = cpputils::fromString<T>(newValue))
@@ -388,7 +389,7 @@ saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, std::string>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
return configs.write_config(config, std::string{newValue});
@@ -397,7 +398,7 @@ saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, wifi_stack::ip_address_t>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
if (const auto parsed = wifi_stack::fromString<wifi_stack::ip_address_t>(newValue); parsed)
@@ -409,7 +410,7 @@ saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, wifi_stack::mac_t>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
if (const auto parsed = wifi_stack::fromString<wifi_stack::mac_t>(newValue); parsed)
@@ -421,7 +422,7 @@ saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
template<typename T>
typename std::enable_if<
std::is_same_v<T, std::optional<wifi_stack::mac_t>>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
if (newValue.empty())
@@ -441,7 +442,7 @@ typename std::enable_if<
std::is_same_v<T, LedstripAnimation> ||
std::is_same_v<T, HandbremseMode> ||
std::is_same_v<T, BobbyQuickActions>
, tl::expected<void, std::string>>::type
, std::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
if (auto parsed = cpputils::fromString<std::underlying_type_t<T>>(newValue))