Commit be5ad753 authored by TechnoElf's avatar TechnoElf
Browse files

Use new display

parent d6929db4
......@@ -162,6 +162,17 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "ili9341"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52897a923ee65051ae7da0f0b3d326c08d3b0998aa59346dc9a856e3f137c0a9"
dependencies = [
"display-interface",
"embedded-graphics-core",
"embedded-hal",
]
[[package]]
name = "json"
version = "0.12.4"
......@@ -176,6 +187,7 @@ dependencies = [
"display-interface-spi",
"embedded-graphics",
"embedded-layout",
"ili9341",
"json",
"rppal",
"st7789",
......
......@@ -7,6 +7,7 @@ edition = "2018"
json = "0.12.4"
rppal = { version = "0.12.0", features = ["hal"] }
st7789 = "0.6.1"
ili9341 = "0.5.0"
display-interface-spi = "0.4.1"
display-interface = "0.4.1"
embedded-graphics = "0.7.1"
......
......@@ -27,7 +27,8 @@ use rppal::hal::Delay;
use rppal::spi::{Spi, Bus, SlaveSelect, Mode};
use rppal::gpio::{Gpio, OutputPin};
use st7789::{ST7789, Orientation};
use st7789::ST7789;
use ili9341::Ili9341;
const GATEWAY: &str = "192.168.254.1:80";
......@@ -40,29 +41,29 @@ fn main() {
println!("{:?}", http_post(GATEWAY, "/", ""));
let spi_bus_0 = Spi::new(Bus::Spi0, SlaveSelect::Ss0, 5000000, Mode::Mode0).unwrap();
let spi_bus_1 = Spi::new(Bus::Spi0, SlaveSelect::Ss1, 5000000, Mode::Mode0).unwrap();
//let spi_bus_1 = Spi::new(Bus::Spi0, SlaveSelect::Ss1, 5000000, Mode::Mode0).unwrap();
let dc_0 = Gpio::new().unwrap().get(12).unwrap().into_output();
let dc_1: OutputPin = unsafe { mem::transmute_copy(&dc_0) };
//let dc_1: OutputPin = unsafe { mem::transmute_copy(&dc_0) };
let rst_0 = Gpio::new().unwrap().get(13).unwrap().into_output();
let rst_1: OutputPin = unsafe { mem::transmute_copy(&rst_0) };
//let rst_1: OutputPin = unsafe { mem::transmute_copy(&rst_0) };
let display_bus_0 = SPIInterfaceNoCS::new(spi_bus_0, dc_0);
let display_bus_1 = SPIInterfaceNoCS::new(spi_bus_1, dc_1);
//let display_bus_1 = SPIInterfaceNoCS::new(spi_bus_1, dc_1);
let mut display_0 = ST7789::new(display_bus_0, rst_0, 240, 240);
let mut display_1 = ST7789::new(display_bus_1, rst_1, 240, 240);
let mut display_0 = Ili9341::new(display_bus_0, rst_0, &mut Delay::new(), ili9341::Orientation::Landscape, ili9341::DisplaySize240x320).unwrap();
//let mut display_1 = ST7789::new(display_bus_1, rst_1, 240, 240);
display_0.init(&mut Delay::new()).unwrap();
display_1.init(&mut Delay::new()).unwrap();
display_0.set_orientation(Orientation::Portrait).unwrap();
display_1.set_orientation(Orientation::Portrait).unwrap();
//display_0.init(&mut Delay::new()).unwrap();
//display_1.init(&mut Delay::new()).unwrap();
//display_0.set_orientation(Orientation::Portrait).unwrap();
//display_1.set_orientation(Orientation::Portrait).unwrap();
display_0.clear(Rgb565::new(255, 255, 255)).unwrap();
display_1.clear(Rgb565::new(255, 255, 255)).unwrap();
//display_1.clear(Rgb565::new(255, 255, 255)).unwrap();
let mut state = State::default();
state.content.resize(4, (String::new(), (0, 0, 0)));
draw_screen(&mut display_0, &state.content[0].0, &state.content[0].1, &state.content[1].0, &state.content[1].1);
draw_screen(&mut display_1, &state.content[2].0, &state.content[2].1, &state.content[3].0, &state.content[3].1);
//draw_screen(&mut display_1, &state.content[2].0, &state.content[2].1, &state.content[3].0, &state.content[3].1);
eprintln!("Starting server...");
......@@ -85,7 +86,7 @@ fn main() {
stream.flush().unwrap();
draw_screen(&mut display_0, &state.content[0].0, &state.content[0].1, &state.content[1].0, &state.content[1].1);
draw_screen(&mut display_1, &state.content[2].0, &state.content[2].1, &state.content[3].0, &state.content[3].1);
//draw_screen(&mut display_1, &state.content[2].0, &state.content[2].1, &state.content[3].0, &state.content[3].1);
},
Err(r) => {
eprintln!("Invalid request: {} {}", method, uri);
......@@ -129,9 +130,9 @@ fn draw_screen<T: DrawTarget<Color = Rgb565, Error: Debug>>(disp: &mut T, text_0
LinearLayout::horizontal(Chain::new(
LinearLayout::vertical(
Chain::new(Rectangle::new(Point::zero(), Size::new(120, 1)).into_styled(PrimitiveStyle::with_fill(Rgb565::new(255, 255, 255)))).append(Circle::new(Point::zero(), 40).into_styled(PrimitiveStyle::with_fill(Rgb565::new(colour_0.0, colour_0.1, colour_0.2)))).append(Text::new(text_0, Point::zero(), style))
Chain::new(Rectangle::new(Point::zero(), Size::new(160, 1)).into_styled(PrimitiveStyle::with_fill(Rgb565::new(255, 255, 255)))).append(Circle::new(Point::zero(), 40).into_styled(PrimitiveStyle::with_fill(Rgb565::new(colour_0.0, colour_0.1, colour_0.2)))).append(Text::new(text_0, Point::zero(), style))
).with_alignment(horizontal::Center).arrange()).append(LinearLayout::vertical(
Chain::new(Rectangle::new(Point::zero(), Size::new(120, 1)).into_styled(PrimitiveStyle::with_fill(Rgb565::new(255, 255, 255)))).append(Circle::new(Point::zero(), 40).into_styled(PrimitiveStyle::with_fill(Rgb565::new(colour_1.0, colour_1.1, colour_1.2)))).append(Text::new(text_1, Point::zero(), style))
Chain::new(Rectangle::new(Point::zero(), Size::new(160, 1)).into_styled(PrimitiveStyle::with_fill(Rgb565::new(255, 255, 255)))).append(Circle::new(Point::zero(), 40).into_styled(PrimitiveStyle::with_fill(Rgb565::new(colour_1.0, colour_1.1, colour_1.2)))).append(Text::new(text_1, Point::zero(), style))
).with_alignment(horizontal::Center).arrange()
)).with_alignment(vertical::Center).arrange().align_to(&disp.bounding_box(), horizontal::Center, vertical::Center).draw(disp).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