Skip to content

Commit

Permalink
获取不到数据时不更新文本
Browse files Browse the repository at this point in the history
  • Loading branch information
planet0104 committed Jul 20, 2024
1 parent cd2d387 commit c77643b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "USB-Screen"
version = "1.1.3"
version = "1.1.4"
edition = "2021"

[features]
Expand Down
12 changes: 7 additions & 5 deletions build-x86_64_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
# default = ["editor", "v4l-webcam", usb-serial]
#
# cargo install cross --git https://github.com/cross-rs/cross
# cross build --target x86_64-unknown-linux-musl --release
# cross build --target x86_64-unknown-linux-gnu --release
bash
cargo build --target x86_64-unknown-linux-gnu --release

# https://github.com/johnthagen/min-sized-rust
# rustup component add rust-src --toolchain nightly
RUSTFLAGS="-Zlocation-detail=none" cross +nightly build -Z build-std=std,panic_abort \
-Z build-std-features=panic_immediate_abort \
-Z build-std-features="optimize_for_size" \
--target x86_64-unknown-linux-gnu --release
# RUSTFLAGS="-Zlocation-detail=none" cross +nightly build -Z build-std=std,panic_abort \
# -Z build-std-features=panic_immediate_abort \
# -Z build-std-features="optimize_for_size" \
# --target x86_64-unknown-linux-gnu --release
4 changes: 2 additions & 2 deletions src/usb_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ impl UsbScreen{
match self{
UsbScreen::USBRaw((info, interface)) => {
if img.width() <= info.width as u32 && img.height() <= info.height as u32{
let _ = draw_rgb_image(x, y, img, interface);
draw_rgb_image(x, y, img, interface)?;
}
}

#[cfg(feature = "usb-serial")]
UsbScreen::USBSerial((info, port)) => {
if img.width() <= info.width as u32 && img.height() <= info.height as u32{
let _ = draw_rgb_image_serial(x, y, img, port.as_mut());
draw_rgb_image_serial(x, y, img, port.as_mut())?;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl Widget for TextWidget {
"lunar_year" => Some(monitor::lunar_year()),
"lunar_date" => Some(monitor::lunar_date()),
"weather" => match monitor::weather_info() {
None => Some(self.text.to_string()),
None => Some(monitor::EMPTY_STRING.to_string()),
Some(w) => {
match self.tag1.as_str() {
"1" => Some(format!("{}", w.station.city)), //城市
Expand Down Expand Up @@ -299,7 +299,7 @@ impl Widget for TextWidget {
"transmitted_speed" => monitor::network_speed_per_sec().map(|(_r, t)| t),
_ => None,
} {
if self.text != text {
if self.text != text && text != monitor::EMPTY_STRING {
self.text = text;
}
}
Expand Down

0 comments on commit c77643b

Please sign in to comment.