Skip to content

Commit

Permalink
app: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JerwuQu committed Oct 9, 2024
1 parent f8338a3 commit fdb6924
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ members = [
"ggoled_lib",
"ggoled_app",
"ggoled_draw",
]
]

[profile.release]
strip = true
lto = true
4 changes: 0 additions & 4 deletions ggoled_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ ggoled_draw = { path = "../ggoled_draw" }
chrono = "0.4.38"
windows = { version = "0.58.0", features = ["Media_Control"] }
anyhow = "1.0.89"

[profile.release]
strip = true
lto = true
10 changes: 7 additions & 3 deletions ggoled_app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![windows_subsystem = "windows"]

use chrono::{Local, TimeDelta};
use chrono::{Local, TimeDelta, Timelike};
use ggoled_draw::{DrawDevice, LayerId};
use ggoled_lib::Device;
use media::{Media, MediaControl};
Expand Down Expand Up @@ -53,7 +53,7 @@ fn main() {

// Update time every second
let time = Local::now();
if time - last_time >= TimeDelta::seconds(1) {
if time.second() != last_time.second() {
let time_str = time.format("%H:%M:%S").to_string();
let media = mgr.get_media();

Expand All @@ -66,7 +66,11 @@ fn main() {
if media != last_media {
dev.remove_layers(&media_layers);
if let Some(m) = &media {
media_layers = dev.add_text(&format!("{}\n{}", m.title, m.artist), None, Some(24));
media_layers = dev.add_text(
&format!("{}\n{}", m.title, m.artist),
None,
Some(8 + dev.font_line_height() as isize),
);
} else {
media_layers = vec![]
}
Expand Down
4 changes: 0 additions & 4 deletions ggoled_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ clap = { version = "4.4.10", features = ["derive"] }
ggoled_lib = { path = "../ggoled_lib" }
ggoled_draw = { path = "../ggoled_draw" }
spin_sleep = "1.2.1"

[profile.release]
strip = true
lto = true
3 changes: 3 additions & 0 deletions ggoled_draw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ impl DrawDevice {
pub fn clear_layers(&mut self) {
self.layers.lock().unwrap().clear();
}
pub fn font_line_height(&self) -> usize {
self.texter.line_height()
}
pub fn add_text(&mut self, text: &str, x: Option<isize>, y: Option<isize>) -> Vec<LayerId> {
let layers = self.layers.clone();
let mut layers = layers.lock().unwrap();
Expand Down

0 comments on commit fdb6924

Please sign in to comment.