Files
ESP-Nodes/ESP-IDF_Robot/tutorial/docs/source/data.rst
2025-07-05 17:14:50 -04:00

29 lines
1.3 KiB
ReStructuredText

DATA STRUCT
===========
The struct is used as a payload for sending control signals from transmitting device to the receiver.
In addition, it may contain telemetry data, battery status, etc.
The *sensors_data_t* struct is designed as a data payload that encapsulates all control commands and sensor states relevant to the vehicle's operation.
It's intended to be sent from a transmitting device (like a remote control or master controller) to a receiver (such as a microcontroller onboard the vehicle).
.. code-block:: c
typedef struct {
int x_axis; // Joystick x-position
int y_axis; // Joystick y-position
bool nav_bttn; // Joystick push button
bool led; // LED ON/OFF state
uint8_t motor1_rpm_pwm; // PWMs for 4 DC motors
uint8_t motor2_rpm_pwm;
uint8_t motor3_rpm_pwm;
uint8_t motor4_rpm_pwm;
} __attribute__((packed)) sensors_data_t;
Struct Walkthrough
^^^^^^^^^^^^^^^^^^
*x_axis* and *y_axis* fields capture analog input from a joystick, determining direction and speed.
*nav_bttn* represents a joystick push-button.
*led* allows the transmitter to toggle an onboard LED and is used for status indication (e.g. pairing, battery warning, etc).