Commit 9d3e182f authored by TechnoElf's avatar TechnoElf
Browse files

Set text over network

parent d2a1474e
/target
*.swp
.direnv
use std::net::{TcpListener};
use std::io::Read;
use rppal::hal::Delay;
use rppal::spi::{Spi, Bus, SlaveSelect, Mode};
use rppal::gpio::Gpio;
......@@ -6,9 +9,9 @@ use display_interface_spi::SPIInterfaceNoCS;
use embedded_graphics::prelude::*;
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::draw_target::DrawTarget;
use embedded_graphics::mono_font::ascii::FONT_6X13;
use embedded_graphics::mono_font::ascii::FONT_9X18_BOLD;
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::text::Text;
use embedded_graphics::text::{Text, Alignment};
fn main() {
let spi_bus = Spi::new(Bus::Spi0, SlaveSelect::Ss0, 5000000, Mode::Mode0).unwrap();
......@@ -22,8 +25,18 @@ fn main() {
display.init(&mut Delay::new()).unwrap();
display.set_orientation(Orientation::Landscape).unwrap();
let style = MonoTextStyle::new(&FONT_9X18_BOLD, Rgb565::new(0, 0, 0));
display.clear(Rgb565::new(255, 255, 255)).unwrap();
Text::with_alignment("Release the Kraken!", Point::new(120, 120), style, Alignment::Center).draw(&mut display).unwrap();
let style = MonoTextStyle::new(&FONT_6X13, Rgb565::new(0, 0, 0));
Text::new("Release the Kraken!", Point::new(0, 0), style).draw(&mut display).unwrap();
let listener = TcpListener::bind("0.0.0.0:8080").unwrap();
for stream in listener.incoming() {
if let Ok(mut stream) = stream {
let mut text = String::new();
stream.read_to_string(&mut text).unwrap();
display.clear(Rgb565::new(255, 255, 255)).unwrap();
Text::with_alignment(&text, Point::new(120, 20), style, Alignment::Center).draw(&mut display).unwrap();
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment