Added emulate feedback option
This commit is contained in:
@ -175,6 +175,7 @@ set(headers
|
|||||||
drivingstatistics.h
|
drivingstatistics.h
|
||||||
espnowfunctions.h
|
espnowfunctions.h
|
||||||
esptexthelpers.h
|
esptexthelpers.h
|
||||||
|
feedbackemulator.h
|
||||||
feedbackparser.h
|
feedbackparser.h
|
||||||
globals.h
|
globals.h
|
||||||
handbremse.h
|
handbremse.h
|
||||||
@ -425,6 +426,7 @@ set(sources
|
|||||||
drivingstatistics.cpp
|
drivingstatistics.cpp
|
||||||
espnowfunctions.cpp
|
espnowfunctions.cpp
|
||||||
esptexthelpers.cpp
|
esptexthelpers.cpp
|
||||||
|
feedbackemulator.cpp
|
||||||
feedbackparser.cpp
|
feedbackparser.cpp
|
||||||
globals.cpp
|
globals.cpp
|
||||||
handbremse.cpp
|
handbremse.cpp
|
||||||
|
@ -82,6 +82,11 @@ void initCan()
|
|||||||
|
|
||||||
void updateCan()
|
void updateCan()
|
||||||
{
|
{
|
||||||
|
if (configs.emulateFeedback.value())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
if (!tryParseCanInput())
|
if (!tryParseCanInput())
|
||||||
break;
|
break;
|
||||||
|
55
main/feedbackemulator.cpp
Normal file
55
main/feedbackemulator.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "feedbackemulator.h"
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <esprandom.h>
|
||||||
|
#include <randomutils.h>
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
namespace feedbackemulator {
|
||||||
|
void init()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void update()
|
||||||
|
{
|
||||||
|
if (!configs.emulateFeedback.value())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &controller: controllers)
|
||||||
|
{
|
||||||
|
controller.feedback.left.dcLink = cpputils::randomNumber<int16_t>(-500, 500, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.right.dcLink = cpputils::randomNumber<int16_t>(-500, 500, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.left.speed = cpputils::randomNumber<int16_t>(-1000, 1000, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.right.speed = cpputils::randomNumber<int16_t>(-1000, 1000, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.left.error = cpputils::randomNumber(0, 4, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.right.error = cpputils::randomNumber(0, 4, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.left.angle = 0;
|
||||||
|
controller.feedback.right.angle = 0;
|
||||||
|
controller.feedback.left.dcPhaA = cpputils::randomNumber<int16_t>(-5, 5, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.right.dcPhaA = cpputils::randomNumber<int16_t>(-5, 5, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.left.dcPhaB = cpputils::randomNumber<int16_t>(-5, 5, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.right.dcPhaB = cpputils::randomNumber<int16_t>(-5, 5, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.left.dcPhaC = cpputils::randomNumber<int16_t>(-5, 5, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.right.dcPhaC = cpputils::randomNumber<int16_t>(-5, 5, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.left.chops = 0;
|
||||||
|
controller.feedback.right.chops = 0;
|
||||||
|
controller.feedback.left.hallA = true;
|
||||||
|
controller.feedback.left.hallB = false;
|
||||||
|
controller.feedback.left.hallC = true;
|
||||||
|
controller.feedback.right.hallA = false;
|
||||||
|
controller.feedback.right.hallB = true;
|
||||||
|
controller.feedback.right.hallC = false;
|
||||||
|
controller.feedback.batVoltage = cpputils::randomNumber<int16_t>(3000, 5000, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.boardTemp = cpputils::randomNumber<int16_t>(200, 600, espcpputils::esp_random_device{});
|
||||||
|
controller.feedback.left.id = 0;
|
||||||
|
controller.feedback.right.id = 0;
|
||||||
|
controller.feedback.left.iq = 0;
|
||||||
|
controller.feedback.right.iq = 0;
|
||||||
|
|
||||||
|
controller.feedbackValid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // feedbackemulator
|
6
main/feedbackemulator.h
Normal file
6
main/feedbackemulator.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace feedbackemulator {
|
||||||
|
void init();
|
||||||
|
void update();
|
||||||
|
} // namespace feedbackemulator
|
@ -399,7 +399,7 @@ public:
|
|||||||
ConfigWrapperLegacy<uint8_t> brightness {255, DoReset, {}, "ledbrightness" };
|
ConfigWrapperLegacy<uint8_t> brightness {255, DoReset, {}, "ledbrightness" };
|
||||||
ConfigWrapperLegacy<bool> enableAnimBlink {false, DoReset, {}, "enAnimBlink" };
|
ConfigWrapperLegacy<bool> enableAnimBlink {false, DoReset, {}, "enAnimBlink" };
|
||||||
ConfigWrapperLegacy<OtaAnimationModes> otaMode {OtaAnimationModes::GreenProgressBar, DoReset, {}, "ledOtaAnim" };
|
ConfigWrapperLegacy<OtaAnimationModes> otaMode {OtaAnimationModes::GreenProgressBar, DoReset, {}, "ledOtaAnim" };
|
||||||
ConfigWrapperLegacy<uint32_t> maxMilliamps {3000, DoReset, {}, "ledMaxMilliamps" };
|
ConfigWrapperLegacy<uint32_t> maxMilliamps {3000, DoReset, {}, "ledMaxMilliamps" };
|
||||||
ConfigWrapperLegacy<bool> enableVisualizeBlink {false, DoReset, {}, "enVisualBlink" };
|
ConfigWrapperLegacy<bool> enableVisualizeBlink {false, DoReset, {}, "enVisualBlink" };
|
||||||
std::array<ConfigWrapperLegacy<uint32_t>, 8> custom_color {
|
std::array<ConfigWrapperLegacy<uint32_t>, 8> custom_color {
|
||||||
ConfigWrapperLegacy<uint32_t> {0, DoReset, {}, "ledCustomCol1" },
|
ConfigWrapperLegacy<uint32_t> {0, DoReset, {}, "ledCustomCol1" },
|
||||||
@ -479,6 +479,7 @@ public:
|
|||||||
} feature;
|
} feature;
|
||||||
|
|
||||||
ConfigWrapperLegacy<uint16_t> anhaenger_id {0, DoReset, {}, "anhaenger_id" };
|
ConfigWrapperLegacy<uint16_t> anhaenger_id {0, DoReset, {}, "anhaenger_id" };
|
||||||
|
ConfigWrapperLegacy<bool> emulateFeedback {false, DoReset, {}, "emuFeedback" };
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
ConfigWrapperLegacy<bool> bleEnabled {true, DoReset, {}, "bleEnabled" };
|
ConfigWrapperLegacy<bool> bleEnabled {true, DoReset, {}, "bleEnabled" };
|
||||||
@ -800,7 +801,8 @@ public:
|
|||||||
x(feature.udpcloud.isEnabled) \
|
x(feature.udpcloud.isEnabled) \
|
||||||
x(feature.webserver.isEnabled) \
|
x(feature.webserver.isEnabled) \
|
||||||
x(feature.webserver_disable_lock.isEnabled) \
|
x(feature.webserver_disable_lock.isEnabled) \
|
||||||
x(bleSettings.bleEnabled)
|
x(bleSettings.bleEnabled) \
|
||||||
|
x(emulateFeedback)
|
||||||
|
|
||||||
#define FEATURES(x) \
|
#define FEATURES(x) \
|
||||||
x(feature.ble) \
|
x(feature.ble) \
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "dnsannounce.h"
|
#include "dnsannounce.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "feedbackemulator.h"
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@ -83,12 +84,13 @@ BobbySchedulerTask schedulerTasksArr[] {
|
|||||||
BobbySchedulerTask { "ledstrip", initLedStrip, updateLedStrip, 30ms, false },
|
BobbySchedulerTask { "ledstrip", initLedStrip, updateLedStrip, 30ms, false },
|
||||||
BobbySchedulerTask { "espnow", espnow::initESPNow, espnow::handle, 100ms, false },
|
BobbySchedulerTask { "espnow", espnow::initESPNow, espnow::handle, 100ms, false },
|
||||||
BobbySchedulerTask { "cloud", initCloud, updateCloud, 50ms, false },
|
BobbySchedulerTask { "cloud", initCloud, updateCloud, 50ms, false },
|
||||||
BobbySchedulerTask { "udpcloud", udpCloudInit, udpCloudUpdate, 50ms, false },
|
BobbySchedulerTask { "udpcloud", udpCloudInit, udpCloudUpdate, 25ms, false },
|
||||||
BobbySchedulerTask { "drivingmode", initDrivingMode, updateDrivingMode, 20ms, false },
|
BobbySchedulerTask { "drivingmode", initDrivingMode, updateDrivingMode, 20ms, false },
|
||||||
BobbySchedulerTask { "drivingstatistics", initStatistics, calculateStatistics, 100ms, false },
|
BobbySchedulerTask { "drivingstatistics", initStatistics, calculateStatistics, 100ms, false },
|
||||||
BobbySchedulerTask { "dnsannounce", init_dns_announce, handle_dns_announce, 100ms, false },
|
BobbySchedulerTask { "dnsannounce", init_dns_announce, handle_dns_announce, 100ms, false },
|
||||||
BobbySchedulerTask { "updateDisp", not_needed, updateDisplay, 20ms, true },
|
BobbySchedulerTask { "updateDisp", not_needed, updateDisplay, 20ms, true },
|
||||||
BobbySchedulerTask { "redrawDisp", not_needed, redrawDisplay, 20ms, true },
|
BobbySchedulerTask { "redrawDisp", not_needed, redrawDisplay, 20ms, true },
|
||||||
|
BobbySchedulerTask { "feedbackEmulator", feedbackemulator::init, feedbackemulator::update, 500ms, false},
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user