Skip to content

Commit f21063a

Browse files
committed
LEDs and first flash
1 parent 150ed69 commit f21063a

File tree

5 files changed

+41
-14
lines changed

5 files changed

+41
-14
lines changed

.cargo/config.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ target = "xtensa-esp32s3-espidf"
33

44
[target.xtensa-esp32s3-espidf]
55
linker = "ldproxy"
6-
runner = "espflash flash --monitor" # Select this runner for espflash v3.x.x
7-
rustflags = [ "--cfg", "espidf_time64"] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110
6+
runner = "espflash flash --monitor --partition-table partitions.csv --flash-size 4mb" # Select this runner for espflash v3.x.x
7+
rustflags = [
8+
"--cfg",
9+
"espidf_time64",
10+
] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110
811

912
[unstable]
1013
build-std = ["std", "panic_abort"]
1114

1215
[env]
13-
MCU="esp32s3"
16+
MCU = "esp32s3"
1417
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
1518
ESP_IDF_VERSION = "v5.2.2"
1619

17-
# Workaround for https://github.com/esp-rs/esp-idf-template/issues/174
20+
# Workaround for https://github.com/esp-rs/esp-idf-template/issues/174
1821
CRATE_CC_NO_DEFAULTS = "1"

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ harness = false # do not use the built in cargo test harness -> resolve rust-an
1212

1313
[profile.release]
1414
opt-level = "s"
15+
strip = true
16+
lto = true
17+
codegen-units = 1
1518

1619
[profile.dev]
1720
debug = true # Symbols are nice and they don't increase the size on Flash
@@ -34,7 +37,7 @@ anyhow = "1.0.95"
3437
http = "1.2.0"
3538
serde = { version = "1.0.217", features = ["derive"] }
3639
serde_json = "1.0.134"
37-
embassy-time = "0.3.0"
40+
embassy-time = { version = "*", features = ["generic-queue"] }
3841
semver = "1.0.24"
3942
async-io = "2.4.0"
4043
url = "2.5.4"

partitions.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Name, Type, SubType, Offset, Size, Flags
2+
nvs, data, nvs, 0x9000, 0x5000,
3+
otadata, data, ota, 0xe000, 0x2000,
4+
app0, app, ota_0, 0x10000, 0x1e0000,
5+
app1, app, ota_1, 0x1f0000, 0x1e0000,
6+
spiffs, data, spiffs, 0x3d0000, 0x20000,
7+
coredump, data, coredump, 0x3f0000, 0x10000,

src/main.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ use beacons::{
44
Displays, Leds,
55
};
66
use build_time::build_time_utc;
7+
use embassy_time::Timer;
78
use esp_idf_svc::{
89
eventloop::EspSystemEventLoop,
910
hal::{
1011
gpio::{AnyInputPin, OutputPin, PinDriver},
1112
prelude::Peripherals,
12-
spi::{config::DriverConfig, SpiBusDriver, SpiDriver},
13+
spi::{
14+
config::{Config, DriverConfig},
15+
SpiBusDriver, SpiDriver,
16+
},
1317
task::block_on,
18+
units::Hertz,
1419
},
1520
io,
1621
nvs::EspDefaultNvsPartition,
@@ -23,18 +28,26 @@ use ws2812_spi::Ws2812;
2328

2429
async fn amain(displays: Displays, mut leds: Leds, mut wifi: AsyncWifi<EspWifi<'static>>) {
2530
// Red before wifi
26-
leds.set_all_colors(smart_leds::RGB { r: 255, g: 0, b: 0 });
31+
leds.set_all_colors(smart_leds::RGB { r: 100, g: 0, b: 0 });
2732

2833
connect_to_network(&mut wifi)
2934
.await
3035
.expect("wifi connection");
3136

3237
// Blue before update
33-
leds.set_all_colors(smart_leds::RGB { r: 0, g: 0, b: 255 });
34-
35-
self_update(&mut leds).await.expect("self update");
36-
37-
todo!()
38+
leds.set_all_colors(smart_leds::RGB { r: 0, g: 0, b: 100 });
39+
40+
// Do this later once I have a build system working
41+
// self_update(&mut leds).await.expect("self update");
42+
43+
loop {
44+
info!("BLUE");
45+
leds.set_all_colors(smart_leds::RGB { r: 0, g: 0, b: 100 });
46+
Timer::after_secs(1).await;
47+
info!("RED");
48+
leds.set_all_colors(smart_leds::RGB { r: 100, g: 0, b: 0 });
49+
Timer::after_secs(1).await;
50+
}
3851
}
3952

4053
fn main() {
@@ -91,7 +104,8 @@ fn main() {
91104
&DriverConfig::new(),
92105
)
93106
.expect("valid spi");
94-
let bus = SpiBusDriver::new(driver, &Default::default()).expect("valid spi bus");
107+
let cfg = Config::new().baudrate(Hertz(2_500_000));
108+
let bus = SpiBusDriver::new(driver, &cfg).expect("valid spi bus");
95109

96110
let leds = Ws2812::new(bus);
97111
Leds { leds }

src/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub async fn self_update(leds: &mut Leds) -> anyhow::Result<()> {
169169

170170
if remote > local {
171171
info!("New release found! Downloading and updating");
172-
leds.set_all_colors(smart_leds::RGB { r: 0, g: 255, b: 0 });
172+
leds.set_all_colors(smart_leds::RGB { r: 0, g: 100, b: 0 });
173173
// Grab new release and update
174174
let url = manifest
175175
.assets

0 commit comments

Comments
 (0)