diff --git a/.cargo/config.toml b/.cargo/config.toml index 94c3919..947bc5d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,16 +3,19 @@ target = "xtensa-esp32s3-espidf" [target.xtensa-esp32s3-espidf] linker = "ldproxy" -runner = "espflash flash --monitor" # Select this runner for espflash v3.x.x -rustflags = [ "--cfg", "espidf_time64"] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110 +runner = "espflash flash --monitor --partition-table partitions.csv --flash-size 4mb" # Select this runner for espflash v3.x.x +rustflags = [ + "--cfg", + "espidf_time64", +] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110 [unstable] build-std = ["std", "panic_abort"] [env] -MCU="esp32s3" +MCU = "esp32s3" # Note: this variable is not used by the pio builder (`cargo build --features pio`) ESP_IDF_VERSION = "v5.2.2" -# Workaround for https://github.com/esp-rs/esp-idf-template/issues/174 +# Workaround for https://github.com/esp-rs/esp-idf-template/issues/174 CRATE_CC_NO_DEFAULTS = "1" diff --git a/Cargo.toml b/Cargo.toml index 7630182..e818550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,9 @@ harness = false # do not use the built in cargo test harness -> resolve rust-an [profile.release] opt-level = "s" +strip = true +lto = true +codegen-units = 1 [profile.dev] debug = true # Symbols are nice and they don't increase the size on Flash @@ -34,7 +37,7 @@ anyhow = "1.0.95" http = "1.2.0" serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.134" -embassy-time = "0.3.0" +embassy-time = { version = "*", features = ["generic-queue"] } semver = "1.0.24" async-io = "2.4.0" url = "2.5.4" diff --git a/partitions.csv b/partitions.csv new file mode 100644 index 0000000..36e876a --- /dev/null +++ b/partitions.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x1e0000, +app1, app, ota_1, 0x1f0000, 0x1e0000, +spiffs, data, spiffs, 0x3d0000, 0x20000, +coredump, data, coredump, 0x3f0000, 0x10000, \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 21af134..89c9b8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,13 +4,18 @@ use beacons::{ Displays, Leds, }; use build_time::build_time_utc; +use embassy_time::Timer; use esp_idf_svc::{ eventloop::EspSystemEventLoop, hal::{ gpio::{AnyInputPin, OutputPin, PinDriver}, prelude::Peripherals, - spi::{config::DriverConfig, SpiBusDriver, SpiDriver}, + spi::{ + config::{Config, DriverConfig}, + SpiBusDriver, SpiDriver, + }, task::block_on, + units::Hertz, }, io, nvs::EspDefaultNvsPartition, @@ -23,18 +28,26 @@ use ws2812_spi::Ws2812; async fn amain(displays: Displays, mut leds: Leds, mut wifi: AsyncWifi>) { // Red before wifi - leds.set_all_colors(smart_leds::RGB { r: 255, g: 0, b: 0 }); + leds.set_all_colors(smart_leds::RGB { r: 100, g: 0, b: 0 }); connect_to_network(&mut wifi) .await .expect("wifi connection"); // Blue before update - leds.set_all_colors(smart_leds::RGB { r: 0, g: 0, b: 255 }); - - self_update(&mut leds).await.expect("self update"); - - todo!() + leds.set_all_colors(smart_leds::RGB { r: 0, g: 0, b: 100 }); + + // Do this later once I have a build system working + // self_update(&mut leds).await.expect("self update"); + + loop { + info!("BLUE"); + leds.set_all_colors(smart_leds::RGB { r: 0, g: 0, b: 100 }); + Timer::after_secs(1).await; + info!("RED"); + leds.set_all_colors(smart_leds::RGB { r: 100, g: 0, b: 0 }); + Timer::after_secs(1).await; + } } fn main() { @@ -91,7 +104,8 @@ fn main() { &DriverConfig::new(), ) .expect("valid spi"); - let bus = SpiBusDriver::new(driver, &Default::default()).expect("valid spi bus"); + let cfg = Config::new().baudrate(Hertz(2_500_000)); + let bus = SpiBusDriver::new(driver, &cfg).expect("valid spi bus"); let leds = Ws2812::new(bus); Leds { leds } diff --git a/src/net.rs b/src/net.rs index d659b40..0458554 100644 --- a/src/net.rs +++ b/src/net.rs @@ -169,7 +169,7 @@ pub async fn self_update(leds: &mut Leds) -> anyhow::Result<()> { if remote > local { info!("New release found! Downloading and updating"); - leds.set_all_colors(smart_leds::RGB { r: 0, g: 255, b: 0 }); + leds.set_all_colors(smart_leds::RGB { r: 0, g: 100, b: 0 }); // Grab new release and update let url = manifest .assets