From 119608bdc0513b536b59916ffdaf142c499f88ed Mon Sep 17 00:00:00 2001 From: robot Date: Fri, 26 Jun 2026 14:02:02 -0600 Subject: [PATCH] vtm in hive --- src/comms/data/comms_ref_data.hpp | 74 ++++++++++++++++++++++++++++- src/sensors/RefSystem.cpp | 1 + src/sensors/RefSystemPacketDefs.hpp | 40 ++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/src/comms/data/comms_ref_data.hpp b/src/comms/data/comms_ref_data.hpp index d9d4be71..e42a53a0 100644 --- a/src/comms/data/comms_ref_data.hpp +++ b/src/comms/data/comms_ref_data.hpp @@ -104,6 +104,76 @@ struct ProjectileAllowanceData { uint32_t num_gold = 0; }; +/// @copydoc VTMRemoteControl +struct VTMData { + /// @copydoc VTMRemoteControl::channel_0 + uint16_t channel_0 = 1024; + /// @copydoc VTMRemoteControl::channel_1 + uint16_t channel_1 = 1024; + /// @copydoc VTMRemoteControl::channel_2 + uint16_t channel_2 = 1024; + /// @copydoc VTMRemoteControl::channel_3 + uint16_t channel_3 = 1024; + /// @copydoc VTMRemoteControl::mode_switch + uint8_t mode_switch = 0; + /// @copydoc VTMRemoteControl::pause_button + uint8_t pause_button = 0; + /// @copydoc VTMRemoteControl::custom_button_left + uint8_t custom_button_left = 0; + /// @copydoc VTMRemoteControl::custom_button_right + uint8_t custom_button_right = 0; + /// @copydoc VTMRemoteControl::dial + uint16_t dial = 1024; + /// @copydoc VTMRemoteControl::mouse_speed_x + int16_t mouse_speed_x = 0; + /// @copydoc VTMRemoteControl::mouse_speed_y + int16_t mouse_speed_y = 0; + /// @copydoc VTMRemoteControl::scroll_speed + int16_t scroll_speed = 0; + /// @copydoc VTMRemoteControl::trigger + uint8_t trigger = 0; + /// @copydoc VTMRemoteControl::button_left + uint8_t button_left = 0; + /// @copydoc VTMRemoteControl::button_right + uint8_t button_right = 0; + /// @copydoc VTMRemoteControl::button_middle + uint8_t button_middle = 0; + /// @copydoc VTMRemoteControl::keyboard_value + uint16_t keyboard_value = 0; + /// @copydoc VTMRemoteControl::key_w + uint8_t key_w; + /// @copydoc VTMRemoteControl::key_s + uint8_t key_s; + /// @copydoc VTMRemoteControl::key_a + uint8_t key_a; + /// @copydoc VTMRemoteControl::key_d + uint8_t key_d; + /// @copydoc VTMRemoteControl::key_shift + uint8_t key_shift; + /// @copydoc VTMRemoteControl::key_ctrl + uint8_t key_ctrl; + /// @copydoc VTMRemoteControl::key_q + uint8_t key_q; + /// @copydoc VTMRemoteControl::key_e + uint8_t key_e; + /// @copydoc VTMRemoteControl::key_r + uint8_t key_r; + /// @copydoc VTMRemoteControl::key_f + uint8_t key_f; + /// @copydoc VTMRemoteControl::key_g + uint8_t key_g; + /// @copydoc VTMRemoteControl::key_z + uint8_t key_z; + /// @copydoc VTMRemoteControl::key_x + uint8_t key_x; + /// @copydoc VTMRemoteControl::key_c + uint8_t key_c; + /// @copydoc VTMRemoteControl::key_v + uint8_t key_v; + /// @copydoc VTMRemoteControl::key_b + uint8_t key_b; +}; + /// @brief Mega struct fo al of the ref data we want to send over comms struct CommsRefData : Comms::CommsData { /// @brief default constructor that initializes the CommsData base class with the appropriate type label, physical medium, priority, and size for this struct @@ -126,6 +196,8 @@ struct CommsRefData : Comms::CommsData { LaunchingStatusData launching_status_data; /// @brief projectile allowance data for our robot ProjectileAllowanceData projectile_allowance_data; + /// @brief VTM remote control data for our robot + VTMData vtm_data; /// @brief padding to ensure proper alignment - uint32_t _padding = 0; + uint16_t _padding[3] = {0}; }; diff --git a/src/sensors/RefSystem.cpp b/src/sensors/RefSystem.cpp index c19b28a7..07eab2a5 100644 --- a/src/sensors/RefSystem.cpp +++ b/src/sensors/RefSystem.cpp @@ -213,6 +213,7 @@ void RefSystem::send_to_comms() { ref_data_for_comms.damage_status_data = ref_data.damage_status.to_comms_data(); ref_data_for_comms.launching_status_data = ref_data.launching_status.to_comms_data(); ref_data_for_comms.projectile_allowance_data = ref_data.projectile_allowance.to_comms_data(); + ref_data_for_comms.vtm_data = ref_data.vtm_remote_control.to_comms_data(); Comms::Sendable ref_data_sendable = ref_data_for_comms; ref_data_sendable.send_to_comms(); } diff --git a/src/sensors/RefSystemPacketDefs.hpp b/src/sensors/RefSystemPacketDefs.hpp index c2dc8dd1..707e0817 100644 --- a/src/sensors/RefSystemPacketDefs.hpp +++ b/src/sensors/RefSystemPacketDefs.hpp @@ -1777,6 +1777,46 @@ struct VTMRemoteControl { last_update_ms = millis(); } + /// @brief Converts this VTMRemoteControl struct to a VTMRemoteControlData struct for comms transmission + /// @return VTMRemoteControlData struct with the same data as this VTMRemoteControl struct + VTMData to_comms_data() { + VTMData data; + data.channel_0 = channel_0; + data.channel_1 = channel_1; + data.channel_2 = channel_2; + data.channel_3 = channel_3; + data.mode_switch = mode_switch; + data.pause_button = pause_button; + data.custom_button_left = custom_button_left; + data.custom_button_right = custom_button_right; + data.dial = dial; + data.mouse_speed_x = mouse_speed_x; + data.mouse_speed_y = mouse_speed_y; + data.scroll_speed = scroll_speed; + data.trigger = trigger; + data.button_left = button_left; + data.button_right = button_right; + data.button_middle = button_middle; + data.keyboard_value = keyboard_value; + data.key_w = key_w; + data.key_s = key_s; + data.key_a = key_a; + data.key_d = key_d; + data.key_shift = key_shift; + data.key_ctrl = key_ctrl; + data.key_q = key_q; + data.key_e = key_e; + data.key_r = key_r; + data.key_f = key_f; + data.key_g = key_g; + data.key_z = key_z; + data.key_x = key_x; + data.key_c = key_c; + data.key_v = key_v; + data.key_b = key_b; + return data; + } + private: /// @brief Reads a little-endian bit field from a VT03/VT13 remote-control frame. /// @param packet Raw 21-byte frame