From b5b4bf3b415eb5d26fc5d8e85c8980f7b8a8df4c Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 10 Oct 2021 16:43:08 +0100 Subject: [PATCH] Use thread::sleep for better efficency --- README.adoc | 22 ++++++++++++++++++++-- src/strip.rs | 14 +++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.adoc b/README.adoc index bdb6896..4b8e06c 100644 --- a/README.adoc +++ b/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 +---- diff --git a/src/strip.rs b/src/strip.rs index a2931d7..8e2e33b 100644 --- a/src/strip.rs +++ b/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; + // } + // } } } }