【专题STM32F03】 使用 STM32Cube\Repository\STM32Cube_FW_F1_V1.8.5 中例程由ST7735硬SPI串口屏修改驱动ST7789V硬SPI串口LCD屏
1.【专题STM32F103】FSMC+LCD+ ILI9341驱动程序+由标准库 修改为 HAL库+STM32F103霸道V2板2.【专题STM32F103】串口下载程序 +野火霸道开发板3.【专题STM32F103】HX711 测重传感器的采样值读取-HAL库版本4.【专题STM32F103】PB6接SCL,PB7接SDA,IIC通信访问 24C02, STM32F103的HAL版本5.【专题STM32F103】STM32+HAL库+SHT30温湿度传感器模块I2C通讯数字型6.【专题STM32F103】步进电机控制 stm32 hal库版本7.【专题STM32F103】四位阳数码管显示 stm32 HAL库8.【专题STM32F103】关于STM32Cube_FW_F1_V1.8.0内的example顶层程序设计逻辑 与 RTC_Calendar增补9.【专题STM32F103】移植STemWin5.44+ ILI9341显示无触摸屏 + cubemx+野火霸道V210.【专题STM32F03】FreeRTOS 队列queue传递结构体,野火例程代码简单修改。
11.【专题STM32F03】 使用 STM32Cube\Repository\STM32Cube_FW_F1_V1.8.5 中例程由ST7735硬SPI串口屏修改驱动ST7789V硬SPI串口LCD屏
1)修改Project
\STM32Cube_FW_F1_V1.8.5\Projects\STM32F103RB-Nucleo\Demonstrations\Adafruit_LCD_1_8_SD_Joystick
2)接线 (见 stm32f1xx_nucleo.h)
LCD_LED_PIN 接高电平
LCD_CS_PIN 接PB6
LCD_DC_PIN 接PA9
LCD_SPI_CLK 接SPI1 ,PA5
LCD_SPI_SDA 接SPI1 ,PA7
3)修改代码
st7735.h
/** * @brief ST7735 Size */ //#define ST7735_LCD_PIXEL_WIDTH ((uint16_t)128) //#define ST7735_LCD_PIXEL_HEIGHT ((uint16_t)160) #define ST7735_LCD_PIXEL_WIDTH ((uint16_t)240) #define ST7735_LCD_PIXEL_HEIGHT ((uint16_t)320)
st7735.c
void st7735_Init(void) { uint8_t data = 0; /* Initialize ST7735 low level bus layer -----------------------------------*/ LCD_IO_Init(); /* Out of sleep mode, 0 args, no delay */ st7735_WriteReg(0x11, 0x00);//LCD_Write_Cmd(0x11); LCD_Delay(10); st7735_WriteReg(0x36, 0x00);//LCD_Write_Cmd(0x36); //LCD_Write_Data(0x00); //横屏 如果设置不对,会出现两种色块分屏 //LCD_Write_Data (0xa0); //横屏 st7735_WriteReg(0x3a, 0x05);//LCD_Write_Cmd(0x3a); //LCD_Write_Data (0x05); //像素点的数据格式设置为 RGB:565 //与屏的型号有关 st7735_WriteReg(0x20, 0x00);//LCD_Write_Cmd(0x20); // 颜色值需按位取反 /* porch 设置 */ //st7735_WriteReg(0x2b, 0x00);//LCD_Write_Cmd(0xb2); st7735_WriteReg(0x2b, 0x0c);//LCD_Write_Data (0x0c); st7735_WriteReg(0x2b, 0x0c);//LCD_Write_Data (0x0c); st7735_WriteReg(0x2b, 0x00);//LCD_Write_Data (0x00); st7735_WriteReg(0x2b, 0x33);//LCD_Write_Data (0x33); st7735_WriteReg(0x2b, 0x33);//LCD_Write_Data (0x33); /* VGH设置 */ st7735_WriteReg(0xb7, 0x35);//LCD_Write_Cmd(0xb7); //LCD_Write_Data (0x35); /* VCOM 设置 */ st7735_WriteReg(0xbb, 0x35);//LCD_Write_Cmd(0xbb); //LCD_Write_Data (0x35); /* LCM 设置 */ st7735_WriteReg(0xc0, 0x2c);//LCD_Write_Cmd(0xc0); //LCD_Write_Data (0x2c); /* VDV and VRH 设置 */ st7735_WriteReg(0xc2, 0x01);//LCD_Write_Cmd(0xc2); //LCD_Write_Data (0x01); /* VRH 设置 */ st7735_WriteReg(0xc3, 0x0b);//LCD_Write_Cmd(0xc3); //LCD_Write_Data (0x0b); /* VDV 设置 */ st7735_WriteReg(0xc4, 0x20);//LCD_Write_Cmd(0xc4); //LCD_Write_Data (0x20); /* 普通模式下显存速率设置 60Mhz */ st7735_WriteReg(0xc6, 0x1e);//LCD_Write_Cmd(0xc6); //LCD_Write_Data (0x1e); /* 电源控制 */ st7735_WriteReg(0xd0, 0xa4);//LCD_Write_Cmd(0xd0); //LCD_Write_Data (0xa4); st7735_WriteReg(0xd0, 0xa1);//LCD_Write_Data (0xa1); /* 正电压设置 */ //st7735_WriteReg(0xe0, 0x00);//LCD_Write_Cmd(0xE0); //Set Gamma st7735_WriteReg(0xe0, 0xd0);//LCD_Write_Data (0xd0); st7735_WriteReg(0xe0, 0x00);//LCD_Write_Data (0x00); st7735_WriteReg(0xe0, 0x02);//LCD_Write_Data (0x02); st7735_WriteReg(0xe0, 0x07);//LCD_Write_Data (0x07); st7735_WriteReg(0xe0, 0x0b);//LCD_Write_Data (0x0b); st7735_WriteReg(0xe0, 0x1a);//LCD_Write_Data (0x1a); st7735_WriteReg(0xe0, 0x31);//LCD_Write_Data (0x31); st7735_WriteReg(0xe0, 0x54);//LCD_Write_Data (0x54); st7735_WriteReg(0xe0, 0x40);//LCD_Write_Data (0x40); st7735_WriteReg(0xe0, 0x29);//LCD_Write_Data (0x29); st7735_WriteReg(0xe0, 0x12);//LCD_Write_Data (0x12); st7735_WriteReg(0xe0, 0x12);//LCD_Write_Data (0x12); st7735_WriteReg(0xe0, 0x12);//LCD_Write_Data (0x12); st7735_WriteReg(0xe0, 0x17);//LCD_Write_Data (0x17); /* 负电压设置 */ //st7735_WriteReg(0xe1, 0x00);//LCD_Write_Cmd(0XE1); //Set Gamma st7735_WriteReg(0xe1, 0xd0);//LCD_Write_Data (0xd0); st7735_WriteReg(0xe1, 0x00);//LCD_Write_Data (0x00); st7735_WriteReg(0xe1, 0x02);//LCD_Write_Data (0x02); st7735_WriteReg(0xe1, 0x07);//LCD_Write_Data (0x07); st7735_WriteReg(0xe1, 0x05);//LCD_Write_Data (0x05); st7735_WriteReg(0xe1, 0x25);//LCD_Write_Data (0x25); st7735_WriteReg(0xe1, 0x2d);//LCD_Write_Data (0x2d); st7735_WriteReg(0xe1, 0x44);//LCD_Write_Data (0x44); st7735_WriteReg(0xe1, 0x45);//LCD_Write_Data (0x45); st7735_WriteReg(0xe1, 0x1c);//LCD_Write_Data (0x1c); st7735_WriteReg(0xe1, 0x18);//LCD_Write_Data (0x18); st7735_WriteReg(0xe1, 0x16);//LCD_Write_Data (0x16); st7735_WriteReg(0xe1, 0x1c);//LCD_Write_Data (0x1c); st7735_WriteReg(0xe1, 0x1d);//LCD_Write_Data (0x1d); /* 显示开 */ st7735_WriteReg(0x29, 0x00);//LCD_Write_Cmd(0x29); }
LCD相关的源代码依赖关系解析: LCD +STM32F103RB-Nucleo+Demonstrations+Adafruit_LCD_1_8_SD_Joystick
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)