mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-08 12:30:52 +00:00
ESP-NOW Transmitter
This commit is contained in:
@@ -13,6 +13,14 @@ static sensors_data_t buffer;
|
|||||||
static int x, y; // Joystick x and y positions
|
static int x, y; // Joystick x and y positions
|
||||||
adc_oneshot_unit_handle_t adc_xy_handle;
|
adc_oneshot_unit_handle_t adc_xy_handle;
|
||||||
|
|
||||||
|
// Function to delete peer (i.e. when communication error occurs)
|
||||||
|
void deleteDev (void) {
|
||||||
|
uint8_t delStatus = esp_now_del_peer(receiver_mac);
|
||||||
|
if (delStatus != 0) {
|
||||||
|
ESP_LOGE("ESP-NOW", "Could not delete peer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int convert_axis_to_pwm(int axis_value) {
|
int convert_axis_to_pwm(int axis_value) {
|
||||||
// Convert the joystick axis value to a PWM value
|
// Convert the joystick axis value to a PWM value
|
||||||
// Assuming axis_value is in the range of 0-4095 for a 12-bit ADC
|
// Assuming axis_value is in the range of 0-4095 for a 12-bit ADC
|
||||||
@@ -56,6 +64,6 @@ void sendRawData(void) {
|
|||||||
ESP_LOGE("sendData()", "Ensure that received MAC is: %02X:%02X:%02X:%02X:%02X:%02X",
|
ESP_LOGE("sendData()", "Ensure that received MAC is: %02X:%02X:%02X:%02X:%02X:%02X",
|
||||||
receiver_mac[0], receiver_mac[1], receiver_mac[2],
|
receiver_mac[0], receiver_mac[1], receiver_mac[2],
|
||||||
receiver_mac[3], receiver_mac[4], receiver_mac[5]);
|
receiver_mac[3], receiver_mac[4], receiver_mac[5]);
|
||||||
deletePeer();
|
deleteDev();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -34,6 +34,7 @@ sensors_data_t buffer;
|
|||||||
int convert_axis_to_pwm(int axis_value);
|
int convert_axis_to_pwm(int axis_value);
|
||||||
void get_joystick_xy_axis(int *x_axis, int *y_axis);
|
void get_joystick_xy_axis(int *x_axis, int *y_axis);
|
||||||
void sendRawData(void);
|
void sendRawData(void);
|
||||||
|
void deleteDev(void);
|
||||||
|
|
||||||
//static sensors_data_t buffer;
|
//static sensors_data_t buffer;
|
||||||
esp_err_t joystick_adc_init(void) {
|
esp_err_t joystick_adc_init(void) {
|
||||||
|
Reference in New Issue
Block a user