diff --git a/examples/xiao-fpv-sender/xiao-fpv-sender.cpp b/examples/xiao-fpv-sender/xiao-fpv-sender.cpp new file mode 100644 index 0000000..8ecb29c --- /dev/null +++ b/examples/xiao-fpv-sender/xiao-fpv-sender.cpp @@ -0,0 +1,65 @@ +/************************************************** + * ESPNowCam video Transmitter. + * ---------------------------- + * + * XIAO FPV ESPNow transmitter uses some extra features of + * this board to have some power consumption improvements + * + * by @hpsaturn Copyright (C) 2024 + * This file is part ESP32S3 camera tests project: + * https://github.com/hpsaturn/esp32s3-cam +**************************************************/ + +#include +#include +#include +#include +#include + +CamXiao Camera; +ESPNowCam radio; +OneButton button1(GPIO_NUM_0, true); + +void processFrame() { + if (Camera.get()) { + uint8_t *out_jpg = NULL; + size_t out_jpg_len = 0; + frame2jpg(Camera.fb, 12, &out_jpg, &out_jpg_len); + radio.sendData(out_jpg, out_jpg_len); + printFPS("CAM:"); + free(out_jpg); + Camera.free(); + } +} + +void shutdown() { + Serial.println("shutdown.."); + esp_sleep_enable_ext0_wakeup(GPIO_NUM_0,0); + delay(1000); + esp_deep_sleep_start(); +} + +void setup() { + Serial.begin(115200); + + delay(1000); // only for debugging + + if(psramFound()){ + size_t psram_size = esp_spiram_get_size() / 1048576; + Serial.printf("PSRAM size: %dMb\r\n", psram_size); + } + + radio.init(); + if (!Camera.begin()) { + Serial.println("Camera Init Fail"); + delay(1000); + } + + button1.attachClick([]() { shutdown(); }); + delay(100); +} + +void loop() { + processFrame(); + button1.tick(); +} diff --git a/platformio.ini b/platformio.ini index 7984f39..09853df 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,16 +29,26 @@ board = esp32-s3-devkitc-1 board_build.flash_size = 16MB board_build.partitions = ./config/partitions.csv -[env:xiao-espnow-sender] +[xiao-common] extends = esp32common board_build.arduino.memory_type = dio_opi ; board_build.flash_size = 8MB -build_src_filter = -<*> -<*common*> + build_flags = ${env.build_flags} -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 +[env:xiao-espnow-sender] +extends = xiao-common +build_src_filter = -<*> -<*common*> + + +[env:xiao-fpv-sender] +extends = xiao-common +build_src_filter = -<*> -<*common*> + +lib_deps = + ${esp32common.lib_deps} + mathertel/OneButton@^2.0.3 + [env:freenove-tank] extends = esp32common board_build.arduino.memory_type = dio_opi ;