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:
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