Skip to content

Commit

Permalink
Merge pull request #22 from hpsaturn/xiao_improv
Browse files Browse the repository at this point in the history
added basic FPV example with XIAO board
  • Loading branch information
hpsaturn authored Apr 27, 2024
2 parents 21185c5 + e7bc697 commit 8affd6b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
65 changes: 65 additions & 0 deletions examples/xiao-fpv-sender/xiao-fpv-sender.cpp
Original file line number Diff line number Diff line change
@@ -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 <Arduino.h>
#include <OneButton.h>
#include <ESPNowCam.h>
#include <drivers/CamXiao.h>
#include <Utils.h>

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();
}
14 changes: 12 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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*> +<xiao-espnow-sender/>
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*> +<xiao-espnow-sender/>

[env:xiao-fpv-sender]
extends = xiao-common
build_src_filter = -<*> -<*common*> +<xiao-fpv-sender/>
lib_deps =
${esp32common.lib_deps}
mathertel/OneButton@^2.0.3

[env:freenove-tank]
extends = esp32common
board_build.arduino.memory_type = dio_opi ;
Expand Down

0 comments on commit 8affd6b

Please sign in to comment.