Reworked display code
This commit is contained in:
parent
639ee2af7f
commit
bc3c25a5d3
2 changed files with 214 additions and 117 deletions
|
|
@ -5,10 +5,7 @@ use core::panic::PanicInfo;
|
|||
|
||||
use cardputer_bsc_nostd::display::{DISPLAY_SIZE_HEIGHT, DISPLAY_SIZE_WIDTH};
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
use esp_hal::{
|
||||
ledc::{LowSpeed, channel::ChannelIFace, timer::TimerIFace},
|
||||
main,
|
||||
};
|
||||
use esp_hal::main;
|
||||
use esp_println::println;
|
||||
|
||||
#[panic_handler]
|
||||
|
|
@ -28,39 +25,24 @@ fn entrypoint() -> ! {
|
|||
|
||||
fn _main() {
|
||||
let peripherals = esp_hal::init(esp_hal::Config::default());
|
||||
let mut display = cardputer_bsc_nostd::display::build(
|
||||
|
||||
cardputer_bsc_nostd::setup_backlight! {
|
||||
let (mut ledc, mut timer) = setup_backlight(peripherals.LEDC);
|
||||
}
|
||||
|
||||
let mut display = cardputer_bsc_nostd::display::Display::new(
|
||||
peripherals.SPI2,
|
||||
peripherals.GPIO36,
|
||||
peripherals.GPIO35,
|
||||
peripherals.GPIO37,
|
||||
peripherals.GPIO34,
|
||||
peripherals.GPIO33,
|
||||
&ledc,
|
||||
&timer,
|
||||
peripherals.GPIO38,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut ledc = esp_hal::ledc::Ledc::new(peripherals.LEDC);
|
||||
ledc.set_global_slow_clock(esp_hal::ledc::LSGlobalClkSource::APBClk);
|
||||
|
||||
let mut timer = ledc.timer::<LowSpeed>(esp_hal::ledc::timer::Number::Timer3);
|
||||
timer.configure(esp_hal::ledc::timer::config::Config {
|
||||
duty: esp_hal::ledc::timer::config::Duty::Duty8Bit,
|
||||
clock_source: esp_hal::ledc::timer::LSClockSource::APBClk,
|
||||
frequency: esp_hal::time::Rate::from_hz(256),
|
||||
}).unwrap();
|
||||
|
||||
let mut backlight: esp_hal::ledc::channel::Channel<'_, _> =
|
||||
ledc.channel(esp_hal::ledc::channel::Number::Channel7, peripherals.GPIO38);
|
||||
|
||||
backlight
|
||||
.configure(esp_hal::ledc::channel::config::Config {
|
||||
timer: &timer,
|
||||
duty_pct: 100,
|
||||
pin_config: esp_hal::ledc::channel::config::PinConfig::PushPull,
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
||||
|
||||
display
|
||||
.set_pixels(
|
||||
0,
|
||||
|
|
@ -86,4 +68,6 @@ fn _main() {
|
|||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
display.set_backlight_brightness(100).unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue