mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-07 20:40:46 +00:00
core
This commit is contained in:
@@ -1 +1 @@
|
||||
51c07d3525ad1d5e472abdbcc47476db C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/espnow_transmitter.bin
|
||||
993afca02d63a9f12f946b2a4ebe629a C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/espnow_transmitter.bin
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
64e98ba85f8c9493230f791d3b90a94b7eeeed84
|
||||
321e36dc3f732812e0cf52915e150f3442913b41
|
||||
|
@@ -125,3 +125,7 @@
|
||||
42 313 7759051410545755 C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/bootloader/esp-idf/esptool_py/CMakeFiles/bootloader_check_size e2b83983896ccca6
|
||||
44 396 7759051808809439 esp-idf/esptool_py/CMakeFiles/bootloader_check_size e2b83983896ccca6
|
||||
44 396 7759051808809439 C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/bootloader/esp-idf/esptool_py/CMakeFiles/bootloader_check_size e2b83983896ccca6
|
||||
51 271 7759054150783691 esp-idf/esptool_py/CMakeFiles/bootloader_check_size e2b83983896ccca6
|
||||
51 271 7759054150783691 C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/bootloader/esp-idf/esptool_py/CMakeFiles/bootloader_check_size e2b83983896ccca6
|
||||
42 333 7759054523269219 esp-idf/esptool_py/CMakeFiles/bootloader_check_size e2b83983896ccca6
|
||||
42 333 7759054523269219 C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/bootloader/esp-idf/esptool_py/CMakeFiles/bootloader_check_size e2b83983896ccca6
|
||||
|
@@ -3167,7 +3167,7 @@ build esp-idf/partition_table/CMakeFiles/partition_table-flash | ${cmake_ninja_w
|
||||
build cmake_object_order_depends_target___idf_esp_app_format: phony || cmake_object_order_depends_target___idf_esp_bootloader_format
|
||||
|
||||
build esp-idf/esp_app_format/CMakeFiles/__idf_esp_app_format.dir/esp_app_desc.c.obj: C_COMPILER____idf_esp_app_format_unscanned_ C$:/Users/alex/esp/v5.4/esp-idf/components/esp_app_format/esp_app_desc.c || cmake_object_order_depends_target___idf_esp_app_format
|
||||
DEFINES = -DESP_PLATFORM -DIDF_VER=\"v5.4\" -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ -D_GLIBCXX_HAVE_POSIX_SEMAPHORE -D_GLIBCXX_USE_POSIX_SEMAPHORE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -D PROJECT_NAME=\"espnow_transmitter\" -DPROJECT_VER=\"ESP32-Node_Switch-v2.7-8923-g64\"
|
||||
DEFINES = -DESP_PLATFORM -DIDF_VER=\"v5.4\" -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ -D_GLIBCXX_HAVE_POSIX_SEMAPHORE -D_GLIBCXX_USE_POSIX_SEMAPHORE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -D PROJECT_NAME=\"espnow_transmitter\" -DPROJECT_VER=\"ESP32-Node_Switch-v2.7-8924-g32\"
|
||||
DEP_FILE = esp-idf\esp_app_format\CMakeFiles\__idf_esp_app_format.dir\esp_app_desc.c.obj.d
|
||||
FLAGS = -march=rv32imc_zicsr_zifencei -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-error=extra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -nostartfiles -Og -fno-shrink-wrap -fmacro-prefix-map=C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter=. -fmacro-prefix-map=C:/Users/alex/esp/v5.4/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -std=gnu17 -Wno-old-style-declaration
|
||||
INCLUDES = -IC:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/config -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_app_format/include -IC:/Users/alex/esp/v5.4/esp-idf/components/newlib/platform_include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/include/freertos -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/esp_additions/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include/soc -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include/soc/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/dma/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/ldo/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/debug_probe/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/port/esp32c3/. -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/port/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/heap/include -IC:/Users/alex/esp/v5.4/esp-idf/components/heap/tlsf -IC:/Users/alex/esp/v5.4/esp-idf/components/log/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3/register -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/platform_port/include -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3/include/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_common/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/soc -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/include/riscv -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/include/private -IC:/Users/alex/esp/v5.4/esp-idf/components/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include/apps -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include/apps/sntp -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/lwip/src/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/freertos/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include/arch -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include/sys
|
||||
|
@@ -907,7 +907,7 @@
|
||||
},
|
||||
{
|
||||
"directory": "C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build",
|
||||
"command": "C:\\Users\\alex\\esp\\tools\\riscv32-esp-elf\\esp-14.2.0_20241119\\riscv32-esp-elf\\bin\\riscv32-esp-elf-gcc.exe -DESP_PLATFORM -DIDF_VER=\\\"v5.4\\\" -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ -D_GLIBCXX_HAVE_POSIX_SEMAPHORE -D_GLIBCXX_USE_POSIX_SEMAPHORE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -D PROJECT_NAME=\\\"espnow_transmitter\\\" -DPROJECT_VER=\\\"ESP32-Node_Switch-v2.7-8923-g64\\\" -IC:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/config -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_app_format/include -IC:/Users/alex/esp/v5.4/esp-idf/components/newlib/platform_include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/include/freertos -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/esp_additions/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include/soc -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include/soc/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/dma/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/ldo/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/debug_probe/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/port/esp32c3/. -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/port/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/heap/include -IC:/Users/alex/esp/v5.4/esp-idf/components/heap/tlsf -IC:/Users/alex/esp/v5.4/esp-idf/components/log/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3/register -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/platform_port/include -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3/include/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_common/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/soc -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/include/riscv -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/include/private -IC:/Users/alex/esp/v5.4/esp-idf/components/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include/apps -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include/apps/sntp -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/lwip/src/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/freertos/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include/arch -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include/sys -march=rv32imc_zicsr_zifencei -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-error=extra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -nostartfiles -Og -fno-shrink-wrap -fmacro-prefix-map=C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter=. -fmacro-prefix-map=C:/Users/alex/esp/v5.4/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -std=gnu17 -Wno-old-style-declaration -o esp-idf\\esp_app_format\\CMakeFiles\\__idf_esp_app_format.dir\\esp_app_desc.c.obj -c C:\\Users\\alex\\esp\\v5.4\\esp-idf\\components\\esp_app_format\\esp_app_desc.c",
|
||||
"command": "C:\\Users\\alex\\esp\\tools\\riscv32-esp-elf\\esp-14.2.0_20241119\\riscv32-esp-elf\\bin\\riscv32-esp-elf-gcc.exe -DESP_PLATFORM -DIDF_VER=\\\"v5.4\\\" -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ -D_GLIBCXX_HAVE_POSIX_SEMAPHORE -D_GLIBCXX_USE_POSIX_SEMAPHORE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -D PROJECT_NAME=\\\"espnow_transmitter\\\" -DPROJECT_VER=\\\"ESP32-Node_Switch-v2.7-8924-g32\\\" -IC:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build/config -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_app_format/include -IC:/Users/alex/esp/v5.4/esp-idf/components/newlib/platform_include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/include/freertos -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/config/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos -IC:/Users/alex/esp/v5.4/esp-idf/components/freertos/esp_additions/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include/soc -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/include/soc/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/dma/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/ldo/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/debug_probe/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/port/esp32c3/. -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_hw_support/port/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/heap/include -IC:/Users/alex/esp/v5.4/esp-idf/components/heap/tlsf -IC:/Users/alex/esp/v5.4/esp-idf/components/log/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/soc/esp32c3/register -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/platform_port/include -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/hal/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3/include/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_rom/esp32c3 -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_common/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/include -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/soc -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/include/riscv -IC:/Users/alex/esp/v5.4/esp-idf/components/esp_system/port/include/private -IC:/Users/alex/esp/v5.4/esp-idf/components/riscv/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include/apps -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/include/apps/sntp -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/lwip/src/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/freertos/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include/arch -IC:/Users/alex/esp/v5.4/esp-idf/components/lwip/port/esp32xx/include/sys -march=rv32imc_zicsr_zifencei -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-error=extra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -nostartfiles -Og -fno-shrink-wrap -fmacro-prefix-map=C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter=. -fmacro-prefix-map=C:/Users/alex/esp/v5.4/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -std=gnu17 -Wno-old-style-declaration -o esp-idf\\esp_app_format\\CMakeFiles\\__idf_esp_app_format.dir\\esp_app_desc.c.obj -c C:\\Users\\alex\\esp\\v5.4\\esp-idf\\components\\esp_app_format\\esp_app_desc.c",
|
||||
"file": "C:\\Users\\alex\\esp\\v5.4\\esp-idf\\components\\esp_app_format\\esp_app_desc.c",
|
||||
"output": "esp-idf\\esp_app_format\\CMakeFiles\\__idf_esp_app_format.dir\\esp_app_desc.c.obj"
|
||||
},
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "1.1",
|
||||
"project_name": "espnow_transmitter",
|
||||
"project_version": "ESP32-Node_Switch-v2.7-8923-g64e98ba85-dirty",
|
||||
"project_version": "ESP32-Node_Switch-v2.7-8924-g321e36dc3-dirty",
|
||||
"project_path": "C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter",
|
||||
"idf_path": "C:/Users/alex/esp/v5.4/esp-idf",
|
||||
"build_dir": "C:/Users/alex/github/ESP-Nodes/ESP32-IDF_ESPNOW-Transmitter/build",
|
||||
|
@@ -10,13 +10,6 @@
|
||||
|
||||
#define SYS_LED_GPIO (10) // 10 GPIO of on-board LED
|
||||
|
||||
/* ============================
|
||||
Joystick
|
||||
============================
|
||||
*/
|
||||
#define PROJ_X (1) // ADC1_CH1; 0 GPIO joystick, x-axis
|
||||
#define PROJ_Y (0) // ADC1_CH0; 1 GPIO joystick, y-axis
|
||||
#define NAV_BTN (8) // 8 GPIO joystick button
|
||||
|
||||
/* ============================
|
||||
ESP NOW
|
||||
|
@@ -1,52 +0,0 @@
|
||||
#include "driver/adc.h"
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_now.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_event.h"
|
||||
#include "config.h"
|
||||
#include "joystick.h"
|
||||
|
||||
int x, y; // Joystick x and y positions
|
||||
adc_oneshot_unit_handle_t adc_xy_handle;
|
||||
sensors_data_t buffer;
|
||||
|
||||
// Function for sending the data to the receiver
|
||||
void sendData (void)
|
||||
{
|
||||
buffer.crc = 0;
|
||||
buffer.x_axis = 240;
|
||||
buffer.y_axis = 256;
|
||||
buffer.nav_bttn = 0;
|
||||
buffer.motor1_rpm_pcm = 0; //10;
|
||||
buffer.motor2_rpm_pcm = 0;
|
||||
buffer.motor3_rpm_pcm = 0;
|
||||
buffer.motor4_rpm_pcm = 0;
|
||||
|
||||
get_joystick_xy(&x, &y);
|
||||
//ESP_LOGI("(x, y)", "[ %d, %d ]", x, y);
|
||||
buffer.x_axis = x;
|
||||
buffer.y_axis = y;
|
||||
|
||||
// Display brief summary of data being sent.
|
||||
ESP_LOGI(TAG, "Joystick (x,y) position ( %d, %d )", buffer.x_axis, buffer.y_axis);
|
||||
ESP_LOGI(TAG, "pcm 1, pcm 2 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor1_rpm_pcm, (uint8_t)buffer.motor2_rpm_pcm);
|
||||
ESP_LOGI(TAG, "pcm 3, pcm 4 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor3_rpm_pcm, (uint8_t)buffer.motor4_rpm_pcm);
|
||||
|
||||
// Call ESP-NOW function to send data (MAC address of receiver, pointer to the memory holding data & data length)
|
||||
uint8_t result = esp_now_send(receiver_mac, (uint8_t *)&buffer, sizeof(buffer));
|
||||
|
||||
// If status is NOT OK, display error message and error code (in hexadecimal).
|
||||
if (result != 0) {
|
||||
ESP_LOGE("sendData()", "Error sending data! Error code: 0x%04X", result);
|
||||
ESP_LOGE("sendData()", "esp_now_send() failed: %s", esp_err_to_name(result));
|
||||
ESP_LOGE("sendData()", "Ensure that receiver is powered-on.");
|
||||
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[3], receiver_mac[4], receiver_mac[5]);
|
||||
deletePeer();
|
||||
}
|
||||
}
|
@@ -1,237 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_now.h"
|
||||
|
||||
#include "sensors_data.h"
|
||||
#include "config.h"
|
||||
|
||||
esp_now_peer_info_t devices;
|
||||
static adc_oneshot_unit_handle_t adc_xy_handle;
|
||||
sensors_data_t buffer;
|
||||
static int x, y; // Joystick x- and y- axis positions
|
||||
static int espnow_channel = 1;//11;
|
||||
void transmission_init();
|
||||
void wifi_init();
|
||||
|
||||
static void statusDataSend(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
esp_err_t joystick_adc_init(void)
|
||||
{
|
||||
adc_oneshot_unit_init_cfg_t adc_init_config_xy = {
|
||||
.unit_id = ADC_UNIT_1,
|
||||
.ulp_mode = ADC_ULP_MODE_DISABLE,
|
||||
};
|
||||
ESP_ERROR_CHECK(adc_oneshot_new_unit(&adc_init_config_xy, &adc_xy_handle));
|
||||
|
||||
adc_oneshot_chan_cfg_t config_x = {
|
||||
.bitwidth = SOC_ADC_DIGI_MAX_BITWIDTH,
|
||||
//.atten = ADC_ATTEN_DB_0, // 800mV
|
||||
//.atten = ADC_ATTEN_DB_2_5, // 1.1V
|
||||
//.atten = ADC_ATTEN_DB_6, // 1.3V
|
||||
//.atten = ADC_ATTEN_DB_12, // 2.6V
|
||||
.atten = ADC_ATTEN_DB_12,
|
||||
};
|
||||
adc_oneshot_chan_cfg_t config_y = {
|
||||
.bitwidth = SOC_ADC_DIGI_MAX_BITWIDTH,
|
||||
.atten = ADC_ATTEN_DB_12,
|
||||
};
|
||||
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_xy_handle, ADC_CHANNEL_0, &config_x));
|
||||
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_xy_handle, ADC_CHANNEL_1, &config_y));
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void joystick_show_raw_xy()
|
||||
{
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_0, &x));
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_1, &y));
|
||||
ESP_LOGI("(x,y)", "( %d, %d )", x, y);
|
||||
}
|
||||
|
||||
static void get_joystick_xy(int *x_axis, int *y_axis)
|
||||
{
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_0, x_axis));
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_1, y_axis));
|
||||
}
|
||||
|
||||
// Function to delete peer (i.e. when communication error occurs)
|
||||
static void deletePeer (void)
|
||||
{
|
||||
uint8_t delStatus = esp_now_del_peer(receiver_mac);
|
||||
if (delStatus != 0) {
|
||||
ESP_LOGE(TAG, "Could not delete peer");
|
||||
}
|
||||
}
|
||||
|
||||
static void sendData (void)
|
||||
{
|
||||
buffer.crc = 0;
|
||||
buffer.x_axis = 240;
|
||||
buffer.y_axis = 256;
|
||||
buffer.nav_bttn = 0;
|
||||
buffer.led = 0;
|
||||
buffer.motor1_rpm_pwm = 0;
|
||||
buffer.motor2_rpm_pwm = 0;
|
||||
buffer.motor3_rpm_pwm = 0;
|
||||
buffer.motor4_rpm_pwm = 0;
|
||||
|
||||
//joystick_show_raw_xy();
|
||||
//get_joystick_xy(&x, &y);
|
||||
get_joystick_xy(&y, &x);
|
||||
//ESP_LOGI("(x, y)", "[ %d, %d ]", x, y);
|
||||
buffer.x_axis = x;
|
||||
buffer.y_axis = y;
|
||||
|
||||
// Display brief summary of data being sent.
|
||||
ESP_LOGI(TAG, "Joystick (x,y) position ( %d, %d )", buffer.x_axis, buffer.y_axis);
|
||||
ESP_LOGI(TAG, "pwm 1, pwm 2 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor1_rpm_pwm, (uint8_t)buffer.motor2_rpm_pwm);
|
||||
ESP_LOGI(TAG, "pwm 3, pwm 4 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor3_rpm_pwm, (uint8_t)buffer.motor4_rpm_pwm);
|
||||
|
||||
//ESP_LOGI(TAG, "ESP-NOW Channel: %d", devices.channel);
|
||||
//ESP_LOGI(TAG, "Wi-Fi Channel: %d", );
|
||||
uint8_t channel;
|
||||
esp_wifi_get_channel(&channel, NULL);
|
||||
ESP_LOGE(TAG, "ESP-NOW Channel: %d", channel);
|
||||
// Call ESP-NOW function to send data (MAC address of receiver, pointer to the memory holding data & data length)
|
||||
uint8_t result = esp_now_send((uint8_t*)receiver_mac, (uint8_t *)&buffer, sizeof(buffer));
|
||||
ESP_LOGI(TAG, "Channel is set at %d", espnow_channel);
|
||||
|
||||
// If status is NOT OK, display error message and error code (in hexadecimal).
|
||||
if (result != 0) {
|
||||
ESP_LOGE(TAG, "Error sending data! Error code: 0x%04X", result);
|
||||
ESP_LOGE(TAG, "esp_now_send() failed: %s", esp_err_to_name(result));
|
||||
ESP_LOGE(TAG, "==========================");
|
||||
ESP_LOGE(TAG, "Ensure that received MAC is: %02X:%02X:%02X:%02X:%02X:%02X",
|
||||
receiver_mac[0], receiver_mac[1], receiver_mac[2],
|
||||
receiver_mac[3], receiver_mac[4], receiver_mac[5]);
|
||||
}
|
||||
}
|
||||
|
||||
// Callback function to handle the status of data transmission
|
||||
// This function is called when the data is sent or if there is an error.
|
||||
static void statusDataSend(const uint8_t *mac_addr, esp_now_send_status_t status)
|
||||
{
|
||||
if (status == ESP_NOW_SEND_SUCCESS) {
|
||||
ESP_LOGI(TAG, "Data sent successfully to: %02X:%02X:%02X:%02X:%02X:%02X",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
} else if (status != ESP_NOW_SEND_SUCCESS) {// == ESP_NOW_SEND_FAIL) {
|
||||
ESP_LOGE(TAG, "Error sending data to: %02X:%02X:%02X:%02X:%02X:%02X",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
ESP_LOGE(TAG, "Error sending data. Error code: 0x%04X", status);
|
||||
ESP_LOGE(TAG, "esp_now_send() failed: %s", esp_err_to_name(status));
|
||||
ESP_LOGE(TAG, "Ensure that receiver is powered-on and MAC is correct.");
|
||||
//deletePeer();
|
||||
|
||||
esp_now_del_peer(receiver_mac);
|
||||
esp_now_deinit();
|
||||
esp_wifi_set_channel(espnow_channel, WIFI_SECOND_CHAN_NONE);
|
||||
esp_now_init();
|
||||
memcpy(devices.peer_addr, receiver_mac, 6);
|
||||
devices.channel = espnow_channel;
|
||||
devices.encrypt = false;
|
||||
esp_now_add_peer(&devices);
|
||||
esp_now_register_send_cb(statusDataSend);
|
||||
if (espnow_channel < 11) {
|
||||
espnow_channel++;
|
||||
}/* else {
|
||||
esp_restart();
|
||||
//espnow_channel = 1; // Reset to channel 1 if it exceeds 11
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/* WiFi should start before using ESPNOW */
|
||||
void wifi_init()
|
||||
{
|
||||
/*
|
||||
* STAND-ALONE
|
||||
*/
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA));//ESPNOW_WIFI_MODE));
|
||||
ESP_ERROR_CHECK( esp_wifi_start());
|
||||
//ESP_ERROR_CHECK( esp_wifi_set_channel(CONFIG_ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE));
|
||||
ESP_ERROR_CHECK( esp_wifi_set_channel(espnow_channel, WIFI_SECOND_CHAN_NONE)); // 2
|
||||
#if CONFIG_ESPNOW_ENABLE_LONG_RANGE
|
||||
ESP_ERROR_CHECK( esp_wifi_set_protocol(ESPNOW_WIFI_IF, WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_LR) );
|
||||
#endif
|
||||
/*
|
||||
* WI-FI
|
||||
*/
|
||||
/*
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA));//ESPNOW_WIFI_MODE));
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = "IoT_bots2",
|
||||
.password = "208208208",
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK (esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
||||
//ESP_ERROR_CHECK( esp_wifi_set_channel(CONFIG_ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE));
|
||||
ESP_ERROR_CHECK( esp_wifi_start());
|
||||
//ESP_ERROR_CHECK( esp_wifi_set_channel(CONFIG_ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE));
|
||||
ESP_ERROR_CHECK( esp_wifi_connect() );
|
||||
*/
|
||||
}
|
||||
|
||||
// Task to periodically send ESPNOW remote control data
|
||||
static void rc_send_data_task()
|
||||
{
|
||||
while (true) {
|
||||
if (esp_now_is_peer_exist((uint8_t*)receiver_mac)) {
|
||||
sendData();
|
||||
}
|
||||
vTaskDelay (250 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
static void rc_display_data_task()
|
||||
{
|
||||
while (true) {
|
||||
joystick_show_raw_xy();
|
||||
ESP_LOGI(TAG, "Channel is set at %d", espnow_channel);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
void transmission_init()
|
||||
{
|
||||
esp_err_t espnow_ret = esp_now_init();
|
||||
if (espnow_ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_now_init() failed: %s", esp_err_to_name(espnow_ret));
|
||||
return;
|
||||
}
|
||||
ESP_LOGI(TAG, "ESPNOW initialized successfully");
|
||||
esp_now_register_send_cb(statusDataSend);
|
||||
|
||||
// Set ESP-NOW receiver device configuration values
|
||||
memcpy(devices.peer_addr, receiver_mac, 6);
|
||||
devices.channel = espnow_channel;
|
||||
devices.encrypt = false;
|
||||
esp_now_add_peer(&devices);
|
||||
|
||||
// Defince a task for periodically sending ESPNOW remote control data
|
||||
xTaskCreate(rc_send_data_task, "RC", 8096, NULL, 4, NULL);
|
||||
|
||||
xTaskCreate(rc_display_data_task, "RC Display", 8096, NULL, 5, NULL);
|
||||
}
|
@@ -1,84 +0,0 @@
|
||||
#include "sensors_data.h"
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_now.h"
|
||||
#include "config.h"
|
||||
#include "joystick.h"
|
||||
|
||||
#include "sensors_data.h"
|
||||
|
||||
extern sensors_data_t buffer;
|
||||
static int x, y; // Joystick x and y positions
|
||||
adc_oneshot_unit_handle_t adc_xy_handle;
|
||||
//uint8_t receiver_mac[ESP_NOW_ETH_ALEN] = {0xE4, 0xB0, 0x63, 0x17, 0x9E, 0x45}; // MAC address of Robot
|
||||
//extern uint8_t receiver_mac[ESP_NOW_ETH_ALEN];
|
||||
|
||||
uint8_t broadcast_mac[ESP_NOW_ETH_ALEN] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // Broadcast MAC address
|
||||
uint8_t receiver_mac[ESP_NOW_ETH_ALEN] = {0xE4, 0xB0, 0x63, 0x17, 0x9E, 0x45}; // MAC address of Robot
|
||||
uint8_t transmitter_mac[ESP_NOW_ETH_ALEN] = {0x34, 0xB7, 0xDA, 0xF9, 0x33, 0x8D}; // MAC address of Remote Control
|
||||
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
// Function to delete peer (i.e. when communication error occurs)
|
||||
void deletePeer (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) {
|
||||
// Convert the joystick axis value to a PWM value
|
||||
// Assuming axis_value is in the range of 0-4095 for a 12-bit ADC
|
||||
// and we want to map it to a PWM range of 0-255
|
||||
return (axis_value * 255) / 4095;
|
||||
}
|
||||
|
||||
void get_joystick_xy_axis(int *x_axis, int *y_axis) {
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_0, x_axis));
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_1, y_axis));
|
||||
}
|
||||
|
||||
void sendRawData(void) {
|
||||
|
||||
buffer.crc = 0;
|
||||
buffer.x_axis = 240;
|
||||
buffer.y_axis = 256;
|
||||
buffer.nav_bttn = 0;
|
||||
buffer.motor1_rpm_pcm = 0;
|
||||
buffer.motor2_rpm_pcm = 0;
|
||||
buffer.motor3_rpm_pcm = 0;
|
||||
buffer.motor4_rpm_pcm = 0;
|
||||
|
||||
get_joystick_xy_axis(&x, &y);
|
||||
buffer.x_axis = x;
|
||||
buffer.y_axis = y;
|
||||
|
||||
// Display brief summary of data being sent.
|
||||
ESP_LOGI("ESP-NOW", "Joystick (x,y) position ( %d, %d )", buffer.x_axis, buffer.y_axis);
|
||||
ESP_LOGI("ESP-NOW", "pcm 1, pcm 2 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor1_rpm_pcm, (uint8_t)buffer.motor2_rpm_pcm);
|
||||
ESP_LOGI("ESP-NOW", "pcm 3, pcm 4 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor3_rpm_pcm, (uint8_t)buffer.motor4_rpm_pcm);
|
||||
|
||||
// Call ESP-NOW function to send data (MAC address of receiver, pointer to the memory holding data & data length)
|
||||
uint8_t result = esp_now_send(receiver_mac, (uint8_t *)&buffer, sizeof(buffer));
|
||||
|
||||
// If status is NOT OK, display error message and error code (in hexadecimal).
|
||||
if (result != 0) {
|
||||
ESP_LOGE("sendData()", "Error sending data! Error code: 0x%04X", result);
|
||||
ESP_LOGE("sendData()", "esp_now_send() failed: %s", esp_err_to_name(result));
|
||||
ESP_LOGE("sendData()", "Ensure that receiver is powered-on.");
|
||||
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[3], receiver_mac[4], receiver_mac[5]);
|
||||
deleteDev();
|
||||
}
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
#ifndef JOYSTICK_H
|
||||
#define JOYSTICK_H
|
||||
|
||||
#include "esp_mac.h"
|
||||
#include "esp_now.h"
|
||||
#include "esp_netif.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
void wifi_init();
|
||||
esp_err_t joystick_adc_init(void);
|
||||
void transmission_init();
|
||||
|
||||
static void rc_send_data_task();
|
||||
static void sendData (void);
|
||||
static void get_joystick_xy(int *x_axis, int *y_axis);
|
||||
static void deletePeer (void);
|
||||
static void statusDataSend(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
//void joystick_show_raw_xy();
|
||||
|
||||
#endif
|
@@ -1,152 +0,0 @@
|
||||
#ifndef JOYSTICK_H
|
||||
#define JOYSTICK_H
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/timers.h"
|
||||
|
||||
//#include "driver/adc.h"
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "sensors_data.h"
|
||||
|
||||
/*#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_event.h"*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
uint8_t broadcast_mac[ESP_NOW_ETH_ALEN];// = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // Broadcast MAC address
|
||||
uint8_t receiver_mac[ESP_NOW_ETH_ALEN];// = {0xE4, 0xB0, 0x63, 0x17, 0x9E, 0x45}; // MAC address of Robot
|
||||
uint8_t transmitter_mac[ESP_NOW_ETH_ALEN];// = {0x34, 0xB7, 0xDA, 0xF9, 0x33, 0x8D}; // MAC address of Remote Control
|
||||
|
||||
|
||||
//static int x, y; // Joystick x and y positions
|
||||
//static adc_oneshot_unit_handle_t adc_xy_handle;
|
||||
// Struct holding sensors values
|
||||
/*typedef struct {
|
||||
uint16_t crc; // CRC16 value of ESPNOW data
|
||||
int x_axis; // Joystick x-position
|
||||
int y_axis; // Joystick y-position
|
||||
bool nav_bttn; // Joystick push button
|
||||
uint8_t motor1_rpm_pcm; // PWMs for 4 DC motors
|
||||
uint8_t motor2_rpm_pcm;
|
||||
uint8_t motor3_rpm_pcm;
|
||||
uint8_t motor4_rpm_pcm;
|
||||
} __attribute__((packed)) sensors_data_t;*/
|
||||
|
||||
static int x, y; // Joystick x and y positions
|
||||
adc_oneshot_unit_handle_t adc_xy_handle;
|
||||
sensors_data_t buffer;
|
||||
|
||||
int convert_axis_to_pwm(int axis_value);
|
||||
void get_joystick_xy_axis(int *x_axis, int *y_axis);
|
||||
void sendRawData(void);
|
||||
void deleteDev(void);
|
||||
void deletePeer(void);
|
||||
|
||||
//static sensors_data_t buffer;
|
||||
esp_err_t joystick_adc_init(void) {
|
||||
adc_oneshot_unit_init_cfg_t adc_init_config_xy = {
|
||||
.unit_id = ADC_UNIT_1,
|
||||
.ulp_mode = ADC_ULP_MODE_DISABLE,
|
||||
};
|
||||
ESP_ERROR_CHECK(adc_oneshot_new_unit(&adc_init_config_xy, &adc_xy_handle));
|
||||
|
||||
adc_oneshot_chan_cfg_t config_x = {
|
||||
.bitwidth = SOC_ADC_DIGI_MAX_BITWIDTH,
|
||||
.atten = ADC_ATTEN_DB_12,
|
||||
};
|
||||
adc_oneshot_chan_cfg_t config_y = {
|
||||
.bitwidth = SOC_ADC_DIGI_MAX_BITWIDTH,
|
||||
.atten = ADC_ATTEN_DB_12,
|
||||
};
|
||||
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_xy_handle, ADC_CHANNEL_0, &config_x));
|
||||
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc_xy_handle, ADC_CHANNEL_1, &config_y));
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void joystick_show_raw_xy() {
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_0, &x));
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_1, &y));
|
||||
ESP_LOGI("(x,y)", "( %d, %d )", x, y);
|
||||
}
|
||||
|
||||
void get_joystick_xy(int *x_axis, int *y_axis) {
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_0, x_axis));
|
||||
ESP_ERROR_CHECK(adc_oneshot_read(adc_xy_handle, ADC_CHANNEL_1, y_axis));
|
||||
}
|
||||
|
||||
void joystick_task(void *arg) {
|
||||
while (true) {
|
||||
joystick_show_raw_xy();
|
||||
vTaskDelay (1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void statusDataSend(const uint8_t *mac_addr, esp_now_send_status_t status) {
|
||||
if (status == ESP_NOW_SEND_SUCCESS) {
|
||||
ESP_LOGI(TAG, "Data sent successfully to: %02X:%02X:%02X:%02X:%02X:%02X",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Error sending data to: %02X:%02X:%02X:%02X:%02X:%02X",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
ESP_LOGE("sendData()", "Error sending data. Error code: 0x%04X", status);
|
||||
ESP_LOGE("sendData()", "esp_now_send() failed: %s", esp_err_to_name(status));
|
||||
ESP_LOGE("sendData()", "Ensure that receiver is powered-on and MAC is correct.");
|
||||
deletePeer();
|
||||
}
|
||||
}
|
||||
// Function for sending the data to the receiver
|
||||
void sendData (void)
|
||||
{
|
||||
buffer.crc = 0;
|
||||
buffer.x_axis = 240;
|
||||
buffer.y_axis = 256;
|
||||
buffer.nav_bttn = 0;
|
||||
buffer.motor1_rpm_pcm = 0; //10;
|
||||
buffer.motor2_rpm_pcm = 0;
|
||||
buffer.motor3_rpm_pcm = 0;
|
||||
buffer.motor4_rpm_pcm = 0;
|
||||
|
||||
get_joystick_xy(&x, &y);
|
||||
//ESP_LOGI("(x, y)", "[ %d, %d ]", x, y);
|
||||
buffer.x_axis = x;
|
||||
buffer.y_axis = y;
|
||||
|
||||
// Display brief summary of data being sent.
|
||||
ESP_LOGI(TAG, "Joystick (x,y) position ( %d, %d )", buffer.x_axis, buffer.y_axis);
|
||||
ESP_LOGI(TAG, "pcm 1, pcm 2 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor1_rpm_pcm, (uint8_t)buffer.motor2_rpm_pcm);
|
||||
ESP_LOGI(TAG, "pcm 3, pcm 4 [ 0x%04X, 0x%04X ]", (uint8_t)buffer.motor3_rpm_pcm, (uint8_t)buffer.motor4_rpm_pcm);
|
||||
|
||||
// Call ESP-NOW function to send data (MAC address of receiver, pointer to the memory holding data & data length)
|
||||
uint8_t result = esp_now_send(receiver_mac, (uint8_t *)&buffer, sizeof(buffer));
|
||||
|
||||
// If status is NOT OK, display error message and error code (in hexadecimal).
|
||||
if (result != 0) {
|
||||
ESP_LOGE("sendData()", "Error sending data! Error code: 0x%04X", result);
|
||||
ESP_LOGE("sendData()", "esp_now_send() failed: %s", esp_err_to_name(result));
|
||||
ESP_LOGE("sendData()", "Ensure that receiver is powered-on.");
|
||||
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[3], receiver_mac[4], receiver_mac[5]);
|
||||
deletePeer();
|
||||
}
|
||||
}
|
||||
/*void rc_send_data_task()
|
||||
{
|
||||
while (true) {
|
||||
if (esp_now_is_peer_exist(receiver_mac))
|
||||
sendData();
|
||||
vTaskDelay (250 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}*/
|
||||
|
||||
#endif
|
@@ -20,11 +20,6 @@ static sensors_data_t buffer;
|
||||
static float temperature_value = 0.0;
|
||||
static int espnow_channel = 1;
|
||||
|
||||
//void transmission_init();
|
||||
//void wifi_init();
|
||||
|
||||
//static void statusDataSend(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
// Function to delete peer (i.e. when communication error occurs)
|
||||
static void deletePeer (void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user