Skip to content

Commit

Permalink
LEDs and first flash
Browse files Browse the repository at this point in the history
  • Loading branch information
ImTheSquid committed Jan 4, 2025
1 parent 150ed69 commit f21063a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
11 changes: 7 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions partitions.csv
Original file line number Diff line number Diff line change
@@ -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,
30 changes: 22 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,18 +28,26 @@ use ws2812_spi::Ws2812;

async fn amain(displays: Displays, mut leds: Leds, mut wifi: AsyncWifi<EspWifi<'static>>) {
// 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() {
Expand Down Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f21063a

Please sign in to comment.