-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move screen drivers into Drivers crate and refactor graphics and screen
- Loading branch information
1 parent
515d0c6
commit 3561eb2
Showing
20 changed files
with
266 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#![allow(non_snake_case)] | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_upper_case_globals)] | ||
|
||
use std::{ | ||
thread::sleep, | ||
time::{Duration, Instant}, | ||
}; | ||
use File_system::{File_type, Mode_type, Path_type}; | ||
|
||
const Pointer_device_path: &Path_type = | ||
unsafe { Path_type::New_unchecked_constant("/Device/Pointer") }; | ||
|
||
#[cfg(target_os = "linux")] | ||
#[test] | ||
#[ignore] | ||
fn main() { | ||
use Drivers::Native::New_touchscreen; | ||
use Screen::Point_type; | ||
|
||
use Graphics::lvgl::{self, Widget}; | ||
|
||
const Horizontal_resolution: u32 = 800; | ||
const Vertical_resolution: u32 = 480; | ||
const Buffer_size: usize = (Horizontal_resolution * Vertical_resolution / 2) as usize; | ||
|
||
let (S, Pointer) = New_touchscreen(Point_type::New( | ||
Horizontal_resolution as i16, | ||
Vertical_resolution as i16, | ||
)) | ||
.expect("Error creating touchscreen"); | ||
|
||
let S = Box::new(S); | ||
|
||
Users::Initialize().expect("Error initializing users manager"); | ||
|
||
Task::Initialize().expect("Error initializing task manager"); | ||
|
||
let Virtual_file_system = File_system::Initialize().expect("Error initializing file system"); | ||
|
||
Virtual_file_system | ||
.Add_device(&Pointer_device_path, Box::new(Pointer)) | ||
.expect("Error adding pointer device"); | ||
|
||
let Pointer_file = File_type::Open( | ||
Virtual_file_system, | ||
Pointer_device_path, | ||
Mode_type::Read_only().into(), | ||
) | ||
.expect("Error opening pointer file"); | ||
|
||
Graphics::Initialize().expect("Error initializing manager"); | ||
|
||
let Graphics_manager = Graphics::Get_instance().expect("Error getting manager"); | ||
|
||
let Resolution = S.Get_resolution().expect("Error getting resolution"); | ||
|
||
let Display = Graphics_manager | ||
.Create_display::<Buffer_size>(S, Resolution, Pointer_file) | ||
.expect("Error adding screen"); | ||
|
||
let mut S = Display.Get_object().expect("Error getting screen"); | ||
|
||
let _ = lvgl::widgets::Slider::create(&mut S); | ||
|
||
let Calendar = lvgl::widgets::Calendar::create(&mut S); | ||
assert!(Calendar.is_ok()); | ||
let mut Calendar = Calendar.unwrap(); | ||
|
||
let mut Style = lvgl::style::Style::default(); | ||
Style.set_bg_color(lvgl::Color::from_rgb((255, 0, 0))); | ||
|
||
Calendar.add_style(lvgl::obj::Part::Any, &mut Style); | ||
Calendar.set_align(lvgl::Align::Center, 0, 0); | ||
|
||
loop { | ||
let Start = Instant::now(); | ||
lvgl::task_handler(); | ||
sleep(Duration::from_millis(5)); | ||
lvgl::tick_inc(Instant::now().duration_since(Start)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#![allow(non_snake_case)] | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_upper_case_globals)] | ||
|
||
use Drivers::Native::New_touchscreen; | ||
use File_system::Device_trait; | ||
use Screen::{Area_type, Color_ARGB8888_type, Error_type, Point_type, Screen_traits}; | ||
|
||
#[test] | ||
#[cfg(target_os = "linux")] | ||
fn Test_touchscreen() { | ||
const Horizontal_resolution: u32 = 800; | ||
const Vertical_resolution: u32 = 480; | ||
|
||
let Touchscreen = New_touchscreen(Point_type::New( | ||
Horizontal_resolution as i16, | ||
Vertical_resolution as i16, | ||
)); | ||
|
||
assert!(Touchscreen.is_ok()); | ||
|
||
let (mut Screen, Pointer_device_type) = | ||
Touchscreen.expect("Touchscreen initialization failed."); | ||
|
||
let mut Buffer = [0; 5]; | ||
|
||
assert_eq!(Pointer_device_type.Read(&mut Buffer), Ok(5)); | ||
|
||
Screen | ||
.Update( | ||
Area_type::New(Point_type::New(0, 0), Point_type::New(9, 9)), | ||
&[Color_ARGB8888_type::New(255, 255, 255, 255); 100], | ||
) | ||
.expect("Screen update failed."); | ||
|
||
assert_eq!( | ||
Screen.Update( | ||
Area_type::New(Point_type::New(0, 0), Point_type::New(10, 9),), | ||
&[Color_ARGB8888_type::New(255, 255, 255, 255); 100], | ||
), | ||
Err(Error_type::Invalid_dimension) | ||
); | ||
|
||
assert_eq!(Screen.Get_resolution().unwrap(), Point_type::New(800, 480)); | ||
|
||
unsafe { | ||
sdl2::sys::SDL_Quit(); // Force SDL2 to quit to avoid conflicts with other tests. | ||
} | ||
} |
Oops, something went wrong.