mirror of
https://github.com/FliegendeWurst/raspi-oled.git
synced 2024-11-22 02:14:58 +00:00
Fix main loop delay
This commit is contained in:
parent
c5a930bed1
commit
ca73b6545a
26
Cargo.lock
generated
26
Cargo.lock
generated
@ -1011,9 +1011,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.6.3"
|
version = "2.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
|
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memmap2"
|
name = "memmap2"
|
||||||
@ -1552,9 +1552,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.9.5"
|
version = "1.9.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
|
checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -1564,9 +1564,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.3.8"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
|
checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -1838,7 +1838,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ssd1351"
|
name = "ssd1351"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/FliegendeWurst/ssd1351-rust#9192fde637a2cc672e27ed1dc324f82e6bb65f72"
|
source = "git+https://github.com/FliegendeWurst/ssd1351-rust?rev=ce3194474355f4433ffe2a63484f263071a0d54e#ce3194474355f4433ffe2a63484f263071a0d54e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"display-interface",
|
"display-interface",
|
||||||
@ -1898,18 +1898,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.48"
|
version = "1.0.49"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7"
|
checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.48"
|
version = "1.0.49"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
|
checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -2084,9 +2084,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ureq"
|
name = "ureq"
|
||||||
version = "2.7.1"
|
version = "2.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b11c96ac7ee530603dcdf68ed1557050f374ce55a5a07193ebf8cbc9f8927e9"
|
checksum = "f5ccd538d4a604753ebc2f17cd9946e89b77bf87f6a8e2309667c6f2e87855e3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"log",
|
"log",
|
||||||
|
@ -14,12 +14,12 @@ libc = "0.2.98"
|
|||||||
rusqlite = "0.27.0"
|
rusqlite = "0.27.0"
|
||||||
time = { version = "0.3.9", features = ["parsing"] }
|
time = { version = "0.3.9", features = ["parsing"] }
|
||||||
time-tz = "1.0.1"
|
time-tz = "1.0.1"
|
||||||
image = "0.24.1"
|
image = { version = "0.24.1", optional = true }
|
||||||
serde_json = "1.0.79"
|
serde_json = "1.0.79"
|
||||||
serde_derive = "1.0.136"
|
serde_derive = "1.0.136"
|
||||||
serde = "1.0.136"
|
serde = "1.0.136"
|
||||||
rppal = { version = "0.13.1", features = ["hal"] }
|
rppal = { version = "0.13.1", features = ["hal"] }
|
||||||
ssd1351 = { git = "https://github.com/FliegendeWurst/ssd1351-rust" }
|
ssd1351 = { git = "https://github.com/FliegendeWurst/ssd1351-rust", rev = "ce3194474355f4433ffe2a63484f263071a0d54e" }
|
||||||
display-interface-spi = "0.4.1"
|
display-interface-spi = "0.4.1"
|
||||||
ureq = { version = "2.4.0", default-features = false }
|
ureq = { version = "2.4.0", default-features = false }
|
||||||
winit = { version = "0.28.7", optional = true }
|
winit = { version = "0.28.7", optional = true }
|
||||||
@ -29,7 +29,7 @@ gpiocdev = "0.6.0"
|
|||||||
#gpio-am2302-rs = { git = "https://github.com/FliegendeWurst/gpio-am2302-rs" }
|
#gpio-am2302-rs = { git = "https://github.com/FliegendeWurst/gpio-am2302-rs" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
pc = ["winit", "softbuffer"]
|
pc = ["winit", "softbuffer", "image"]
|
||||||
default = [ "pc" ]
|
default = [ "pc" ]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
@ -9,7 +9,7 @@ rustPlatform.buildRustPackage {
|
|||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
outputHashes = {
|
outputHashes = {
|
||||||
"ssd1351-0.3.0" = "sha256-K6QCU9qPEuU7Ur8W6fTdi4JWk8NsVz3mLfV0afpfdBA=";
|
"ssd1351-0.3.0" = "sha256-D0gnYbZfSsG/K8BN5N8pmMGtGcqWt7/0gN3UXLRsOlc=";
|
||||||
# "gpio-am2302-rs-1.1.0" = "sha256-tyA/R80LtWIXoVEoxHhkmzy0IsMdMH1Oi3FTQ56XjyQ=";
|
# "gpio-am2302-rs-1.1.0" = "sha256-tyA/R80LtWIXoVEoxHhkmzy0IsMdMH1Oi3FTQ56XjyQ=";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -25,7 +25,7 @@ rustPlatform.buildRustPackage {
|
|||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "OLED display of clock/calendar/temperature";
|
description = "OLED display of clock/calendar/temperature";
|
||||||
homepage = "https://github.com/FliegendeWurst/raspi-oled";
|
homepage = "https://github.com/FliegendeWurst/raspi-oled";
|
||||||
license = licenses.mit;
|
license = licenses.gpl3;
|
||||||
maintainers = with maintainers; [ fliegendewurst ];
|
maintainers = with maintainers; [ fliegendewurst ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
|
thread,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -8,7 +9,6 @@ use display_interface_spi::SPIInterfaceNoCS;
|
|||||||
use embedded_graphics::{pixelcolor::Rgb565, prelude::DrawTarget, Drawable};
|
use embedded_graphics::{pixelcolor::Rgb565, prelude::DrawTarget, Drawable};
|
||||||
use gpiocdev::line::{Bias, EdgeDetection, Value};
|
use gpiocdev::line::{Bias, EdgeDetection, Value};
|
||||||
use rand_xoshiro::{rand_core::SeedableRng, Xoroshiro128StarStar};
|
use rand_xoshiro::{rand_core::SeedableRng, Xoroshiro128StarStar};
|
||||||
use raspi_oled::FrameOutput;
|
|
||||||
use rppal::{
|
use rppal::{
|
||||||
gpio::{Gpio, OutputPin},
|
gpio::{Gpio, OutputPin},
|
||||||
hal::Delay,
|
hal::Delay,
|
||||||
@ -100,6 +100,7 @@ fn pc_main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::screensaver::{Screensaver, DUOLINGO};
|
use crate::screensaver::{Screensaver, DUOLINGO};
|
||||||
|
use raspi_oled::FrameOutput;
|
||||||
|
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
@ -317,6 +318,7 @@ fn main_loop(mut disp: Oled) {
|
|||||||
},
|
},
|
||||||
6 => {
|
6 => {
|
||||||
menu.push(2);
|
menu.push(2);
|
||||||
|
ctx.do_action(Action::Screensaver("rpi"));
|
||||||
},
|
},
|
||||||
5 => {
|
5 => {
|
||||||
menu.push(3);
|
menu.push(3);
|
||||||
@ -325,7 +327,7 @@ fn main_loop(mut disp: Oled) {
|
|||||||
println!("unknown offset: {}", e.offset);
|
println!("unknown offset: {}", e.offset);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
println!("menu: {menu:?}");
|
//println!("menu: {menu:?}");
|
||||||
}
|
}
|
||||||
// clean up stale menu selection
|
// clean up stale menu selection
|
||||||
if !menu.is_empty() && Instant::now().duration_since(last_button).as_secs() >= 10 {
|
if !menu.is_empty() && Instant::now().duration_since(last_button).as_secs() >= 10 {
|
||||||
@ -336,5 +338,6 @@ fn main_loop(mut disp: Oled) {
|
|||||||
if dirty {
|
if dirty {
|
||||||
let _ = disp.flush(); // ignore bus write errors, they are harmless
|
let _ = disp.flush(); // ignore bus write errors, they are harmless
|
||||||
}
|
}
|
||||||
|
thread::sleep(Duration::from_millis(1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,15 @@ use embedded_graphics::{
|
|||||||
prelude::{OriginDimensions, RgbColor, Size},
|
prelude::{OriginDimensions, RgbColor, Size},
|
||||||
};
|
};
|
||||||
use gpiocdev::line::{Bias, EdgeDetection, EdgeKind, Value};
|
use gpiocdev::line::{Bias, EdgeDetection, EdgeKind, Value};
|
||||||
|
#[cfg(feature = "pc")]
|
||||||
use image::{ImageBuffer, Rgb};
|
use image::{ImageBuffer, Rgb};
|
||||||
|
|
||||||
|
#[cfg(feature = "pc")]
|
||||||
pub struct FrameOutput {
|
pub struct FrameOutput {
|
||||||
pub buffer: ImageBuffer<Rgb<u8>, Vec<u8>>,
|
pub buffer: ImageBuffer<Rgb<u8>, Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "pc")]
|
||||||
impl FrameOutput {
|
impl FrameOutput {
|
||||||
pub fn new(width: u32, height: u32) -> Self {
|
pub fn new(width: u32, height: u32) -> Self {
|
||||||
FrameOutput {
|
FrameOutput {
|
||||||
@ -23,6 +26,7 @@ impl FrameOutput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "pc")]
|
||||||
impl DrawTarget for FrameOutput {
|
impl DrawTarget for FrameOutput {
|
||||||
type Color = Rgb565;
|
type Color = Rgb565;
|
||||||
|
|
||||||
@ -49,6 +53,7 @@ impl DrawTarget for FrameOutput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "pc")]
|
||||||
impl OriginDimensions for FrameOutput {
|
impl OriginDimensions for FrameOutput {
|
||||||
fn size(&self) -> Size {
|
fn size(&self) -> Size {
|
||||||
Size::new(self.buffer.width(), self.buffer.height())
|
Size::new(self.buffer.width(), self.buffer.height())
|
||||||
|
Loading…
Reference in New Issue
Block a user