你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32WBA55CG使用spi驱动ST7789 LCD

[复制链接]
Stm32McuLover 提问时间:2024-12-22 14:36 / 未解决

项目用到LCD显示信息,使用的屏幕是微雪电子的1.69寸IPS彩色LCD显示屏,分辨率是240×280分辨率,采用SPI接口驱动。驱动芯片是ST7789V2,模块使用到6个控制管脚:

LCD_DINLCD_CLKLCD_CSLCD_DCLCD_RSTLCD_BL

SPI 通信 MOSI 引脚 SPI 通信 CLK引脚 LCD 的片选引脚,低电平有效 LCD 的数据/命令引脚,低电平表示命令,高电平表示数据 LCD 的复位引脚,低电平有效 LCD 的背光引脚 根据开发板的原理图,选择合适的管脚:

屏幕截图2024-12-08214617.png

屏幕截图2024-12-08214636.png

使用STM32CubeMX配置SPI驱动过程如下:

11.png

屏幕截图2024-12-08214923.png

背光管脚配置PWM输出,PA2定时器3通道1,

内部时钟,分频系数99,计数值999,则PWM频率为:100MHz/(99+1)/(999+1)=1KHz,

输出占空比百分值为:Pulse值/(999+1)

测试代码

include "image.h"

include "LCD_Test.h"

include "LCD_1in69.h"

include "Touch_Driver.h"

include "DEV_Config.h"

Touch_1IN69_XY XY; UBYTE flag = 0,flgh = 0; UWORD x,y,l = 0;

void LCD_1in69_test() { printf("LCD_1IN28_test Demo\r\n"); DEV_Module_Init();

printf("LCD1IN28 Init and Clear...\r\n"); LCD_1IN69_SetBackLight(1000); LCD_1IN69_Init(VERTICAL); LCD_1IN69_Clear(WHITE);

XY.mode = 0;
//if(Touch_1IN69_init(XY.mode) == true)
// printf("OK!\r\n"); // else // printf("NO!\r\n");

printf("Paint_NewImage\r\n");
Paint_NewImage(LCD_1IN69_WIDTH, LCD_1IN69_HEIGHT, 0, WHITE);

printf("Set Clear and Display Funtion\r\n");
Paint_SetClearFuntion(LCD_1IN69_Clear);
Paint_SetDisplayFuntion(LCD_1IN69_DrawPoint);
printf("Paint_Clear\r\n"); Paint_Clear(BLACK); Paint_Clear(RED); Paint_Clear(GREEN); Paint_Clear(BLUE);

Paint_Clear(BLACK); Paint_DrawString_EN(0, 90, "stm32wba55cg", &Font24, BLACK, RED); Paint_DrawString_EN(0, 120, "eepw bbs", &Font20, BLACK, GREEN); while(1);

Paint_ClearWindows(10,90,230,137,WHITE);
Paint_DrawString_EN(105, 100, "Up", &Font24, 0X647C, WHITE); /while(XY.Gesture != UP) { if (flag == TOUCH_IRQ) { XY.Gesture = I2C_Read_Byte(0x01); flag = TOUCH_DRAW; } DEV_Delay_ms(10); }/

Paint_ClearWindows(105,100,160,155,WHITE);
Paint_DrawString_EN(85, 100, "Down", &Font24, 0X647C, WHITE);
/while(XY.Gesture != Down) { if (flag == TOUCH_IRQ) { XY.Gesture = I2C_Read_Byte(0x01); flag = TOUCH_DRAW; }
DEV_Delay_ms(10);
}
/

Paint_ClearWindows(85, 100,160,155,WHITE);
Paint_DrawString_EN(85, 100, "Left", &Font24, 0X647C, WHITE);
/while(XY.Gesture != LEFT) { if (flag == TOUCH_IRQ) { XY.Gesture = I2C_Read_Byte(0x01); flag = TOUCH_DRAW; }
DEV_Delay_ms(10);
}
/

Paint_ClearWindows(85, 100,160,155,WHITE);
Paint_DrawString_EN(80, 100, "Right", &Font24, 0X647C, WHITE);
/while(XY.Gesture != RIGHT) { if (flag == TOUCH_IRQ) { XY.Gesture = I2C_Read_Byte(0x01); flag = TOUCH_DRAW; }
DEV_Delay_ms(10);
}
/

Paint_ClearWindows(80, 100,165,160,WHITE);
Paint_DrawString_EN(47, 100, "Long Press", &Font20, 0X647C, WHITE);
/while(XY.Gesture != LONG_PRESS) { if (flag == TOUCH_IRQ) { XY.Gesture = I2C_Read_Byte(0x01); flag = TOUCH_DRAW; }
DEV_Delay_ms(10);
}
/

Paint_ClearWindows(47, 100,200,155,WHITE);
Paint_DrawString_EN(35, 100, "Double Click", &Font20, 0X647C, WHITE);
while(XY.Gesture != DOUBLE_CLICK)
{
if (flag == TOUCH_IRQ)
{
XY.Gesture = I2C_Read_Byte(0x01);
flag = TOUCH_DRAW;
}
DEV_Delay_ms(10);
}

XY.mode = 1;
//Touch_1IN69_init(XY.mode);
Paint_ClearWindows(10,90,230,137,WHITE);
Paint_DrawPoint(120, 140, BLACK, DOT_PIXEL_2X2, DOT_FILL_AROUND);
while (1)
{
if (flag == TOUCH_IRQ)
{
Paint_DrawPoint(XY.x_point, XY.y_point, XY.color, DOT_PIXEL_2X2, DOT_FILL_AROUND);
}
}
}

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { //if(GPIO_Pin & TP_INT_Pin) { if(XY.mode == 1) { flag = TOUCH_IRQ; //XY = Touch_1IN69_Get_Point(); } //else { flag = TOUCH_IRQ; } } }

效果:

微信图片_20241208215802.jpg

微信图片_20241208215806.jpg

收藏 评论0 发布时间:2024-12-22 14:36

举报

0个回答

所属标签

相似问题

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32Cube扩展软件包
意法半导体边缘AI套件
ST - 理想汽车豪华SUV案例
ST意法半导体智能家居案例
STM32 ARM Cortex 32位微控制器
关注我们
st-img 微信公众号
st-img 手机版