Display control code

This commit is contained in:
2026-02-07 01:38:05 -05:00
parent 2e9004ee34
commit 52ff24e649
21 changed files with 797 additions and 86 deletions

View File

@@ -7,6 +7,7 @@
#include "control/ActuatorFactory.h"
#include "control/DCMotorActuator.h"
#include "control/Servo1Actuator.h"
#include "control/OledActuator.h"
#include "flatbuffers_generated/RobotModule_generated.h"
std::unique_ptr<IActuator>
@@ -18,6 +19,8 @@ ActuatorFactory::create_actuator(const ModuleType type) {
return std::make_unique<Servo1Actuator>();
case ModuleType_DC_MOTOR:
return std::make_unique<DCMotorActuator>();
case ModuleType_DISPLAY:
return std::make_unique<OledActuator>();
default:
return nullptr;
}

View File

@@ -101,6 +101,8 @@ void DCMotorActuator::setup_encoder() {
}
void DCMotorActuator::actuate(uint8_t *cmd) {
// todo: Do we want to verify flatbuffers here?
// Will introduce latency, and means that we need to also send the size to the actuate function.
const auto *angleControlCmd =
Flatbuffers::AngleControlMessageBuilder::parse_angle_control_message(cmd);
this->m_target_angle = angleControlCmd->angle();

View File

@@ -0,0 +1,33 @@
//
// Created by Johnathon Slightham on 2025-07-15.
//
#include "control/OledActuator.h"
#include "TextControlMessageBuilder.h"
#include "SensorMessageBuilder.h"
#include "constants/module.h"
#include "driver/ledc.h"
#include "flatbuffers_generated/SensorMessage_generated.h"
#include "util/number_utils.h"
#include "esp_log.h"
void OledActuator::actuate(uint8_t *cmd) {
// todo: Do we want to verify flatbuffers here?
// Will introduce latency, and means that we need to also send the size to the actuate function.
const auto *text_control_message = Flatbuffers::TextControlMessageBuilder::parse_text_control_message(cmd);
const auto new_str = text_control_message->message()->str();
if (m_display_str != new_str) {
m_display_str = new_str;
m_oled->clear_display();
if (m_display_str != "") {
m_oled->display_text(m_display_str);
}
}
}
std::vector<Flatbuffers::sensor_value> OledActuator::get_sensor_data() {
return {Flatbuffers::target_text{m_display_str}};
}

View File

@@ -39,6 +39,8 @@ Servo1Actuator::Servo1Actuator() {
}
void Servo1Actuator::actuate(uint8_t *cmd) {
// todo: Do we want to verify flatbuffers here?
// Will introduce latency, and means that we need to also send the size to the actuate function.
const auto *angleControlCmd =
Flatbuffers::AngleControlMessageBuilder::parse_angle_control_message(cmd);
const auto newDuty =