mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Display control code
This commit is contained in:
33
main/control/OledActuator.cpp
Normal file
33
main/control/OledActuator.cpp
Normal 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}};
|
||||
}
|
||||
Reference in New Issue
Block a user