From 99d33fdcabb2a64fc4d6b67da8b983db368070b5 Mon Sep 17 00:00:00 2001 From: Sofia Date: Wed, 13 May 2026 17:51:32 +0300 Subject: [PATCH] Make screen color change be 10fps --- src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 033e145..c15617c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use esp_hal::{ gpio::{Level, Output, OutputConfig}, main, spi::master::{Config, Spi}, - time::Rate, + time::{Duration, Instant, Rate}, }; use esp_backtrace as _; @@ -69,7 +69,7 @@ fn main() -> ! { let spi = Spi::new( peripherals.SPI2, Config::default() - .with_frequency(Rate::from_mhz(40)) + .with_frequency(Rate::from_mhz(80)) .with_mode(esp_hal::spi::Mode::_2) .with_read_bit_order(esp_hal::spi::BitOrder::MsbFirst) .with_write_bit_order(esp_hal::spi::BitOrder::MsbFirst), @@ -94,7 +94,7 @@ fn main() -> ! { color_order: display::ColorOrder::Bgr, ..Default::default() }); - display.set_tearing(display::TearingMode::Horizontal); + display.set_tearing(display::TearingMode::Off); display.draw_rect( Position::new(0, 0), @@ -107,6 +107,8 @@ fn main() -> ! { let mut color = 0; loop { + let delay_start = Instant::now(); + log::info!("Hello world: {}", color); color = (color + 50) % 200; @@ -119,9 +121,8 @@ fn main() -> ! { }, ); - // let delay_start = Instant::now(); - // while delay_start.elapsed() < Duration::from_millis(500) {} - test_delay.delay_millis(1000); + while delay_start.elapsed() < Duration::from_millis(100) {} + // test_delay.delay_millis(1); } // for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.1.0/examples