Added pwmomat
This commit is contained in:
@ -218,6 +218,7 @@ set(headers
|
|||||||
statistics.h
|
statistics.h
|
||||||
statustexthelper.h
|
statustexthelper.h
|
||||||
taskmanager.h
|
taskmanager.h
|
||||||
|
tempomat.h
|
||||||
texthelpers/networktexthelpers.h
|
texthelpers/networktexthelpers.h
|
||||||
texthelpers/wifiaptexthelpers.h
|
texthelpers/wifiaptexthelpers.h
|
||||||
texthelpers/wifistatexthelpers.h
|
texthelpers/wifistatexthelpers.h
|
||||||
@ -449,6 +450,7 @@ set(sources
|
|||||||
statistics.cpp
|
statistics.cpp
|
||||||
statustexthelper.cpp
|
statustexthelper.cpp
|
||||||
taskmanager.cpp
|
taskmanager.cpp
|
||||||
|
tempomat.cpp
|
||||||
texthelpers/networktexthelpers.cpp
|
texthelpers/networktexthelpers.cpp
|
||||||
texthelpers/wifiaptexthelpers.cpp
|
texthelpers/wifiaptexthelpers.cpp
|
||||||
texthelpers/wifistatexthelpers.cpp
|
texthelpers/wifistatexthelpers.cpp
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "espnowfunctions.h"
|
#include "espnowfunctions.h"
|
||||||
|
#include "handbremse.h"
|
||||||
#include "newsettings.h"
|
#include "newsettings.h"
|
||||||
|
#include "tempomat.h"
|
||||||
#include "wifi_bobbycar.h"
|
#include "wifi_bobbycar.h"
|
||||||
|
|
||||||
namespace quickactions {
|
namespace quickactions {
|
||||||
@ -44,6 +46,9 @@ void handle_bobby_quickaction(espgui::Button button)
|
|||||||
case BobbyQuickActions::WIFI_SCAN:
|
case BobbyQuickActions::WIFI_SCAN:
|
||||||
action_wifi_scan();
|
action_wifi_scan();
|
||||||
break;
|
break;
|
||||||
|
case BobbyQuickActions::PWMOMAT:
|
||||||
|
handle_pwmomat();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -117,18 +122,25 @@ void handle_handbremse()
|
|||||||
{
|
{
|
||||||
if (configs.handbremse.enable.value)
|
if (configs.handbremse.enable.value)
|
||||||
{
|
{
|
||||||
using namespace handbremse;
|
using StateWish = handbremse::StateWish;
|
||||||
if (stateWish == StateWish::brake || angezogen)
|
if (handbremse::stateWish == StateWish::brake || handbremse::angezogen)
|
||||||
stateWish = StateWish::release;
|
handbremse::stateWish = StateWish::release;
|
||||||
else
|
else
|
||||||
stateWish = StateWish::brake;
|
handbremse::stateWish = StateWish::brake;
|
||||||
wishTimer = espchrono::millis_clock::now();
|
handbremse::wishTimer = espchrono::millis_clock::now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void batteryDebugPrint()
|
void handle_pwmomat()
|
||||||
{
|
{
|
||||||
ESP_LOGI("BATTERY", "");
|
if (pwmomat::tempomat_pwm)
|
||||||
|
{
|
||||||
|
pwmomat::wish = pwmomat::WISH::WISH_DISABLE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pwmomat::wish = pwmomat::WISH::WISH_ENABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace quickactions
|
} // namespace quickactions
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
x(BLINK_RIGHT) \
|
x(BLINK_RIGHT) \
|
||||||
x(HANDBREMSE) \
|
x(HANDBREMSE) \
|
||||||
x(OPEN_GARAGE) \
|
x(OPEN_GARAGE) \
|
||||||
x(WIFI_SCAN)
|
x(WIFI_SCAN) \
|
||||||
|
x(PWMOMAT)
|
||||||
DECLARE_TYPESAFE_ENUM(BobbyQuickActions, : uint8_t, BobbyQuickActionsValues)
|
DECLARE_TYPESAFE_ENUM(BobbyQuickActions, : uint8_t, BobbyQuickActionsValues)
|
||||||
|
|
||||||
namespace quickactions {
|
namespace quickactions {
|
||||||
@ -26,6 +27,6 @@ void blink_left();
|
|||||||
void blink_right();
|
void blink_right();
|
||||||
void handle_handbremse();
|
void handle_handbremse();
|
||||||
void action_wifi_scan();
|
void action_wifi_scan();
|
||||||
void batteryDebugPrint();
|
void handle_pwmomat();
|
||||||
|
|
||||||
} // namespace quickactions
|
} // namespace quickactions
|
||||||
|
@ -22,6 +22,7 @@ constexpr char TEXT_QUICKACTION_BLINK_RIGHT[] = "Blink Right";
|
|||||||
constexpr char TEXT_QUICKACTION_HANDBREMSE[] = "Handbremse";
|
constexpr char TEXT_QUICKACTION_HANDBREMSE[] = "Handbremse";
|
||||||
constexpr char TEXT_QUICKACTION_OPEN_GARAGE[] = "Open Garage";
|
constexpr char TEXT_QUICKACTION_OPEN_GARAGE[] = "Open Garage";
|
||||||
constexpr char TEXT_QUICKACTION_WIFI_SCAN[] = "Wifi Scan";
|
constexpr char TEXT_QUICKACTION_WIFI_SCAN[] = "Wifi Scan";
|
||||||
|
constexpr char TEXT_QUICKACTION_TEMPOMAT[] = "Toggle PWM-Omat";
|
||||||
constexpr char TEXT_BACK[] = "Back";
|
constexpr char TEXT_BACK[] = "Back";
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ ChangeValueDisplay<BobbyQuickActions>::ChangeValueDisplay()
|
|||||||
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<BobbyQuickActions>, StaticText<TEXT_QUICKACTION_HANDBREMSE>>>(BobbyQuickActions::HANDBREMSE, *this, *this, *this);
|
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<BobbyQuickActions>, StaticText<TEXT_QUICKACTION_HANDBREMSE>>>(BobbyQuickActions::HANDBREMSE, *this, *this, *this);
|
||||||
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<BobbyQuickActions>, StaticText<TEXT_QUICKACTION_OPEN_GARAGE>>>(BobbyQuickActions::OPEN_GARAGE, *this, *this, *this);
|
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<BobbyQuickActions>, StaticText<TEXT_QUICKACTION_OPEN_GARAGE>>>(BobbyQuickActions::OPEN_GARAGE, *this, *this, *this);
|
||||||
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<BobbyQuickActions>, StaticText<TEXT_QUICKACTION_WIFI_SCAN>>>(BobbyQuickActions::WIFI_SCAN, *this, *this, *this);
|
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<BobbyQuickActions>, StaticText<TEXT_QUICKACTION_WIFI_SCAN>>>(BobbyQuickActions::WIFI_SCAN, *this, *this, *this);
|
||||||
|
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<BobbyQuickActions>, StaticText<TEXT_QUICKACTION_TEMPOMAT>>>(BobbyQuickActions::PWMOMAT, *this, *this, *this);
|
||||||
constructMenuItem<makeComponentArgs<MenuItem, BackProxyAction, StaticText<TEXT_BACK>, StaticMenuItemIcon<&espgui::icons::back>>>(*this);
|
constructMenuItem<makeComponentArgs<MenuItem, BackProxyAction, StaticText<TEXT_BACK>, StaticMenuItemIcon<&espgui::icons::back>>>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,9 +50,10 @@ void ChangeValueDisplay<BobbyQuickActions>::start()
|
|||||||
case BobbyQuickActions::HANDBREMSE: setSelectedIndex(3); break;
|
case BobbyQuickActions::HANDBREMSE: setSelectedIndex(3); break;
|
||||||
case BobbyQuickActions::OPEN_GARAGE: setSelectedIndex(4); break;
|
case BobbyQuickActions::OPEN_GARAGE: setSelectedIndex(4); break;
|
||||||
case BobbyQuickActions::WIFI_SCAN: setSelectedIndex(5); break;
|
case BobbyQuickActions::WIFI_SCAN: setSelectedIndex(5); break;
|
||||||
default:
|
case BobbyQuickActions::PWMOMAT: setSelectedIndex(6); break;
|
||||||
|
default:
|
||||||
ESP_LOGW(TAG, "Unknown BobbyQuickActions: %i", std::to_underlying(value));
|
ESP_LOGW(TAG, "Unknown BobbyQuickActions: %i", std::to_underlying(value));
|
||||||
setSelectedIndex(6);
|
setSelectedIndex(7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +37,6 @@ constexpr char TEXT_SUBGASVAL[] = "Add Gas";
|
|||||||
constexpr char TEXT_SUBBRAKEVAL[] = "Add Brake";
|
constexpr char TEXT_SUBBRAKEVAL[] = "Add Brake";
|
||||||
constexpr char TEXT_ADDGASVAL[] = "Sub Gas";
|
constexpr char TEXT_ADDGASVAL[] = "Sub Gas";
|
||||||
constexpr char TEXT_ADDBRAKEVAL[] = "Sub Brake";
|
constexpr char TEXT_ADDBRAKEVAL[] = "Sub Brake";
|
||||||
constexpr char TEXT_HYBRIDENABLE[] = "Enable Hybrid mode";
|
|
||||||
constexpr char TEXT_HYBRIDACTIVATIONLIMIT[] = "Hybrid activation-limit";
|
|
||||||
constexpr char TEXT_HYBRIDDEACTIVATIONLIMIT[] = "Hybrid deactivation-limit";
|
|
||||||
constexpr char TEXT_LIMITS_TO_NEAR[] = "Hybrid limits too near (>20)";
|
|
||||||
constexpr char TEXT_HANDBREMSE_ENABLE[] = "Enable Handbremse";
|
constexpr char TEXT_HANDBREMSE_ENABLE[] = "Enable Handbremse";
|
||||||
constexpr char TEXT_HANDBREMSE_AUTOMATIC[] = "Automatic Handbremse";
|
constexpr char TEXT_HANDBREMSE_AUTOMATIC[] = "Automatic Handbremse";
|
||||||
constexpr char TEXT_HANDBREMSE_VISUALIZE[] = "Visualize Handbremse";
|
constexpr char TEXT_HANDBREMSE_VISUALIZE[] = "Visualize Handbremse";
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#include "defaultmode.h"
|
#include "defaultmode.h"
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "handbremse.h"
|
||||||
|
#include "tempomat.h"
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace modes {
|
namespace modes {
|
||||||
@ -214,6 +218,21 @@ void DefaultMode::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pwmomat::tempomat_pwm && pwmomat::wish == pwmomat::WISH::WISH_ENABLE)
|
||||||
|
{
|
||||||
|
pwmomat::tempomat_pwm = pwm;
|
||||||
|
pwmomat::wish = pwmomat::WISH::NONE;
|
||||||
|
pwmomat::enabled_time = now;
|
||||||
|
}
|
||||||
|
else if ((pwmomat::tempomat_pwm && pwmomat::enabled_time) && (espchrono::ago(*pwmomat::enabled_time) > 500ms) && (pwm >= std::min(*pwmomat::tempomat_pwm+10, 1500.f) || pwmomat::wish == pwmomat::WISH::WISH_DISABLE)) // disable tempomat when pwm is larger than saved pwm
|
||||||
|
{
|
||||||
|
pwmomat::wish = pwmomat::WISH::NONE;
|
||||||
|
pwmomat::tempomat_pwm = std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pwmomat::tempomat_pwm)
|
||||||
|
pwm = *pwmomat::tempomat_pwm;
|
||||||
|
|
||||||
m_lastPwm = pwm;
|
m_lastPwm = pwm;
|
||||||
m_lastTime = now;
|
m_lastTime = now;
|
||||||
|
|
||||||
|
8
main/tempomat.cpp
Normal file
8
main/tempomat.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "tempomat.h"
|
||||||
|
|
||||||
|
namespace pwmomat {
|
||||||
|
std::optional<float> tempomat_pwm;
|
||||||
|
std::optional<espchrono::millis_clock::time_point> enabled_time;
|
||||||
|
|
||||||
|
WISH wish{WISH::NONE};
|
||||||
|
} // namespace pwmomat
|
20
main/tempomat.h
Normal file
20
main/tempomat.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// system includes
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <espchrono.h>
|
||||||
|
|
||||||
|
namespace pwmomat {
|
||||||
|
extern std::optional<float> tempomat_pwm; // saved pwm
|
||||||
|
extern std::optional<espchrono::millis_clock::time_point> enabled_time;
|
||||||
|
|
||||||
|
enum class WISH : uint8_t {
|
||||||
|
NONE,
|
||||||
|
WISH_ENABLE,
|
||||||
|
WISH_DISABLE,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern WISH wish;
|
||||||
|
} // namespace pwmomat
|
Reference in New Issue
Block a user