Merge branch 'main' into TFTP

This commit is contained in:
2023-11-13 10:35:07 +01:00
2 changed files with 23 additions and 7 deletions

View File

@@ -10,6 +10,8 @@
#include <string.h>
#include <ctype.h>
#define LOGGER_LEVEL_ALL
#include "log.h"
#include "../../Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_lcd.h"
#define LCD_BLUE LCD_COLOR_BLUE

View File

@@ -4,13 +4,15 @@
* @author Tim S.
* @todo Implement function to read images from fs
*/
#include "lcd_api.h"
static const char* TAG = "lcd_api";
static DMA2D_HandleTypeDef hDma2dHandler2;
void lcd_init(bool bl_on) {
LOG_INFO(TAG, "Init LCD");
BSP_LCD_Init();
BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS);
BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS + (BSP_LCD_GetXSize()*BSP_LCD_GetYSize()*4));
@@ -28,6 +30,8 @@ void lcd_init(bool bl_on) {
}
void lcd_display_text(uint8_t* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT *font) {
LOG_INFO(TAG, "Display text: %s @x=%d,y=%d", text, x_pos, y_pos);
uint16_t tot_length = x_pos + (strlen(text) * font->Width);
if ((x_pos % font->Width) != 0) {
x_pos -= (x_pos % font->Width);
@@ -72,12 +76,22 @@ void lcd_draw_bmp(const void* p_src, uint32_t x_pos, uint32_t y_pos, uint32_t x_
hDma2dHandler2.LayerCfg[1].InputColorMode = color_mode;
hDma2dHandler2.LayerCfg[1].InputOffset = 0;
LOG_INFO(TAG, "DMA2D init");
hDma2dHandler2.Instance = DMA2D;
if (HAL_DMA2D_Init(&hDma2dHandler2) == HAL_OK) {
if (HAL_DMA2D_ConfigLayer(&hDma2dHandler2, 1) == HAL_OK) {
if (HAL_DMA2D_Start(&hDma2dHandler2, (uint32_t)p_src, (uint32_t)p_dst, x_size, y_size) == HAL_OK) {
HAL_DMA2D_PollForTransfer(&hDma2dHandler2, 10);
}
}
if (HAL_DMA2D_Init(&hDma2dHandler2) != HAL_OK) {
LOG_CRIT(TAG, "HAL_DMA2D_Init error");
return;
}
LOG_INFO(TAG, "DMA2D config layer");
if (HAL_DMA2D_ConfigLayer(&hDma2dHandler2, 1) != HAL_OK) {
LOG_CRIT(TAG, "HAL_DMA2D_ConfigLayer error");
return;
}
LOG_INFO(TAG, "DMA2D start");
if (HAL_DMA2D_Start(&hDma2dHandler2, (uint32_t)p_src, (uint32_t)p_dst, x_size, y_size) != HAL_OK) {
LOG_CRIT(TAG, "HAL_DMA2D_Start error");
return;
}
LOG_INFO(TAG, "DMA2D poll");
HAL_DMA2D_PollForTransfer(&hDma2dHandler2, 10);
}