mirror of
https://github.com/BotChain-Robots/control.git
synced 2026-03-10 00:32:26 +01:00
Oled implementation (#1)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "flatbuffers/SensorMessageBuilder.h"
|
||||
#include "flatbuffers_generated/RobotModule_generated.h"
|
||||
@@ -14,53 +15,54 @@
|
||||
#include "librpc.h"
|
||||
|
||||
struct neighbour {
|
||||
uint8_t device_id;
|
||||
Orientation orientation;
|
||||
uint8_t device_id;
|
||||
Orientation orientation;
|
||||
};
|
||||
|
||||
class Module {
|
||||
public:
|
||||
explicit Module(uint8_t device_id) : m_device_id(device_id) {};
|
||||
public:
|
||||
explicit Module(uint8_t device_id) : m_device_id(device_id) {};
|
||||
|
||||
Module(uint8_t device_id, ModuleType module_type)
|
||||
: m_device_id(device_id), m_module_type(module_type) {};
|
||||
Module(uint8_t device_id, ModuleType module_type)
|
||||
: m_device_id(device_id), m_module_type(module_type) {};
|
||||
|
||||
Module(uint8_t device_id, ModuleType module_type, Messaging::ConnectionType connection_type,
|
||||
uint8_t leader)
|
||||
: m_device_id(device_id), m_module_type(module_type), m_connection_type(connection_type),
|
||||
m_leader(leader) {};
|
||||
Module(uint8_t device_id, ModuleType module_type,
|
||||
Messaging::ConnectionType connection_type, uint8_t leader)
|
||||
: m_device_id(device_id), m_module_type(module_type),
|
||||
m_connection_type(connection_type), m_leader(leader) {};
|
||||
|
||||
std::vector<neighbour> get_neighbours();
|
||||
std::vector<neighbour> get_neighbours();
|
||||
|
||||
uint8_t get_device_id();
|
||||
uint8_t get_device_id();
|
||||
|
||||
ModuleType get_type();
|
||||
ModuleType get_type();
|
||||
|
||||
Messaging::ConnectionType get_connection_type();
|
||||
Messaging::ConnectionType get_connection_type();
|
||||
|
||||
uint8_t get_leader();
|
||||
uint8_t get_leader();
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> get_last_updated_time();
|
||||
std::chrono::time_point<std::chrono::system_clock> get_last_updated_time();
|
||||
|
||||
virtual double get_position() = 0;
|
||||
virtual void actuate(double x) = 0;
|
||||
// Not all modules implement all actuation/sensor values, some are no-ops
|
||||
virtual double get_position() = 0;
|
||||
virtual std::string get_text() = 0;
|
||||
virtual void actuate(double x) = 0;
|
||||
virtual void actuate(const std::string &text) = 0;
|
||||
virtual void actuate(double x, double y) = 0;
|
||||
|
||||
// There are no modules with 2D actuation support, this is an example of how to implement it.
|
||||
virtual void actuate(double x, double y) = 0;
|
||||
void update_module_metadata(const Messaging::TopologyMessage &message);
|
||||
|
||||
void update_module_metadata(const Messaging::TopologyMessage &message);
|
||||
virtual std::vector<uint8_t> get_actuation_message() = 0;
|
||||
virtual void update_sensor_data(const Flatbuffers::sensor_value &value) = 0;
|
||||
|
||||
virtual std::vector<uint8_t> get_actuation_message() = 0;
|
||||
virtual void update_sensor_data(const Flatbuffers::sensor_value &value) = 0;
|
||||
|
||||
private:
|
||||
uint8_t m_device_id;
|
||||
ModuleType m_module_type;
|
||||
Messaging::ConnectionType m_connection_type;
|
||||
uint8_t m_leader;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_last_updated;
|
||||
std::vector<neighbour> m_neighbours;
|
||||
std::shared_ptr<MessagingInterface> m_messaging_interface;
|
||||
private:
|
||||
uint8_t m_device_id;
|
||||
ModuleType m_module_type;
|
||||
Messaging::ConnectionType m_connection_type;
|
||||
uint8_t m_leader;
|
||||
std::chrono::time_point<std::chrono::system_clock> m_last_updated;
|
||||
std::vector<neighbour> m_neighbours;
|
||||
std::shared_ptr<MessagingInterface> m_messaging_interface;
|
||||
};
|
||||
|
||||
#endif // CONTROL_MODULE_H
|
||||
|
||||
Reference in New Issue
Block a user