mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
增加LCD动态翻转的函数
This commit is contained in:
@@ -4,17 +4,6 @@
|
|||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
|
||||||
#if USE_HORIZONTAL == 0
|
|
||||||
#define OFFSET_Y 0
|
|
||||||
#define OFFSET_X 0
|
|
||||||
#elif USE_HORIZONTAL == 1
|
|
||||||
#define OFFSET_Y 80
|
|
||||||
#define OFFSET_X 0
|
|
||||||
#else
|
|
||||||
#define OFFSET_Y 0
|
|
||||||
#define OFFSET_X 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern osSemaphoreId_t DMA_SemaphoreHandle;
|
extern osSemaphoreId_t DMA_SemaphoreHandle;
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
函数说明:在指定区域填充颜色
|
函数说明:在指定区域填充颜色
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
#include "tim.h"
|
#include "tim.h"
|
||||||
|
|
||||||
|
uint8_t LCD_ROTATION = 0; // 0, 90, 180, 270
|
||||||
|
uint8_t OFFSET_X = 0;
|
||||||
|
uint8_t OFFSET_Y = 0;
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
函数说明:LCD端口初始化
|
函数说明:LCD端口初始化
|
||||||
入口数据:无
|
入口数据:无
|
||||||
@@ -175,6 +179,33 @@ void LCD_ST7789_SleepOut(void)
|
|||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
函数说明:设置屏幕旋转方向
|
||||||
|
入口数据:rotation 0, 90, 180, 270
|
||||||
|
返回值: 无
|
||||||
|
******************************************************************************/
|
||||||
|
void LCD_SetRotation(uint8_t rotation) {
|
||||||
|
LCD_WR_REG(0x36); // Memory Data Access Control
|
||||||
|
switch(rotation) {
|
||||||
|
case 0:
|
||||||
|
OFFSET_Y = 0;
|
||||||
|
LCD_WR_DATA8(0x00);
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
OFFSET_Y = 80;
|
||||||
|
LCD_WR_DATA8(0xC0);
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
LCD_WR_DATA8(0x70);
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
LCD_WR_DATA8(0xA0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LCD_WR_DATA8(0x00);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
函数说明:LCD初始化
|
函数说明:LCD初始化
|
||||||
@@ -194,10 +225,7 @@ void LCD_Init(void)
|
|||||||
LCD_WR_REG(0x11);
|
LCD_WR_REG(0x11);
|
||||||
HAL_Delay(120);
|
HAL_Delay(120);
|
||||||
LCD_WR_REG(0x36);
|
LCD_WR_REG(0x36);
|
||||||
if(USE_HORIZONTAL==0)LCD_WR_DATA8(0x00);
|
LCD_SetRotation(LCD_ROTATION);
|
||||||
else if(USE_HORIZONTAL==1)LCD_WR_DATA8(0xC0);
|
|
||||||
else if(USE_HORIZONTAL==2)LCD_WR_DATA8(0x70);
|
|
||||||
else LCD_WR_DATA8(0xA0);
|
|
||||||
|
|
||||||
LCD_WR_REG(0x3A);
|
LCD_WR_REG(0x3A);
|
||||||
LCD_WR_DATA8(0x05);
|
LCD_WR_DATA8(0x05);
|
||||||
|
|||||||
@@ -3,19 +3,13 @@
|
|||||||
|
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
#define USE_HORIZONTAL 1 //设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏
|
extern uint8_t LCD_ROTATION;
|
||||||
|
extern uint8_t OFFSET_X;
|
||||||
|
extern uint8_t OFFSET_Y;
|
||||||
|
|
||||||
|
|
||||||
#if USE_HORIZONTAL==0||USE_HORIZONTAL==1
|
|
||||||
#define LCD_W 240
|
#define LCD_W 240
|
||||||
#define LCD_H 240
|
#define LCD_H 240
|
||||||
|
|
||||||
#else
|
|
||||||
#define LCD_W 240
|
|
||||||
#define LCD_H 240
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------LCD端口定义----------------
|
//-----------------LCD端口定义----------------
|
||||||
#define SCLK_PORT GPIOB
|
#define SCLK_PORT GPIOB
|
||||||
#define SCLK_PIN GPIO_PIN_13
|
#define SCLK_PIN GPIO_PIN_13
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ int main(void)
|
|||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
//this must set same as keil setting
|
//this must set same as keil setting
|
||||||
SCB->VTOR = 0x00000000U;
|
SCB->VTOR = FLASH_BASE + 0x00000000;
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user