mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-19 02:20:12 +01:00
updated example
This commit is contained in:
parent
3a90627853
commit
42a1654e0e
8
send_text/Cargo.lock
generated
8
send_text/Cargo.lock
generated
|
@ -6,8 +6,6 @@ version = 3
|
||||||
name = "airportdisplay"
|
name = "airportdisplay"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"bytes",
|
|
||||||
"codepage-437",
|
"codepage-437",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -29,12 +27,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bytes"
|
|
||||||
version = "1.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codepage-437"
|
name = "codepage-437"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
1
send_text/rustfmt.toml
Normal file
1
send_text/rustfmt.toml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
max_width = 80
|
|
@ -1,32 +1,23 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use airportdisplay::{
|
use airportdisplay::{text::Buffer, Command, Display};
|
||||||
Display,
|
|
||||||
Command,
|
|
||||||
Text,
|
|
||||||
TextBuffer,
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
/// Send text read from stdio to the display
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
// Read stdin into buffer
|
||||||
// Read buffer
|
let mut text = String::new();
|
||||||
let mut buffer = String::new();
|
|
||||||
for line in io::stdin().lines() {
|
for line in io::stdin().lines() {
|
||||||
if let Ok(line) = line {
|
text.push_str(line?.as_str());
|
||||||
buffer.push_str(line.as_str());
|
text.push('\n');
|
||||||
buffer.push('\n');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send content to display
|
||||||
let display = Display::open("172.23.42.29:2342".into())?;
|
let display = Display::open("172.23.42.29:2342".into())?;
|
||||||
let cmd = Command::Text(Text::Buffer(TextBuffer::from(buffer)));
|
|
||||||
|
|
||||||
display.send(Command::Clear)?;
|
display.send(Command::Clear)?;
|
||||||
display.send(cmd)?;
|
display.send(Buffer::from(text).into())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue