My gloal is to connect slint with the waveshare screen on the esp32 ansusing rust.
i have spend literaly days searching to display something on the screen https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(C)
I've wire the screen following this (and according to the doc ) : https://europe1.discourse-cdn.com/arduino/original/4X/7/2/1/721d0c0306133e962fcfbbcd239eff1798942e56.png
so to achieve my goal i tried as a first step to display something on the screen
but I've never been able to display anything
[edit 2]
there is my code :
#![no_std]
#![no_main]
use esp_backtrace as _;
use esp_hal::{
delay::Delay,
gpio::{Io, Level, NoPin, Output},
prelude::*,
spi::{master::Spi, SpiMode}};
use embedded_graphics::{prelude::*, primitives::Rectangle, pixelcolor::Rgb565,primitives::PrimitiveStyleBuilder};
use display_interface_spi::SPIInterface;
use embedded_hal_bus::spi::ExclusiveDevice;
use mipidsi::{models::ILI9486Rgb565, Builder};
extern crate alloc;
use core::mem::MaybeUninit; //clone,
fn init_heap() {
const HEAP_SIZE: usize = 32 * 1024;
static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit();
unsafe {
esp_alloc::HEAP.add_region(esp_alloc::HeapRegion::new(
HEAP.as_mut_ptr() as *mut u8,
HEAP_SIZE,
esp_alloc::MemoryCapability::Internal.into(),
));
}
}
#[entry]
fn main() -> ! {
let peripherals = esp_hal::init(esp_hal::Config::default());
let mut delay = Delay::new();
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
// slint use heap, setup allocator
init_heap();
esp_println::logger::init_logger_from_env();
log::info!("dbg -- 1");
// -------- Setup clocks --------
let sclk = io.pins.gpio12;
let miso = io.pins.gpio13;
let mosi = io.pins.gpio11;
let mut cs_screen = Output::new(io.pins.gpio10,Level::High);
let _cs_touch = Output::new(io.pins.gpio9,Level::High);
let mut rst = Output::new(io.pins.gpio18,Level::High);
let mut dc = Output::new(io.pins.gpio17,Level::High);
rst.set_low();
delay.delay(10.millis());
rst.set_high();
let spi = Spi::new(
peripherals.SPI2,
500.kHz(),
SpiMode::Mode0,
)
.with_pins(sclk, mosi, miso,NoPin);
log::info!("dbg -- 2");
let ed_spi = ExclusiveDevice::new(spi, &mut cs_screen, delay).unwrap();
// Créer l'interface SPI sans contrôle de CS
let di = SPIInterface::new(ed_spi, &mut dc);
let mut display = Builder::new(ILI9486Rgb565, di)
.reset_pin(rst)
.display_size(320, 480)
.init(&mut delay).unwrap();
log::info!("dbg -- 3");
display.clear(Rgb565::BLACK).unwrap();
//Dessiner un rectangle rouge
loop {
let style = PrimitiveStyleBuilder::new()
.fill_color(Rgb565::RED)
.build();
Rectangle::new(Point::new(50, 50), Size::new(50, 50))
.into_styled(style)
.draw(&mut display)
.unwrap();
log::info!("dbg -- 4");
delay.delay(1000.millis());
}
}
the spi signals looks ok but still nothing on the display im not sure if the screen support 3.3v spi level
[ return from waveshare ]
This screen doesn't support 3.3V. If it's used under this voltage for a long time, the screen will be damaged.
It is recommended that you use the product recommended below to transplant to ESP32. For this product, we have provided Arduino examples.
https://www.waveshare.net/shop/3.5inch-TFT-Touch-Shield.htm
[]
So, i couldn't test it right away with a logic-level adapter. And it's not impossible that I killed the screen.
anyway, i'll put the topic in resolute and update the post when i can.