Touch input device #27
8 changed files with 70 additions and 25 deletions
|
@ -13,6 +13,10 @@ embedded-graphics-simulator = "0.2.0"
|
|||
heapless = "0.5.5"
|
||||
cstr_core = { version = "0.2.0", features = ["alloc"] }
|
||||
|
||||
[[example]]
|
||||
name = "simple"
|
||||
path = "simple.rs"
|
||||
|
||||
[[example]]
|
||||
name = "demo"
|
||||
path = "demo.rs"
|
||||
|
|
|
@ -8,14 +8,11 @@ use lvgl::style::Style;
|
|||
use lvgl::widgets::{Arc, Label, LabelAlign};
|
||||
use lvgl::{self, Align, Color, Part, State, UI};
|
||||
use lvgl::{LvError, Widget};
|
||||
use lvgl_sys;
|
||||
use std::time::Instant;
|
||||
|
||||
fn main() -> Result<(), LvError> {
|
||||
let display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(
|
||||
lvgl_sys::LV_HOR_RES_MAX,
|
||||
lvgl_sys::LV_VER_RES_MAX,
|
||||
));
|
||||
let display: SimulatorDisplay<Rgb565> =
|
||||
SimulatorDisplay::new(Size::new(lvgl::HOR_RES_MAX, lvgl::VER_RES_MAX));
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||
let mut window = Window::new("Arc Example", &output_settings);
|
||||
|
|
|
@ -7,14 +7,11 @@ use embedded_graphics_simulator::{
|
|||
use lvgl::style::Style;
|
||||
use lvgl::widgets::{Bar, Label, LabelAlign};
|
||||
use lvgl::{self, Align, Animation, Color, Event, LvError, Part, State, Widget, UI};
|
||||
use lvgl_sys;
|
||||
use std::time::Instant;
|
||||
|
||||
fn main() -> Result<(), LvError> {
|
||||
let display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(
|
||||
lvgl_sys::LV_HOR_RES_MAX,
|
||||
lvgl_sys::LV_VER_RES_MAX,
|
||||
));
|
||||
let display: SimulatorDisplay<Rgb565> =
|
||||
SimulatorDisplay::new(Size::new(lvgl::HOR_RES_MAX, lvgl::VER_RES_MAX));
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||
let mut window = Window::new("Bar Example", &output_settings);
|
||||
|
|
|
@ -7,14 +7,11 @@ use embedded_graphics_simulator::{
|
|||
use lvgl::style::Style;
|
||||
use lvgl::widgets::{Btn, Label};
|
||||
use lvgl::{self, Align, Color, Event, LvError, Part, State, Widget, UI};
|
||||
use lvgl_sys;
|
||||
use std::time::Instant;
|
||||
|
||||
fn main() -> Result<(), LvError> {
|
||||
let display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(
|
||||
lvgl_sys::LV_HOR_RES_MAX,
|
||||
lvgl_sys::LV_VER_RES_MAX,
|
||||
));
|
||||
let display: SimulatorDisplay<Rgb565> =
|
||||
SimulatorDisplay::new(Size::new(lvgl::HOR_RES_MAX, lvgl::VER_RES_MAX));
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||
let mut window = Window::new("Bar Example", &output_settings);
|
||||
|
|
|
@ -13,10 +13,8 @@ use std::thread::sleep;
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
fn main() -> Result<(), LvError> {
|
||||
let display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(
|
||||
lvgl_sys::LV_HOR_RES_MAX,
|
||||
lvgl_sys::LV_VER_RES_MAX,
|
||||
));
|
||||
let display: SimulatorDisplay<Rgb565> =
|
||||
SimulatorDisplay::new(Size::new(lvgl::HOR_RES_MAX, lvgl::VER_RES_MAX));
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||
let mut window = Window::new("PineTime", &output_settings);
|
||||
|
|
|
@ -6,14 +6,11 @@ use embedded_graphics_simulator::{
|
|||
use lvgl::style::{Opacity, Style};
|
||||
use lvgl::widgets::Gauge;
|
||||
use lvgl::{self, Align, Color, LvError, Part, State, Widget, UI};
|
||||
use lvgl_sys;
|
||||
use std::time::Instant;
|
||||
|
||||
fn main() -> Result<(), LvError> {
|
||||
let display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(
|
||||
lvgl_sys::LV_HOR_RES_MAX,
|
||||
lvgl_sys::LV_VER_RES_MAX,
|
||||
));
|
||||
let display: SimulatorDisplay<Rgb565> =
|
||||
SimulatorDisplay::new(Size::new(lvgl::HOR_RES_MAX, lvgl::VER_RES_MAX));
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||
let mut window = Window::new("Gauge Example", &output_settings);
|
||||
|
@ -36,7 +33,7 @@ fn main() -> Result<(), LvError> {
|
|||
gauge_style.set_radius(State::DEFAULT, 5);
|
||||
gauge_style.set_bg_opa(State::DEFAULT, Opacity::OPA_COVER);
|
||||
gauge_style.set_bg_color(State::DEFAULT, Color::from_rgb((192, 192, 192)));
|
||||
// Set some paddings
|
||||
// Set some padding's
|
||||
gauge_style.set_pad_inner(State::DEFAULT, 20);
|
||||
gauge_style.set_pad_top(State::DEFAULT, 20);
|
||||
gauge_style.set_pad_left(State::DEFAULT, 5);
|
||||
|
|
52
examples/simple.rs
Normal file
52
examples/simple.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
use embedded_graphics::prelude::*;
|
||||
use embedded_graphics_simulator::{
|
||||
OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window,
|
||||
};
|
||||
use lvgl::widgets::Keyboard;
|
||||
use lvgl::LvError;
|
||||
use lvgl::UI;
|
||||
use std::time::Instant;
|
||||
|
||||
fn main() -> Result<(), LvError> {
|
||||
let display: SimulatorDisplay<Rgb565> =
|
||||
SimulatorDisplay::new(Size::new(lvgl::HOR_RES_MAX, lvgl::VER_RES_MAX));
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||
let mut window = Window::new("Simple Example", &output_settings);
|
||||
|
||||
// Initialize LVGL
|
||||
let mut ui = UI::init()?;
|
||||
|
||||
// Register your display
|
||||
ui.disp_drv_register(display)?;
|
||||
|
||||
// Get the active screen
|
||||
let mut screen = ui.scr_act()?;
|
||||
|
||||
// Create a Keyboard widget on the screen
|
||||
let _ = Keyboard::new(&mut screen)?;
|
||||
|
||||
let mut loop_started = Instant::now();
|
||||
'running: loop {
|
||||
// Tell LVGL to process UI related tasks
|
||||
ui.task_handler();
|
||||
|
||||
// Update your window with the latest display image
|
||||
window.update(ui.get_display_ref().unwrap());
|
||||
|
||||
for event in window.events() {
|
||||
match event {
|
||||
SimulatorEvent::Quit => break 'running,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// Tell LVGL how much time has past since last loop
|
||||
ui.tick_inc(loop_started.elapsed());
|
||||
|
||||
loop_started = Instant::now();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -13,3 +13,6 @@ pub mod widgets;
|
|||
pub use lv_core::*;
|
||||
pub use support::*;
|
||||
pub use ui::*;
|
||||
|
||||
pub const HOR_RES_MAX: u32 = lvgl_sys::LV_HOR_RES_MAX;
|
||||
pub const VER_RES_MAX: u32 = lvgl_sys::LV_VER_RES_MAX;
|
||||
|
|
Loading…
Reference in a new issue