加入屏幕翻转的功能

This commit is contained in:
不吃油炸鸡
2025-10-18 19:23:22 +08:00
parent 5e4040aad4
commit cc3f9d243c
8 changed files with 43 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ extern osSemaphoreId_t DMA_SemaphoreHandle;
void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
{
u16 i,j;
LCD_Address_Set(xsta,ysta+OFFSET_Y,xend-1,yend-1+OFFSET_Y);//设置显示范围
LCD_Address_Set(xsta+OFFSET_X, ysta+OFFSET_Y,xend-1+OFFSET_X, yend-1+OFFSET_Y);//设置显示范围
for(i=ysta;i<yend;i++)
{
for(j=xsta;j<xend;j++)
@@ -39,7 +39,7 @@ void LCD_Color_Render(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 *color_p)
height = yend-ysta+1;
uint32_t size = width * height;
LCD_Address_Set(xsta,ysta+OFFSET_Y,xend,yend+OFFSET_Y);
LCD_Address_Set(xsta+OFFSET_X, ysta+OFFSET_Y, xend+OFFSET_X, yend+OFFSET_Y);
hspi2.Init.DataSize = SPI_DATASIZE_16BIT;
hspi2.Instance->CR1|=SPI_CR1_DFF;

View File

@@ -184,24 +184,32 @@ void LCD_ST7789_SleepOut(void)
入口数据rotation 0, 90, 180, 270
返回值: 无
******************************************************************************/
void LCD_SetRotation(uint8_t rotation) {
void LCD_SetRotation(uint16_t rotation) {
LCD_WR_REG(0x36); // Memory Data Access Control
switch(rotation) {
case 0:
OFFSET_X = 0;
OFFSET_Y = 0;
LCD_WR_DATA8(0x00);
break;
case 180:
OFFSET_X = 0;
OFFSET_Y = 80;
LCD_WR_DATA8(0xC0);
break;
case 90:
OFFSET_X = 0;
OFFSET_Y = 0;
LCD_WR_DATA8(0x70);
break;
case 270:
OFFSET_X = 80;
OFFSET_Y = 0;
LCD_WR_DATA8(0xA0);
break;
default:
OFFSET_X = 0;
OFFSET_Y = 0;
LCD_WR_DATA8(0x00);
break;
}

View File

@@ -59,6 +59,8 @@ void LCD_Close_Light(void);
void LCD_ST7789_SleepIn(void);
void LCD_ST7789_SleepOut(void);
void LCD_Open_Light(void);
void LCD_SetRotation(uint16_t rotation);
#endif