Can i haz Structure?
This commit is contained in:
@@ -1,73 +1,40 @@
|
||||
// pub mod mouse;
|
||||
// mod os;
|
||||
mod app;
|
||||
|
||||
// use embedded_graphics::prelude::{Dimensions, DrawTarget};
|
||||
// use embedded_graphics::{pixelcolor::BinaryColor, prelude::Size};
|
||||
// use embedded_graphics_simulator::{OutputSettingsBuilder, SimulatorDisplay, Window};
|
||||
// use mlua::{Error, ExternalResult, Lua};
|
||||
// use rsact_ui::prelude::*;
|
||||
// use rsact_ui::{
|
||||
// col,
|
||||
// event::simulator::simulator_single_encoder,
|
||||
// render::{AntiAliasing, RendererOptions},
|
||||
// row,
|
||||
// style::accent::AccentStyler,
|
||||
// ui::UI,
|
||||
// };
|
||||
// use std::fmt::Binary;
|
||||
// use std::{
|
||||
// fs,
|
||||
// sync::{
|
||||
// Arc,
|
||||
// atomic::{AtomicBool, Ordering},
|
||||
// },
|
||||
// thread::sleep,
|
||||
// time::{Duration, Instant},
|
||||
// };
|
||||
|
||||
// use crate::os::G13Os;
|
||||
|
||||
use embedded_graphics::{
|
||||
Drawable,
|
||||
pixelcolor::BinaryColor,
|
||||
prelude::{DrawTarget, Point},
|
||||
use std::{
|
||||
thread::sleep,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use g13_driver::{G13, G13Event};
|
||||
|
||||
use embedded_graphics::pixelcolor::BinaryColor;
|
||||
use embedded_graphics::prelude::*;
|
||||
|
||||
use g13_driver::G13;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let g13 = G13::new()?;
|
||||
let (mut display, input) = g13.split();
|
||||
let mut g13 = G13::new()?;
|
||||
|
||||
let character_style = embedded_graphics::mono_font::MonoTextStyle::new(
|
||||
&embedded_graphics::mono_font::ascii::FONT_10X20,
|
||||
embedded_graphics::pixelcolor::BinaryColor::On,
|
||||
);
|
||||
let textstyle = embedded_graphics::text::TextStyleBuilder::new()
|
||||
.alignment(embedded_graphics::text::Alignment::Left)
|
||||
.baseline(embedded_graphics::text::Baseline::Top)
|
||||
.build();
|
||||
let mut app = App::new();
|
||||
|
||||
for event in input {
|
||||
let Some(event) = event else {
|
||||
continue;
|
||||
};
|
||||
let events = g13.events();
|
||||
|
||||
println!("{:?}", event);
|
||||
loop {
|
||||
let start = Instant::now();
|
||||
if let Ok(event) = events.try_recv() {
|
||||
app.update(event);
|
||||
}
|
||||
g13.clear(BinaryColor::Off)?;
|
||||
|
||||
display.clear(BinaryColor::Off)?;
|
||||
|
||||
if let G13Event::Axis(x, y) = event {
|
||||
embedded_graphics::text::Text::with_text_style(
|
||||
&format!("{}x{}", x, y),
|
||||
Point::new(5, 5),
|
||||
character_style,
|
||||
textstyle,
|
||||
)
|
||||
.draw(&mut display)?;
|
||||
if let Err(e) = app.draw(&mut g13) {
|
||||
eprintln!("{:?}", e);
|
||||
}
|
||||
|
||||
display.render()?;
|
||||
}
|
||||
g13.render()?;
|
||||
|
||||
Ok(())
|
||||
let elapsed = Instant::now() - start;
|
||||
if elapsed.as_millis() < 33 {
|
||||
sleep(Duration::from_millis(33) - (elapsed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user