mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Add distance sensor, rewrite OLED to use new i2c library
This commit is contained in:
@@ -11,13 +11,15 @@
|
||||
|
||||
#include "MessagingInterface.h"
|
||||
#include "control/ActuatorFactory.h"
|
||||
#include "control/SensorFactory.h"
|
||||
#include "control/IActuator.h"
|
||||
|
||||
class LoopManager {
|
||||
public:
|
||||
LoopManager() : m_config_manager(ConfigManager::get_instance()),
|
||||
m_messaging_interface(std::make_unique<MessagingInterface>()),
|
||||
m_actuator(ActuatorFactory::create_actuator(m_config_manager.get_module_type())) {
|
||||
m_actuator(ActuatorFactory::create_actuator(m_config_manager.get_module_type())),
|
||||
m_sensor(SensorFactory::create_sensor(m_config_manager.get_module_type())) {
|
||||
xTaskCreate(reinterpret_cast<TaskFunction_t>(LoopManager::metadata_tx_loop),
|
||||
"metadata_tx", 3096, this, 3, nullptr);
|
||||
xTaskCreate(reinterpret_cast<TaskFunction_t>(LoopManager::sensor_loop),
|
||||
@@ -43,6 +45,7 @@ private:
|
||||
ConfigManager& m_config_manager;
|
||||
std::unique_ptr<MessagingInterface> m_messaging_interface;
|
||||
std::unique_ptr<IActuator> m_actuator;
|
||||
std::unique_ptr<ISensor> m_sensor;
|
||||
|
||||
void send_sensor_reading(bool durable) const;
|
||||
};
|
||||
|
||||
21
main/include/control/DistanceSensor.h
Normal file
21
main/include/control/DistanceSensor.h
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
#ifndef DCMOTORACTUATOR_H
|
||||
#define DCMOTORACTUATOR_H
|
||||
|
||||
#include "control/ISensor.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "vl53l0x.h"
|
||||
|
||||
class DistanceSensor final : public ISensor {
|
||||
public:
|
||||
DistanceSensor();
|
||||
~DistanceSensor() override;
|
||||
std::vector<Flatbuffers::sensor_value> get_sensor_data() override;
|
||||
|
||||
private:
|
||||
vl53l0x_t *m_sensor = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif //SERVO1ACTUATOR_H
|
||||
@@ -5,10 +5,13 @@
|
||||
#ifndef ISENSOR_H
|
||||
#define ISENSOR_H
|
||||
|
||||
#include <vector>
|
||||
#include "SensorMessageBuilder.h"
|
||||
|
||||
class ISensor {
|
||||
public:
|
||||
virtual ~ISensor() {}
|
||||
virtual void get_reading() = 0; // todo: return a flatbuffer object
|
||||
virtual std::vector<Flatbuffers::sensor_value> get_sensor_data() = 0;
|
||||
};
|
||||
|
||||
#endif //ISENSOR_H
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#ifndef SENSORFACTORY_H
|
||||
#define SENSORFACTORY_H
|
||||
|
||||
#include "flatbuffers_generated/RobotModule_generated.h"
|
||||
#include "control/ISensor.h"
|
||||
|
||||
class SensorFactory {
|
||||
public:
|
||||
static std::unique_ptr<ISensor> create_sensor(ModuleType type);
|
||||
|
||||
Reference in New Issue
Block a user