| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "Int_lcd.h"
- #include "ltdc.h"
- extern LTDC_HandleTypeDef hltdc;
- static volatile uint16_t *Int_lcd_framebuf = (volatile uint16_t *)INT_LCD_FRAME_BUF_ADDR;
- void Int_lcd_bl_on(void)
- {
- HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
- }
- void Int_lcd_bl_off(void)
- {
- HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET);
- }
- static void Int_lcd_reset(void)
- {
- /* LCD 硬件复位:高 -> 低(50ms) -> 高(200ms) */
- HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_SET);
- HAL_Delay(10);
- HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_RESET);
- HAL_Delay(50);
- HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_SET);
- HAL_Delay(200);
- }
- static void Int_lcd_layer_init(void)
- {
- LTDC_LayerCfgTypeDef layer = {0};
- layer.WindowX0 = 0;
- layer.WindowX1 = INT_LCD_WIDTH;
- layer.WindowY0 = 0;
- layer.WindowY1 = INT_LCD_HEIGHT;
- layer.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
- layer.Alpha = 255;
- layer.Alpha0 = 0;
- /* PAxCA 混合模式:alpha 因子 / 常量 alpha */
- layer.BlendingFactor1 = (uint32_t)6 << 8;
- layer.BlendingFactor2 = (uint32_t)7;
- layer.FBStartAdress = INT_LCD_FRAME_BUF_ADDR;
- layer.ImageWidth = INT_LCD_WIDTH;
- layer.ImageHeight = INT_LCD_HEIGHT;
- layer.Backcolor.Blue = 0;
- layer.Backcolor.Green = 0;
- layer.Backcolor.Red = 0;
- HAL_LTDC_ConfigLayer(&hltdc, &layer, 0);
- }
- void Int_lcd_init(void)
- {
- Int_lcd_reset();
- Int_lcd_layer_init();
- Int_lcd_clear(LCD_COLOR_BLACK);
- Int_lcd_bl_on();
- }
- void Int_lcd_clear(uint16_t color)
- {
- uint32_t i;
- uint32_t total = INT_LCD_WIDTH * INT_LCD_HEIGHT;
- for (i = 0; i < total; i++)
- {
- Int_lcd_framebuf[i] = color;
- }
- }
- void Int_lcd_draw_point(uint16_t x, uint16_t y, uint16_t color)
- {
- if (x < INT_LCD_WIDTH && y < INT_LCD_HEIGHT)
- {
- Int_lcd_framebuf[y * INT_LCD_WIDTH + x] = color;
- }
- }
|