From 35871d9eaeb582a83dd801c39494c3ebc565d77d Mon Sep 17 00:00:00 2001 From: xoreo Date: Mon, 13 Nov 2023 17:45:28 +0100 Subject: [PATCH] Implement lcd_draw_img_from_fs_with_name --- project/Core/Inc/lcd_api.h | 12 +++++++++++- project/Core/Src/lcd_api.c | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/project/Core/Inc/lcd_api.h b/project/Core/Inc/lcd_api.h index 7fe30c0..77a297f 100644 --- a/project/Core/Inc/lcd_api.h +++ b/project/Core/Inc/lcd_api.h @@ -105,8 +105,18 @@ void lcd_draw_raw_img(const void* p_src, uint32_t x_pos, uint32_t y_pos, uint32_ * @param[in] y_pos Y-position * @param[in] BMP file data */ -void lcd_draw_bmp_img(uint32_t x_pos, uint32_t y_pos, uint8_t* bmp_buff); +void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos); +/** + * @brief Draw BMP image on screen by specifying the name, the BMP image has in the file system + * Draw BMP image from C array to the LCD screen at position X, Y by specifying the BMP image name on the filesystem + * Supports ARGB8888, RGB565, RGB888 + * + * @param[in] x_pos X-position + * @param[in] y_pos Y-position + * @param[in] BMP file data + */ +void lcd_draw_img_from_fs_with_name(const char* name, uint32_t x_pos, uint32_t y_pos); /** * @brief Clear LCD screen diff --git a/project/Core/Src/lcd_api.c b/project/Core/Src/lcd_api.c index a632cc0..18636a7 100644 --- a/project/Core/Src/lcd_api.c +++ b/project/Core/Src/lcd_api.c @@ -96,10 +96,19 @@ void lcd_draw_raw_img(const void* p_src, uint32_t x_pos, uint32_t y_pos, uint32_ HAL_DMA2D_PollForTransfer(&hDma2dHandler2, 10); } -void lcd_draw_bmp_img(uint32_t x_pos, uint32_t y_pos, uint8_t* bmp_buff){ +void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos){ BSP_LCD_DrawBitmap(x_pos, y_pos, bmp_buff); } +void lcd_draw_img_from_fs_with_name(const char* name, uint32_t x_pos, uint32_t y_pos){ + llfs_file_t* file = llfs_file_open(name); + if (file != NULL) { + BSP_LCD_DrawBitmap(x_pos, y_pos, file->data); + } else { + LOG_WARN(TAG, "File \"%s\" not found", file->name); + } +} + void lcd_clear(uint32_t color){ BSP_LCD_Clear(color); }