Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added basic FPV example with XIAO board #22

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading