diff --git a/.gitignore b/.gitignore index 5f67ac0..af94599 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swo *.swp +target/ diff --git a/hello_display/Cargo.lock b/hello_display/Cargo.lock index 70b9092..cefe8dd 100644 --- a/hello_display/Cargo.lock +++ b/hello_display/Cargo.lock @@ -6,7 +6,9 @@ version = 3 name = "airportdisplay" version = "0.1.0" dependencies = [ + "anyhow", "bytes", + "codepage-437", ] [[package]] @@ -15,12 +17,55 @@ version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + [[package]] name = "bytes" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +[[package]] +name = "codepage-437" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e40c1169585d8d08e5675a39f2fc056cd19a258fc4cba5e3bbf4a9c1026de535" +dependencies = [ + "csv", +] + +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + [[package]] name = "hello_display" version = "0.1.0" @@ -28,3 +73,39 @@ dependencies = [ "airportdisplay", "anyhow", ] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "serde" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" diff --git a/hello_display/src/main.rs b/hello_display/src/main.rs index 04bff4d..f4242c7 100644 --- a/hello_display/src/main.rs +++ b/hello_display/src/main.rs @@ -1,16 +1,21 @@ use anyhow::Result; - -use std::net::UdpSocket; +use airportdisplay::{ + Command, + Display, + Text, + TextBuffer, +}; fn main() -> Result<()> { println!("Sending hello display..."); + let display = Display::open("172.23.42.29:2342".into())?; - let socket = UdpSocket::bind("0.0.0.0:17382")?; + let text = Command::Text(Text::Buffer( + TextBuffer::from( + "♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥\n♥ mauuu ♥\n♥ mau mauuuunz! ♥\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥".into()))); - - for frame in frames { - socket.send_to(frame, " - } + display.send(Command::Clear)?; + display.send(text)?; Ok(()) } diff --git a/send_text/Cargo.lock b/send_text/Cargo.lock new file mode 100644 index 0000000..533c889 --- /dev/null +++ b/send_text/Cargo.lock @@ -0,0 +1,111 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "airportdisplay" +version = "0.1.0" +dependencies = [ + "anyhow", + "bytes", + "codepage-437", +] + +[[package]] +name = "anyhow" +version = "1.0.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "codepage-437" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e40c1169585d8d08e5675a39f2fc056cd19a258fc4cba5e3bbf4a9c1026de535" +dependencies = [ + "csv", +] + +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "send_text" +version = "0.1.0" +dependencies = [ + "airportdisplay", + "anyhow", +] + +[[package]] +name = "serde" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" diff --git a/send_text/Cargo.toml b/send_text/Cargo.toml new file mode 100644 index 0000000..f2ec42e --- /dev/null +++ b/send_text/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "send_text" +version = "0.1.0" +edition = "2021" + +[dependencies] +anyhow = "1" + +airportdisplay = { path = "../airportdisplay" } diff --git a/send_text/src/main.rs b/send_text/src/main.rs new file mode 100644 index 0000000..0149c52 --- /dev/null +++ b/send_text/src/main.rs @@ -0,0 +1,32 @@ + +use anyhow::Result; + +use airportdisplay::{ + Display, + Command, + Text, + TextBuffer, +}; + +use std::io; + +fn main() -> Result<()> { + + // Read buffer + let mut buffer = String::new(); + for line in io::stdin().lines() { + if let Ok(line) = line { + buffer.push_str(line.as_str()); + buffer.push('\n'); + } + } + + 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(cmd)?; + + Ok(()) +} +