Use thread::sleep for better efficency
This commit is contained in:
parent
c295839a9a
commit
b5b4bf3b41
22
README.adoc
22
README.adoc
@ -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
|
||||
----
|
||||
|
14
src/strip.rs
14
src/strip.rs
@ -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;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user