sphinx-key: split button led sd into separate mods

fixes tons of warnings when building the clear binary
This commit is contained in:
irriden
2023-11-23 17:39:06 +00:00
parent 460f3dbe97
commit b4491c48ab
9 changed files with 8 additions and 78 deletions

1
.gitignore vendored
View File

@@ -13,5 +13,4 @@ teststore2
*.pem
*.txt
*.bin
*.md
*.diff

View File

@@ -42,10 +42,6 @@ embuild = "0.31.2"
name = "clear"
path = "src/clear.rs"
[[bin]]
name = "btn"
path = "src/btn.rs"
[profile.release]
codegen-units = 1
lto = true

View File

@@ -1,54 +0,0 @@
mod conn;
mod core;
mod ota;
mod periph;
mod status;
pub use crate::core::control::FlashPersister;
use esp_idf_svc::hal::gpio::Gpio0;
use esp_idf_svc::hal::gpio::Gpio9;
use esp_idf_svc::hal::peripheral::Peripheral;
use esp_idf_svc::hal::peripherals::Peripherals;
use esp_idf_svc::nvs::EspDefaultNvsPartition;
use esp_idf_svc::sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
use status::Status;
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
const ID_LEN: usize = 16;
fn main() -> anyhow::Result<()> {
esp_idf_svc::sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();
thread::sleep(Duration::from_secs(1));
let mut peripherals = Peripherals::take().unwrap();
// LED control thread
let (mut led_tx, mut led_rx) = mpsc::channel::<Status>();
while let Err(e) = periph::led::led_control_loop(
unsafe { Gpio0::new() },
unsafe { peripherals.rmt.channel0.clone_unchecked() },
led_rx,
) {
log::error!("unable to spawn led thread: {:?}", e);
thread::sleep(Duration::from_millis(1000));
(led_tx, led_rx) = mpsc::channel::<Status>();
}
// BUTTON thread
let default_nvs = EspDefaultNvsPartition::take()?;
let flash_per = FlashPersister::new(default_nvs);
let flash_arc = Arc::new(Mutex::new(flash_per));
while let Err(e) =
periph::button::button_loop(unsafe { Gpio9::new() }, led_tx.clone(), flash_arc.clone())
{
log::error!("unable to spawn button thread: {:?}", e);
thread::sleep(Duration::from_millis(1000));
}
loop {
thread::sleep(Duration::from_millis(1000));
}
}

View File

@@ -1,17 +1,7 @@
mod conn;
mod core;
mod ota;
mod periph;
mod status;
#[allow(unused_imports)]
use crate::periph::sd::mount_sd_card;
mod sd;
use crate::sd::mount_sd_card;
use esp_idf_svc as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
// use esp_idf_svc::nvs::EspNvs;
// use esp_idf_svc::nvs::*;
use std::fs;
use std::path::Path;

View File

@@ -1,15 +1,17 @@
mod button;
mod conn;
mod core;
mod led;
mod ota;
mod periph;
mod sd;
mod status;
use crate::button::button_loop;
use crate::core::control::controller_from_seed;
use crate::core::{config::*, events::*, FlashPersister};
use crate::periph::button::button_loop;
use crate::periph::led::led_control_loop;
use crate::led::led_control_loop;
#[allow(unused_imports)]
use crate::periph::sd::{mount_sd_card, simple_fs_test};
use crate::sd::{mount_sd_card, simple_fs_test};
use crate::status::Status;
use anyhow::Result;
use esp_idf_svc::hal::gpio::{Gpio0, Gpio9};

View File

@@ -1,3 +0,0 @@
pub mod button;
pub mod led;
pub mod sd;