A simple to-do app focused on tasks that can be completed within a specific time span.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

display todos on display

ToBinio 7ff3ad1f d2f2de93

+35 -13
+3
rpi-checker/Cargo.toml
··· 8 8 9 9 tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread"] } 10 10 dotenvy = "0.15.7" 11 + 12 + rpi-pal = { version = "0.22.3", features = ["embedded-hal"] } 13 + lcd-lcm1602-i2c = { version = "0.3.0" }
+32 -13
rpi-checker/src/main.rs
··· 1 1 use client::fetch::get_todos; 2 + use rpi_pal::{hal::Delay, i2c::I2c}; 2 3 3 4 #[tokio::main] 4 5 async fn main() { 6 + let (token, server_url) = env(); 7 + 8 + let mut todos_rx = get_todos(server_url, token); 9 + 10 + // pins 3 (SDA) and 5 (SCL) 11 + let mut i2c = I2c::new().unwrap(); 12 + let mut delay = Delay::new(); 13 + let mut lcd = lcd_lcm1602_i2c::sync_lcd::Lcd::new(&mut i2c, &mut delay) 14 + .with_address(0x27) 15 + .with_cursor_on(false) // no visible cursos 16 + .with_rows(2) // two rows 17 + .init() 18 + .unwrap(); 19 + 20 + while let Some(todos) = todos_rx.recv().await { 21 + let todos: Vec<_> = todos.iter().filter(|todo| todo.is_today()).collect(); 22 + 23 + if let Some(todo) = todos.get(0) { 24 + let _ = lcd.set_cursor(0, 0); 25 + let _ = lcd.write_str(&todo.title); 26 + } 27 + 28 + if let Some(todo) = todos.get(1) { 29 + let _ = lcd.set_cursor(1, 0); 30 + let _ = lcd.write_str(&todo.title); 31 + } 32 + } 33 + } 34 + 35 + fn env() -> (String, String) { 5 36 dotenvy::dotenv().unwrap(); 6 37 7 38 let token = std::env::var("TASK_LINE_API_TOKEN") ··· 10 41 let server_url = std::env::var("TASK_LINE_SERVER_URL") 11 42 .expect("TASK_LINE_SERVER_URL environment variable not set"); 12 43 13 - let mut todos_rx = get_todos(server_url, token); 14 - 15 - while let Some(todos) = todos_rx.recv().await { 16 - let todos: Vec<_> = todos 17 - .iter() 18 - .filter(|todo| todo.time.is_some()) 19 - .filter(|todo| todo.is_today()) 20 - .collect(); 21 - 22 - for todo in todos { 23 - println!("{}", todo.title); 24 - } 25 - } 44 + (token, server_url) 26 45 }