mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-21 07:41:51 +00:00
pico2_st7789: Turn on backlight after first frame is drawn #9413
43ede0b1c3
(#7482) was for pico
This commit is contained in:
parent
9a882dd17f
commit
30e52ffa9a
1 changed files with 9 additions and 3 deletions
|
@ -128,7 +128,7 @@ pub fn init() {
|
|||
});
|
||||
|
||||
let rst = pins.gpio15.into_push_pull_output();
|
||||
let mut backlight = pins.gpio13.into_push_pull_output();
|
||||
let backlight = pins.gpio13.into_push_pull_output();
|
||||
|
||||
let dc = pins.gpio8.into_push_pull_output();
|
||||
let cs = pins.gpio9.into_push_pull_output();
|
||||
|
@ -162,7 +162,6 @@ pub fn init() {
|
|||
.invert_colors(mipidsi::options::ColorInversion::Inverted)
|
||||
.init(&mut timer)
|
||||
.unwrap();
|
||||
backlight.set_high().unwrap();
|
||||
|
||||
let touch = xpt2046::XPT2046::new(
|
||||
&IRQ_PIN,
|
||||
|
@ -200,14 +199,16 @@ pub fn init() {
|
|||
window: Default::default(),
|
||||
buffer_provider: buffer_provider.into(),
|
||||
touch: touch.into(),
|
||||
backlight: Some(backlight).into(),
|
||||
}))
|
||||
.expect("backend already initialized");
|
||||
}
|
||||
|
||||
struct PicoBackend<DrawBuffer, Touch> {
|
||||
struct PicoBackend<DrawBuffer, Touch, Backlight> {
|
||||
window: RefCell<Option<Rc<renderer::MinimalSoftwareWindow>>>,
|
||||
buffer_provider: RefCell<DrawBuffer>,
|
||||
touch: RefCell<Touch>,
|
||||
backlight: RefCell<Option<Backlight>>,
|
||||
}
|
||||
|
||||
impl<
|
||||
|
@ -219,10 +220,12 @@ impl<
|
|||
CS_: OutputPin<Error = Infallible>,
|
||||
IRQ: InputPin<Error = Infallible>,
|
||||
SPI: SpiDevice,
|
||||
BL: OutputPin<Error = Infallible>,
|
||||
> slint::platform::Platform
|
||||
for PicoBackend<
|
||||
DrawBuffer<Display<DI, RST>, PioTransfer<TO, CH>, (DC_, CS_)>,
|
||||
xpt2046::XPT2046<IRQ, SPI>,
|
||||
BL,
|
||||
>
|
||||
{
|
||||
fn create_window_adapter(
|
||||
|
@ -254,6 +257,9 @@ impl<
|
|||
let mut buffer_provider = self.buffer_provider.borrow_mut();
|
||||
renderer.render_by_line(&mut *buffer_provider);
|
||||
buffer_provider.flush_frame();
|
||||
if let Some(mut backlight) = self.backlight.take() {
|
||||
backlight.set_high().unwrap();
|
||||
}
|
||||
});
|
||||
|
||||
// handle touch event
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue