Skip to content

Commit

Permalink
cleanup #1
Browse files Browse the repository at this point in the history
  • Loading branch information
enelson1001 committed Dec 4, 2023
1 parent aa7c6f9 commit cee1fce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 94 deletions.
11 changes: 6 additions & 5 deletions src/lcd_panel.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
//! This code was produced from the work done by this person [this repo](https://github.com/anlumo/ESP32-8048S070-Rust/tree/main)
//! He did all the heavy lifting I just expanded on his work.
//! The default configuration and timings are based upon the Aliexpress Esp32S-8048S070C development board.
use esp_idf_hal::sys::EspError;
use esp_idf_sys::*;

use std::ptr::null_mut;

use core::cell::UnsafeCell;

use esp_idf_hal::sys::EspError;

use esp_idf_sys::{
self,
esp_lcd_new_rgb_panel,
Expand All @@ -25,6 +23,9 @@ use esp_idf_sys::{
soc_periph_lcd_clk_src_t_LCD_CLK_SRC_PLL160M,
};

use crate::lcd_panel::esp_idf_sys::esp;
use crate::lcd_panel::esp_idf_sys::soc_periph_lcd_clk_src_t;

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct PanelConfig {
pub clk_src: soc_periph_lcd_clk_src_t,
Expand Down Expand Up @@ -385,7 +386,7 @@ impl LcdPanel {

let panel_config = esp_lcd_rgb_panel_config_t {
clk_src: panel_config.clk_src,
timings: timings,
timings,
data_width: panel_config.data_width,
bits_per_pixel: panel_config.bits_per_pixel,
num_fbs: panel_config.num_fbs,
Expand Down
89 changes: 0 additions & 89 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use esp_idf_hal::ledc::{
{LedcDriver, LedcTimerDriver},
};

use lvgl;
use lvgl::font::Font;
use lvgl::style::Style;
use lvgl::widgets::Label;
Expand Down Expand Up @@ -127,92 +126,4 @@ fn main() {

lvgl::tick_inc(Instant::now().duration_since(start));
}

/*
// This is an example of running Lvgl in its own thread. You can reduce the mian task stack size in
// sdconfig.defaults back to 8000.
// Stack size value - 50,000 for 10 lines
let _lvgl_thread = thread::Builder::new()
.stack_size(50000)
.spawn(|| {
lvgl::init();
//============================================================================================================
// Create driver for the LCD Panel
//============================================================================================================
let mut lcd_panel = LcdPanel::new(
&PanelConfig::new(),
&PanelFlagsConfig::new(),
&TimingsConfig::new(),
&TimingFlagsConfig::new(),
)
.unwrap();
info!("============= Registering Display ====================");
let buffer = DrawBuffer::<{ (HOR_RES * LINES) as usize }>::default();
let display = Display::register(buffer, HOR_RES, VER_RES, |refresh| {
lcd_panel
.set_pixels_lvgl_color(
refresh.area.x1.into(),
refresh.area.y1.into(),
(refresh.area.x2 + 1i16).into(),
(refresh.area.y2 + 1i16).into(),
refresh.colors.into_iter(),
)
.unwrap();
})
.unwrap();
//===========================================================================================================
// Create the User Interface
//===========================================================================================================
// Create screen and widgets
let mut screen = display.get_scr_act().unwrap();
let mut screen_style = Style::default();
screen_style.set_bg_color(Color::from_rgb((0, 0, 255)));
screen_style.set_radius(0);
screen.add_style(Part::Main, &mut screen_style);
let mut time = Label::new().unwrap();
let mut style_time = Style::default();
style_time.set_text_color(Color::from_rgb((255, 255, 255))); // white
style_time.set_text_align(TextAlign::Center);
// Custom font requires lvgl-sys in Cargo.toml and 'use lvgl_sys' in this file
style_time.set_text_font(unsafe { Font::new_raw(lvgl_sys::gotham_bold_80) });
time.add_style(Part::Main, &mut style_time);
// Time text will be centered in screen
time.set_align(Align::Center, 0, 0);
let mut i = 0;
loop {
let start = Instant::now();
if i > 59 {
i = 0;
}
let val = CString::new(format!("21:{:02}", i)).unwrap();
time.set_text(&val).unwrap();
i = 1 + i;
lvgl::task_handler();
// Simulate clock - so sleep for one second so time text is incremented in seconds
delay::FreeRtos::delay_ms(1000);
lvgl::tick_inc(Instant::now().duration_since(start));
}
})
.unwrap();
loop {
// Don't exit application
delay::FreeRtos::delay_ms(1000);
}
*/
}

0 comments on commit cee1fce

Please sign in to comment.