1.8寸 lcd tft显示屏 显示模块。
单片机源程序如下:
- //==================================如何切换横竖屏显示=======================================//
- //打开Lcd_Driver.h头文件,修改宏#define USE_HORIZONTAL 值为0使用竖屏模式.1,使用横屏模式
- //===========================如何切换模拟SPI总线驱动和硬件SPI总线驱动=========================//
- //打开Lcd_Driver.h头文件,修改宏#define USE_HARDWARE_SPI 值为0使用模拟SPI总线.1,使用硬件SPI总线
- /*Voltage[4]:电压
- *I_current[4]:电流
- *direction[4]:方向
- *speed[4]:速度
- *temperature[4]:温度*/
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f10x.h"
- #include "Lcd_Driver.h"
- #include "LCD_Config.h"
- #include "GUI.h"
- #include "delay.h"
- #include "Picture.h"
- #define uint unsigned int
- #define uchar unsigned char
- GPIO_InitTypeDef GPIO_InitStructure;
- void RCC_Configuration(void);
- void Delayms(__IO uint32_t nCount);
- uchar Num[10]={0,1,2,3,4,5,6,7,8,9};
- uchar number[4],nnn=100;
- uchar Voltage[4],I_current[4],direction[4],speed[4],temperature[4];
- void Redraw_Mainmenu(void)
- {
- Lcd_Clear(GRAY0);
-
- Gui_DrawFont_GBK16(16,2,BLUE,GRAY0,"后备保护系统");
- DisplayButtonUp(15,26,113,50); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(15,30,RED,GRAY0,"电流:");
- sprintf(I_current ,"%d",nnn);
- Gui_DrawFont_GBK16(54, 30, RED, GRAY0,I_current);
- Gui_DrawFont_GBK16(92,30,RED,GRAY0,"A");
-
- DisplayButtonUp(15,51,113,75); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(16,55,RED,GRAY0,"电压:");
- sprintf(Voltage,"%d",nnn);
- Gui_DrawFont_GBK16(54, 55, RED, GRAY0,Voltage);
- Gui_DrawFont_GBK16(92,55,RED,GRAY0,"V");
-
- DisplayButtonUp(15,76,113,100); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(16,80,RED,GRAY0,"方向:");
- Gui_DrawFont_GBK16(54,80,RED,GRAY0,"上行");
-
- DisplayButtonUp(15,101,113,125); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(16,105,RED,GRAY0,"转速:");
- sprintf(speed,"%d",nnn);
- Gui_DrawFont_GBK16(54, 105, RED, GRAY0,speed);
- Gui_DrawFont_GBK16(84,105,RED,GRAY0,"m/s");
-
- DisplayButtonUp(15,126,113,150); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(16,130,RED,GRAY0,"温度:");
- sprintf(temperature,"%d",nnn);
- Gui_DrawFont_GBK16(54, 130, RED, GRAY0,temperature);
- Gui_DrawFont_GBK16(92,130,RED,GRAY0,"度");
- }
- //u16 ID=0;
- int main(void)
- {
- SystemInit();
- delay_init(72);//延时初始化
- Lcd_Init();//初始化硬件SPI
-
- Redraw_Mainmenu();
-
-
- while(1)
- {
- }
- }
- //void RCC_Configuration(void)
- //{
- // /* 设置微控制器系统,初始化嵌入式FLASH接口,初始化PLL并更新系统频率变量 */
- // SystemInit();
- //}
- void Delayms(__IO uint32_t nCount)
- {
- for(; nCount != 0; nCount--);
- }
- #ifdef USE_FULL_ASSERT
- /**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval : None
- */
- void assert_failed(uint8_t* file, uint32_t line)
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
显示.rar
(368.75 KB, 下载次数: 171)
|