Somewhat working version
This commit is contained in:
31
src/main.rs
31
src/main.rs
@@ -3,10 +3,7 @@ extern crate arrayref;
|
||||
use std::error::Error;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use rppal::gpio::Gpio;
|
||||
use rppal::spi::{Bus, Mode, Segment, SlaveSelect, Spi};
|
||||
use rppal::system::DeviceInfo;
|
||||
use std::f32::consts::PI;
|
||||
|
||||
|
||||
use image::{
|
||||
@@ -17,25 +14,35 @@ use imageproc::rect::Rect;
|
||||
use imageproc::drawing::draw_filled_rect_mut;
|
||||
|
||||
mod ilidisplay;
|
||||
mod forms;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
let mut screen = forms::Screen::new(200, 200);
|
||||
let c = forms::load_compass_rose();
|
||||
let b = forms::load_boat();
|
||||
|
||||
/*
|
||||
let mut img = RgbImage::new(480, 320);
|
||||
let thickness = 10;
|
||||
draw_filled_rect_mut(&mut img, Rect::at(0,0).of_size(240, 160), Rgb([255,0,0]));
|
||||
draw_filled_rect_mut(&mut img, Rect::at(0,160).of_size(240, 160), Rgb([255,0,0]));
|
||||
draw_filled_rect_mut(&mut img, Rect::at(0,160).of_size(240, 160), Rgb([0, 255, 0]));
|
||||
draw_filled_rect_mut(&mut img, Rect::at(240,0).of_size(240, 160), Rgb([0, 0, 255]));
|
||||
*/
|
||||
|
||||
let mut e = ilidisplay::IliDisplay::init()?;
|
||||
println!("Before init, sleeping for 5s");
|
||||
thread::sleep(Duration::from_millis(5000));
|
||||
e.init_chip();
|
||||
println!("After init, sleeping for 5s");
|
||||
thread::sleep(Duration::from_millis(5000));
|
||||
e.turn_on();
|
||||
println!("Before image, screen has now been reset and turned on, sleeping for 5s");
|
||||
thread::sleep(Duration::from_millis(5000));
|
||||
e.send_image(img);
|
||||
for i in 0..100 {
|
||||
let rad = (i as f32) * 2.0*PI / 100.0;
|
||||
screen.clear();
|
||||
screen.render(&c, rad, 500, 500);
|
||||
screen.render(&b, 0.0, 500, 500);
|
||||
e.put_image(&(screen.image), ((240-100), (160-100)));
|
||||
}
|
||||
|
||||
// draw_filled_rect_mut(&mut img, Rect::at(0,0).of_size(480, 320), Rgb([0, 0, 0]));
|
||||
|
||||
println!("You should see image now, sleeping for 5s");
|
||||
thread::sleep(Duration::from_millis(5000));
|
||||
e.turn_off();
|
||||
|
||||
Reference in New Issue
Block a user