Use thread::sleep for better efficency

This commit is contained in:
Your Name 2021-10-10 16:43:08 +01:00
parent c295839a9a
commit b5b4bf3b41
2 changed files with 29 additions and 7 deletions

View File

@ -1,7 +1,9 @@
# aw-lights
= aw-lights
== Setup
[source,bash]
----
# Install packages
xbps-install fake-hwclock
ln -s /etc/sv/fake-hwclock/ /var/service/
@ -11,3 +13,19 @@ echo 'dtparam=spi=on' >>/boot/config.txt
# Allow big buf for SPI
echo 'options spidev bufsiz=65536' > /etc/modprobe.d/spidev.conf
----
Set CPU clock
* RPI3
+
[title='/boot/config.txt']
----
core_freq=250
----
* RPI4
+
[title='/boot/config.txt']
----
core_freq=500
core_freq_min=500
----

View File

@ -180,11 +180,15 @@ impl LedStrip {
process::exit(0);
}
loop {
if Instant::now() >= target_time {
break;
}
}
// Wait out the rest of the time
thread::sleep(target_time.saturating_duration_since(Instant::now()));
// Required if clock is not set up properly
// loop {
// if Instant::now() >= target_time {
// break;
// }
// }
}
}
}