bluetooth to taskmanager migrated
This commit is contained in:
@ -30,6 +30,7 @@ set(headers
|
||||
battery.h
|
||||
ble_bobby.h
|
||||
bletexthelpers.h
|
||||
bluetooth_bobby.h
|
||||
bluetoothmode.h
|
||||
bluetoothtexthelpers.h
|
||||
bmsutils.h
|
||||
@ -244,6 +245,7 @@ set(sources
|
||||
battery.cpp
|
||||
ble_bobby.cpp
|
||||
bletexthelpers.cpp
|
||||
bluetooth_bobby.cpp
|
||||
bluetoothmode.cpp
|
||||
bluetoothtexthelpers.cpp
|
||||
bmsutils.cpp
|
||||
|
37
main/bluetooth_bobby.cpp
Normal file
37
main/bluetooth_bobby.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "bluetooth_bobby.h"
|
||||
|
||||
// local includes
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
#include "actions/bluetoothbeginaction.h"
|
||||
#include "actions/bluetoothbeginmasteraction.h"
|
||||
#ifdef FEATURE_BMS
|
||||
#include "actions/bluetoothconnectbmsaction.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
void bluetooth_init()
|
||||
{
|
||||
if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Master)
|
||||
{
|
||||
bootLabel.redraw("bluetooth begin master");
|
||||
BluetoothBeginMasterAction{}.triggered();
|
||||
#ifdef FEATURE_BMS
|
||||
if (settings.autoConnectBms)
|
||||
{
|
||||
bootLabel.redraw("connect BMS");
|
||||
BluetoothConnectBmsAction{}.triggered();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Slave)
|
||||
{
|
||||
bootLabel.redraw("bluetooth begin");
|
||||
BluetoothBeginAction{}.triggered();
|
||||
}
|
||||
}
|
||||
|
||||
void bluetooth_update()
|
||||
{
|
||||
}
|
||||
#endif
|
6
main/bluetooth_bobby.h
Normal file
6
main/bluetooth_bobby.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
void bluetooth_init();
|
||||
void bluetooth_update();
|
||||
#endif
|
@ -32,13 +32,6 @@ using namespace std::chrono_literals;
|
||||
#endif
|
||||
#include "presets.h"
|
||||
#include "statistics.h"
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
#include "actions/bluetoothbeginaction.h"
|
||||
#include "actions/bluetoothbeginmasteraction.h"
|
||||
#ifdef FEATURE_BMS
|
||||
#include "actions/bluetoothconnectbmsaction.h"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef FEATURE_BLE
|
||||
#include "ble_bobby.h"
|
||||
#endif
|
||||
@ -140,26 +133,6 @@ extern "C" void app_main()
|
||||
task.setup();
|
||||
}
|
||||
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Master)
|
||||
{
|
||||
bootLabel.redraw("bluetooth begin master");
|
||||
BluetoothBeginMasterAction{}.triggered();
|
||||
#ifdef FEATURE_BMS
|
||||
if (settings.autoConnectBms)
|
||||
{
|
||||
bootLabel.redraw("connect BMS");
|
||||
BluetoothConnectBmsAction{}.triggered();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Slave)
|
||||
{
|
||||
bootLabel.redraw("bluetooth begin");
|
||||
BluetoothBeginAction{}.triggered();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_CAN
|
||||
bootLabel.redraw("can");
|
||||
can::initCan();
|
||||
@ -181,11 +154,6 @@ extern "C" void app_main()
|
||||
initLedStrip();
|
||||
#endif
|
||||
|
||||
raw_gas = std::nullopt;
|
||||
raw_brems = std::nullopt;
|
||||
gas = std::nullopt;
|
||||
brems = std::nullopt;
|
||||
|
||||
for (Controller &controller : controllers)
|
||||
controller.command.buzzer = {};
|
||||
|
||||
|
@ -15,13 +15,16 @@ using namespace std::chrono_literals;
|
||||
|
||||
void initPotis()
|
||||
{
|
||||
|
||||
raw_gas = std::nullopt;
|
||||
raw_brems = std::nullopt;
|
||||
gas = std::nullopt;
|
||||
brems = std::nullopt;
|
||||
}
|
||||
|
||||
void readPotis()
|
||||
{
|
||||
[[maybe_unused]]
|
||||
constexpr auto sampleMultipleTimes = [](int pin){
|
||||
constexpr auto sampleMultipleTimes = [](uint8_t pin){
|
||||
analogRead(pin);
|
||||
double sum{};
|
||||
const auto sampleCount = settings.boardcomputerHardware.sampleCount;
|
||||
|
@ -38,6 +38,9 @@
|
||||
#include "time_bobbycar.h"
|
||||
#endif
|
||||
#include "potis.h"
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
#include "bluetooth_bobby.h"
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@ -73,6 +76,9 @@ espcpputils::SchedulerTask schedulerTasksArr[] {
|
||||
espcpputils::SchedulerTask { "time", initTime, updateTime, 100ms },
|
||||
#endif
|
||||
espcpputils::SchedulerTask { "potis", initPotis, readPotis, 20ms },
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
espcpputils::SchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms },
|
||||
#endif
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
Reference in New Issue
Block a user