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)
2018-4-24 19:38 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|