⚡️ SPI+DMA+interrupt method (STM32 / MKS UI) (#23464)
This commit is contained in:
@ -1331,7 +1331,6 @@ void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue) {
|
||||
lv_label_set_text((lv_obj_t*)btn->child_ll.head, curValue ? machine_menu.enable : machine_menu.disable);
|
||||
}
|
||||
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
void sd_detection() {
|
||||
@ -1360,7 +1359,9 @@ void print_time_count() {
|
||||
}
|
||||
|
||||
void LV_TASK_HANDLER() {
|
||||
lv_task_handler();
|
||||
|
||||
if (TERN1(USE_SPI_DMA_TC, !get_lcd_dma_lock()))
|
||||
lv_task_handler();
|
||||
|
||||
#if BOTH(MKS_TEST, SDSUPPORT)
|
||||
if (mks_test_flag == 0x1E) mks_hardware_test();
|
||||
|
@ -133,6 +133,27 @@ void tft_lvgl_init() {
|
||||
|
||||
watchdog_refresh(); // LVGL init takes time
|
||||
|
||||
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
|
||||
uint16_t usb_flash_loop = 1000;
|
||||
#if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE
|
||||
SET_INPUT_PULLUP(SD_DETECT_PIN);
|
||||
if (READ(SD_DETECT_PIN) == LOW) card.changeMedia(&card.media_driver_sdcard);
|
||||
else card.changeMedia(&card.media_driver_usbFlash);
|
||||
#endif
|
||||
do {
|
||||
card.media_driver_usbFlash.idle();
|
||||
watchdog_refresh();
|
||||
delay(2);
|
||||
} while (!card.media_driver_usbFlash.isInserted() && usb_flash_loop--);
|
||||
card.mount();
|
||||
#elif HAS_LOGO_IN_FLASH
|
||||
delay(1000);
|
||||
watchdog_refresh();
|
||||
delay(1000);
|
||||
#endif
|
||||
|
||||
watchdog_refresh(); // LVGL init takes time
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
UpdateAssets();
|
||||
watchdog_refresh(); // LVGL init takes time
|
||||
@ -231,19 +252,44 @@ void tft_lvgl_init() {
|
||||
#endif
|
||||
}
|
||||
|
||||
static lv_disp_drv_t* disp_drv_p;
|
||||
|
||||
#if ENABLED(USE_SPI_DMA_TC)
|
||||
bool lcd_dma_trans_lock = false;
|
||||
#endif
|
||||
|
||||
void dmc_tc_handler(struct __DMA_HandleTypeDef * hdma) {
|
||||
#if ENABLED(USE_SPI_DMA_TC)
|
||||
lv_disp_flush_ready(disp_drv_p);
|
||||
lcd_dma_trans_lock = false;
|
||||
TFT_SPI::Abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
|
||||
uint16_t width = area->x2 - area->x1 + 1,
|
||||
height = area->y2 - area->y1 + 1;
|
||||
|
||||
TERN_(USE_SPI_DMA_TC, disp_drv_p = disp);
|
||||
|
||||
SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height);
|
||||
|
||||
SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height);
|
||||
|
||||
lv_disp_flush_ready(disp); // Indicate you are ready with the flushing
|
||||
#if ENABLED(USE_SPI_DMA_TC)
|
||||
lcd_dma_trans_lock = true;
|
||||
SPI_TFT.tftio.WriteSequenceIT((uint16_t*)color_p, width * height);
|
||||
TFT_SPI::DMAtx.XferCpltCallback = dmc_tc_handler;
|
||||
#else
|
||||
SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height);
|
||||
lv_disp_flush_ready(disp_drv_p); // Indicate you are ready with the flushing
|
||||
#endif
|
||||
|
||||
W25QXX.init(SPI_QUARTER_SPEED);
|
||||
}
|
||||
|
||||
#if ENABLED(USE_SPI_DMA_TC)
|
||||
bool get_lcd_dma_lock() { return lcd_dma_trans_lock; }
|
||||
#endif
|
||||
|
||||
void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color) {
|
||||
uint16_t width, height;
|
||||
width = x2 - x1 + 1;
|
||||
|
@ -64,6 +64,8 @@ lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
|
||||
void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color);
|
||||
|
||||
bool get_lcd_dma_lock();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
||||
|
@ -121,6 +121,11 @@ public:
|
||||
inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); };
|
||||
|
||||
inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); };
|
||||
|
||||
#if ENABLED(USE_SPI_DMA_TC)
|
||||
inline static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { io.WriteSequenceIT(Data, Count); };
|
||||
#endif
|
||||
|
||||
// static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
|
||||
inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); };
|
||||
|
||||
|
Reference in New Issue
Block a user