Fixed the code
This commit is contained in:
parent
0334c851f8
commit
389aa9e96c
|
|
@ -14,7 +14,7 @@ opt-level = "z"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
esp-camera-rs = { path = "../../", version = "*" }
|
esp-camera-rs = { path = "../../", version = "*" }
|
||||||
|
#esp-hal = { version = "1.0.0", features = ["unstable", "esp32s3"] }
|
||||||
log = { version = "0.4", default-features = false }
|
log = { version = "0.4", default-features = false }
|
||||||
anyhow = "1.0.100"
|
anyhow = "1.0.100"
|
||||||
esp-idf-svc = { version = "0.51.0", default-features = false, features = [
|
esp-idf-svc = { version = "0.51.0", default-features = false, features = [
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use esp_idf_svc::hal::{gpio::PinDriver, peripherals::Peripherals};
|
||||||
use esp_idf_sys::esp_deep_sleep;
|
use esp_idf_sys::esp_deep_sleep;
|
||||||
use log::info;
|
use log::info;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
// It is necessary to call this function once. Otherwise some patches to the runtime
|
// It is necessary to call this function once. Otherwise some patches to the runtime
|
||||||
|
|
@ -17,7 +18,10 @@ fn main() -> anyhow::Result<()> {
|
||||||
// ESP32-CAM has an onboard Flash LED addressed at GPIO-4
|
// ESP32-CAM has an onboard Flash LED addressed at GPIO-4
|
||||||
let mut flash = PinDriver::output(peripherals.pins.gpio4)?;
|
let mut flash = PinDriver::output(peripherals.pins.gpio4)?;
|
||||||
flash.set_low()?;
|
flash.set_low()?;
|
||||||
|
flash.set_high()?;
|
||||||
|
blocking_delay(Duration::from_millis(5000));
|
||||||
|
flash.set_low()?;
|
||||||
|
info!("setting up the gio pins");
|
||||||
// Initialize the camera
|
// Initialize the camera
|
||||||
let camera = esp_camera_rs::Camera::new(
|
let camera = esp_camera_rs::Camera::new(
|
||||||
peripherals.pins.gpio32,
|
peripherals.pins.gpio32,
|
||||||
|
|
@ -74,3 +78,8 @@ fn main() -> anyhow::Result<()> {
|
||||||
info!("finished, entering deep sleep for {delay:#?}");
|
info!("finished, entering deep sleep for {delay:#?}");
|
||||||
unsafe { esp_deep_sleep(delay.as_micros() as u64) }
|
unsafe { esp_deep_sleep(delay.as_micros() as u64) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn blocking_delay(duration: Duration) {
|
||||||
|
let delay_start = Instant::now();
|
||||||
|
while delay_start.elapsed() < duration {}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue