mirror of
https://github.com/FliegendeWurst/raspi-oled.git
synced 2024-11-09 13:40:36 +00:00
Status display + date display for future events
This commit is contained in:
parent
892ed459b6
commit
b856677b7f
@ -8,8 +8,9 @@ https://www.waveshare.com/wiki/1.5inch_RGB_OLED_Module
|
|||||||
> nix-shell
|
> nix-shell
|
||||||
> rustup target add arm-unknown-linux-musleabihf
|
> rustup target add arm-unknown-linux-musleabihf
|
||||||
> cargo build --release --target arm-unknown-linux-musleabihf
|
> cargo build --release --target arm-unknown-linux-musleabihf
|
||||||
> scp target/arm-unknown-linux-musleabihf/release/{display_all,display_off,refresh_json,take_measurement} 'pi@raspberrypi:~'
|
> scp target/arm-unknown-linux-musleabihf/release/{display_all,display_off,refresh_json,take_measurement,status_check_example} 'pi@raspberrypi:~'
|
||||||
> # on the Pi, create sensors.db and events.json
|
> # on the Pi, create sensors.db and events.json
|
||||||
|
> ./status_check_example > /run/user/1000/status.json
|
||||||
> patchelf --set-interpreter /lib/ld-linux-armhf.so.3 display_all
|
> patchelf --set-interpreter /lib/ld-linux-armhf.so.3 display_all
|
||||||
> ./display_off on
|
> ./display_off on
|
||||||
> ./display_all sensors.db events.json temps
|
> ./display_all sensors.db events.json temps
|
||||||
|
@ -4,7 +4,7 @@ use display_interface_spi::SPIInterfaceNoCS;
|
|||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
draw_target::DrawTarget,
|
draw_target::DrawTarget,
|
||||||
mono_font::{
|
mono_font::{
|
||||||
ascii::{FONT_10X20, FONT_5X8, FONT_6X9, FONT_9X15},
|
ascii::{FONT_10X20, FONT_4X6, FONT_5X8, FONT_6X9, FONT_9X15},
|
||||||
MonoTextStyleBuilder,
|
MonoTextStyleBuilder,
|
||||||
},
|
},
|
||||||
pixelcolor::{Rgb565},
|
pixelcolor::{Rgb565},
|
||||||
@ -21,7 +21,7 @@ use rppal::{
|
|||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
//use ssd1306::{I2CDisplayInterface, Ssd1306, size::DisplaySize128x64, rotation::DisplayRotation, mode::DisplayConfig};
|
//use ssd1306::{I2CDisplayInterface, Ssd1306, size::DisplaySize128x64, rotation::DisplayRotation, mode::DisplayConfig};
|
||||||
use time::{format_description, OffsetDateTime, PrimitiveDateTime};
|
use time::{format_description, OffsetDateTime, PrimitiveDateTime, Date};
|
||||||
use time_tz::{timezones::db::europe::BERLIN, OffsetDateTimeExt, PrimitiveDateTimeExt};
|
use time_tz::{timezones::db::europe::BERLIN, OffsetDateTimeExt, PrimitiveDateTimeExt};
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@ -157,6 +157,10 @@ fn draw<D: DrawTarget<Color = Rgb565>>(mut disp: D, time: OffsetDateTime, rh: i6
|
|||||||
.font(&FONT_6X9)
|
.font(&FONT_6X9)
|
||||||
.text_color(Rgb565::new(0xff, 0xff, 0xff))
|
.text_color(Rgb565::new(0xff, 0xff, 0xff))
|
||||||
.build();
|
.build();
|
||||||
|
let mut text_style_4x6 = MonoTextStyleBuilder::new()
|
||||||
|
.font(&FONT_4X6)
|
||||||
|
.text_color(Rgb565::new(0xff, 0xff, 0xff))
|
||||||
|
.build();
|
||||||
let text_style4 = MonoTextStyleBuilder::new()
|
let text_style4 = MonoTextStyleBuilder::new()
|
||||||
.font(&FONT_5X8)
|
.font(&FONT_5X8)
|
||||||
.text_color(Rgb565::new(0xff, 0xff, 0xff))
|
.text_color(Rgb565::new(0xff, 0xff, 0xff))
|
||||||
@ -359,13 +363,20 @@ fn draw<D: DrawTarget<Color = Rgb565>>(mut disp: D, time: OffsetDateTime, rh: i6
|
|||||||
let text = if event.4.len() > 19 { &event.4[0..19] } else { &event.4 };
|
let text = if event.4.len() > 19 { &event.4[0..19] } else { &event.4 };
|
||||||
let day = event.0 as usize;
|
let day = event.0 as usize;
|
||||||
let y = y + 64 + 9 * i as i32 + 5;
|
let y = y + 64 + 9 * i as i32 + 5;
|
||||||
text_style_6x9.set_text_color(Some(Rgb565::new(0xff, 0xff, 0xff)));
|
if event.5 > today && event.5 - today > 7 {
|
||||||
Text::new(days[day].0, (x, y).into(), text_style_6x9)
|
let dt = Date::from_julian_day(event.5).unwrap();
|
||||||
.draw(&mut disp)
|
Text::new(&format!("{}.{}.", dt.day(), dt.month() as u8), (0, y).into(), text_style_4x6)
|
||||||
.unwrap();
|
.draw(&mut disp)
|
||||||
Text::new(days[day].1, (x + 6, y).into(), text_style4)
|
.unwrap();
|
||||||
.draw(&mut disp)
|
} else {
|
||||||
.unwrap();
|
text_style_6x9.set_text_color(Some(Rgb565::new(0xff, 0xff, 0xff)));
|
||||||
|
Text::new(days[day].0, (x, y).into(), text_style_6x9)
|
||||||
|
.draw(&mut disp)
|
||||||
|
.unwrap();
|
||||||
|
Text::new(days[day].1, (x + 6, y).into(), text_style4)
|
||||||
|
.draw(&mut disp)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
text_style_6x9.set_text_color(Some(colors[i]));
|
text_style_6x9.set_text_color(Some(colors[i]));
|
||||||
Text::new(text, (x + 14, y).into(), text_style_6x9)
|
Text::new(text, (x + 14, y).into(), text_style_6x9)
|
||||||
.draw(&mut disp)
|
.draw(&mut disp)
|
||||||
|
11
src/bin/status_check_example.rs
Normal file
11
src/bin/status_check_example.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// adjust as needed
|
||||||
|
|
||||||
|
let github_up = Command::new("ping").args(["-c1", "github.com"]).spawn().unwrap().wait().unwrap().success();
|
||||||
|
let gitlab_up = Command::new("ping").args(["-c1", "gitlab.com"]).spawn().unwrap().wait().unwrap().success();
|
||||||
|
|
||||||
|
let status = format!("{} {} {} {} {}", true, github_up, true, gitlab_up, true);
|
||||||
|
std::fs::write("/run/user/1000/status.json", status).unwrap();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user