@@ -8,6 +8,7 @@ use embedded_graphics::{
8
8
Drawable ,
9
9
} ;
10
10
use embedded_text:: TextBox ;
11
+ use esp_idf_svc:: hal:: gpio:: AnyIOPin ;
11
12
use esp_idf_svc:: sys:: EspError ;
12
13
use u8g2_fonts:: U8g2TextStyle ;
13
14
@@ -17,6 +18,20 @@ pub type ColorFormat = Rgb565;
17
18
18
19
static mut ESP_LCD_PANEL_HANDLE : esp_idf_svc:: sys:: esp_lcd_panel_handle_t = std:: ptr:: null_mut ( ) ;
19
20
21
+ fn init_spi_rs (
22
+ spi : esp_idf_svc:: hal:: spi:: SPI3 ,
23
+ sclk : AnyIOPin ,
24
+ sdo : AnyIOPin ,
25
+ sdi : Option < AnyIOPin > ,
26
+ ) -> esp_idf_svc:: hal:: spi:: SpiDriver < ' static > {
27
+ let config = esp_idf_svc:: hal:: spi:: SpiDriverConfig :: new ( ) . dma (
28
+ esp_idf_svc:: hal:: spi:: Dma :: Auto ( DISPLAY_WIDTH * DISPLAY_HEIGHT ) ,
29
+ ) ;
30
+
31
+ let driver = esp_idf_svc:: hal:: spi:: SpiDriver :: new ( spi, sclk, sdo, sdi, & config) . unwrap ( ) ;
32
+ driver
33
+ }
34
+
20
35
fn init_spi ( ) -> Result < ( ) , EspError > {
21
36
use esp_idf_svc:: sys:: * ;
22
37
const GPIO_NUM_NC : i32 = -1 ;
@@ -119,6 +134,17 @@ pub fn init_ui() -> Result<(), EspError> {
119
134
Ok ( ( ) )
120
135
}
121
136
137
+ pub fn init_ui_rs (
138
+ spi : esp_idf_svc:: hal:: spi:: SPI3 ,
139
+ sclk : AnyIOPin ,
140
+ sdo : AnyIOPin ,
141
+ sdi : Option < AnyIOPin > ,
142
+ ) -> Result < esp_idf_svc:: hal:: spi:: SpiDriver < ' static > , EspError > {
143
+ let driver = init_spi_rs ( spi, sclk, sdo, sdi) ;
144
+ init_lcd ( ) ?;
145
+ Ok ( driver)
146
+ }
147
+
122
148
pub fn hello_lcd ( ) -> Result < ( ) , EspError > {
123
149
let mut display = Box :: new ( Framebuffer :: <
124
150
ColorFormat ,
0 commit comments