@Valda60
Industrial software engineer (embedded and computer platforms). Rust enthusiast.
Nothing here yet.
Nothing here yet.
No blogs yet.
Hello Omar, Do you know what happens when the adc.read function returns 0 ? Temperature computation will do a floating division by 0 (=+INF). I have tested on Wokwi, it seems OK (Temperature -273.15 Celcius). Rust follows the IEEE 754 rules.
Omar Hiari I have another suggestion. It concerns the displayed message. I have added a remark to the issue #2 on github repository (more clear than typing it here). It is about the decimal that can't be displayed because of the computation that gives an integer result. By the way, it permits to increase timer resolution in the displayed message.
Another suggestion, you can remove all the "return" key words of the button_pressed function (don't forget to remove also semicolon). It is more idiomatic Rust, but also less readable for the new comer. fn button pressed(but: &PinDriver<' , Gpio3, Input>, del: &u32) -> u32 { // Check if Button has been pressed // If not pressed, return the delay value unchanged if but.is_low() { // if the value of the delay passed is less of equal to 50 then reset it to initial value // else subtract 50 from the passed delay println!("Button Pressed!"); if del <= &50_u32 { 200_u32 } else { 50_u32 } } else { *del } }
I think you should use an array instead of declaring 10 variables (one variable by pin!). Then you will be able to iterate the array with a for loop. // Configure all LED pins to digital outputs let mut leds = [ PinDriver::output(dp.pins.gpio1.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio10.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio19.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio18.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio4.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio5.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio6.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio7.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio8.downgrade_output()).unwrap(), PinDriver::output(dp.pins.gpio9.downgrade_output()).unwrap(), ]; // Put the following code in the loop for mut led in &mut leds { // LED i led.set_high().unwrap(); blinkdelay = button_pressed(&button, &blinkdelay); FreeRtos::delay_ms(blinkdelay); led.set_low().unwrap(); FreeRtos::delay_ms(100_u32); } // I have tested the result on wokwi