bluetooth to taskmanager migrated
This commit is contained in:
@ -30,6 +30,7 @@ set(headers
|
|||||||
battery.h
|
battery.h
|
||||||
ble_bobby.h
|
ble_bobby.h
|
||||||
bletexthelpers.h
|
bletexthelpers.h
|
||||||
|
bluetooth_bobby.h
|
||||||
bluetoothmode.h
|
bluetoothmode.h
|
||||||
bluetoothtexthelpers.h
|
bluetoothtexthelpers.h
|
||||||
bmsutils.h
|
bmsutils.h
|
||||||
@ -244,6 +245,7 @@ set(sources
|
|||||||
battery.cpp
|
battery.cpp
|
||||||
ble_bobby.cpp
|
ble_bobby.cpp
|
||||||
bletexthelpers.cpp
|
bletexthelpers.cpp
|
||||||
|
bluetooth_bobby.cpp
|
||||||
bluetoothmode.cpp
|
bluetoothmode.cpp
|
||||||
bluetoothtexthelpers.cpp
|
bluetoothtexthelpers.cpp
|
||||||
bmsutils.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
|
#endif
|
||||||
#include "presets.h"
|
#include "presets.h"
|
||||||
#include "statistics.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
|
#ifdef FEATURE_BLE
|
||||||
#include "ble_bobby.h"
|
#include "ble_bobby.h"
|
||||||
#endif
|
#endif
|
||||||
@ -140,26 +133,6 @@ extern "C" void app_main()
|
|||||||
task.setup();
|
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
|
#ifdef FEATURE_CAN
|
||||||
bootLabel.redraw("can");
|
bootLabel.redraw("can");
|
||||||
can::initCan();
|
can::initCan();
|
||||||
@ -181,11 +154,6 @@ extern "C" void app_main()
|
|||||||
initLedStrip();
|
initLedStrip();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
raw_gas = std::nullopt;
|
|
||||||
raw_brems = std::nullopt;
|
|
||||||
gas = std::nullopt;
|
|
||||||
brems = std::nullopt;
|
|
||||||
|
|
||||||
for (Controller &controller : controllers)
|
for (Controller &controller : controllers)
|
||||||
controller.command.buzzer = {};
|
controller.command.buzzer = {};
|
||||||
|
|
||||||
|
@ -15,13 +15,16 @@ using namespace std::chrono_literals;
|
|||||||
|
|
||||||
void initPotis()
|
void initPotis()
|
||||||
{
|
{
|
||||||
|
raw_gas = std::nullopt;
|
||||||
|
raw_brems = std::nullopt;
|
||||||
|
gas = std::nullopt;
|
||||||
|
brems = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void readPotis()
|
void readPotis()
|
||||||
{
|
{
|
||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
constexpr auto sampleMultipleTimes = [](int pin){
|
constexpr auto sampleMultipleTimes = [](uint8_t pin){
|
||||||
analogRead(pin);
|
analogRead(pin);
|
||||||
double sum{};
|
double sum{};
|
||||||
const auto sampleCount = settings.boardcomputerHardware.sampleCount;
|
const auto sampleCount = settings.boardcomputerHardware.sampleCount;
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
#include "time_bobbycar.h"
|
#include "time_bobbycar.h"
|
||||||
#endif
|
#endif
|
||||||
#include "potis.h"
|
#include "potis.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
|
#include "bluetooth_bobby.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@ -73,6 +76,9 @@ espcpputils::SchedulerTask schedulerTasksArr[] {
|
|||||||
espcpputils::SchedulerTask { "time", initTime, updateTime, 100ms },
|
espcpputils::SchedulerTask { "time", initTime, updateTime, 100ms },
|
||||||
#endif
|
#endif
|
||||||
espcpputils::SchedulerTask { "potis", initPotis, readPotis, 20ms },
|
espcpputils::SchedulerTask { "potis", initPotis, readPotis, 20ms },
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
|
espcpputils::SchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user