給各位參考下
單片機源程序如下:
- //==================================如何切換橫豎屏顯示=======================================//
- //打開Lcd_Driver.h頭文件,修改宏#define USE_HORIZONTAL 值為0使用豎屏模式.1,使用橫屏模式
- //===========================如何切換模擬SPI總線驅動和硬件SPI總線驅動=========================//
- //打開Lcd_Driver.h頭文件,修改宏#define USE_HARDWARE_SPI 值為0使用模擬SPI總線.1,使用硬件SPI總線
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f10x.h"
- #include "Lcd_Driver.h"
- #include "LCD_Config.h"
- #include "GUI.h"
- #include "delay.h"
- #include "Picture.h"
- GPIO_InitTypeDef GPIO_InitStructure;
- void RCC_Configuration(void);
- void Delayms(__IO uint32_t nCount);
- unsigned char Num[10]={0,1,2,3,4,5,6,7,8,9};
- void Redraw_Mainmenu(void)
- {
- Lcd_Clear(GRAY0);
-
- Gui_DrawFont_GBK16(8,2,BLUE,GRAY0,"Mcudev電子技術");
- Gui_DrawFont_GBK16(32,20,BLUE,GRAY0,"液晶測試");
- DisplayButtonUp(15,38,113,58); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(16,40,GREEN,GRAY0,"顏色填充測試");
- DisplayButtonUp(15,68,113,88); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(16,70,BLUE,GRAY0,"文字顯示測試");
- DisplayButtonUp(15,98,113,118); //x1,y1,x2,y2
- Gui_DrawFont_GBK16(16,100,RED,GRAY0,"圖片顯示測試");
- #if USE_HORIZONTAL==1 //使用橫屏
-
- Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[5]);
- delay_ms(1000);
- Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[4]);
- delay_ms(1000);
- Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[3]);
- delay_ms(1000);
- Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[2]);
- delay_ms(1000);
- Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[1]);
- delay_ms(1000);
- Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[0]);
-
- #else
-
- Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[5]);
- delay_ms(1000);
- Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[4]);
- delay_ms(1000);
- Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[3]);
- delay_ms(1000);
- Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[2]);
- delay_ms(1000);
- Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[1]);
- delay_ms(1000);
- Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[0]);
-
- #endif
- }
- void Num_Test(void)
- {
- u8 i=0;
- Lcd_Clear(GRAY0);
- Gui_DrawFont_GBK16(16,20,RED,GRAY0,"Num Test");
- delay_ms(1000);
- Lcd_Clear(GRAY0);
- for(i=0;i<10;i++)
- {
- Gui_DrawFont_Num32((i%3)*40,32*(i/3),RED,GRAY0,Num[i+1]);
- delay_ms(100);
- }
-
- }
- void Font_Test(void)
- {
- Lcd_Clear(GRAY0);
- Gui_DrawFont_GBK16(16,10,BLUE,GRAY0,"文字顯示測試");
- delay_ms(1000);
- Lcd_Clear(GRAY0);
- Gui_DrawFont_GBK16(16,16,BLACK,GRAY0,"嵌入式開發(fā)網");
- Gui_DrawFont_GBK16(32,36,BLACK,GRAY0,"中文測試");
- Gui_DrawFont_GBK16(16,52,BLUE,GRAY0,"專注液晶批發(fā)");
- Gui_DrawFont_GBK16(16,70,RED,GRAY0, "全程技術支持");
- Gui_DrawFont_GBK16(16,100,GREEN,GRAY0,"mcudev.taobao");
- delay_ms(1800);
- }
- void Color_Test(void)
- {
- u8 i=1;
- Lcd_Clear(GRAY0);
-
- Gui_DrawFont_GBK16(20,10,BLUE,GRAY0,"Color Test");
- delay_ms(200);
- while(i--)
- {
- Lcd_Clear(WHITE);
- Lcd_Clear(BLACK);
- Lcd_Clear(RED);
- Lcd_Clear(GREEN);
- Lcd_Clear(BLUE);
- }
- }
- //16位 垂直掃描 右到左 高位在前
- void show_pic(void)
- {
- int i,j,k;
- unsigned char picH,picL;
-
- Lcd_Clear(GRAY0);
-
- Gui_DrawFont_GBK16(16,10,BLUE,GRAY0,"圖片顯示測試");
-
- delay_ms(1000);
-
- Lcd_Clear(GRAY0);
-
- #if USE_HORIZONTAL==1 //使用橫屏
- {
- k=0;
- for(i=0;i<128;i++)
- for(j=0;j<160;j++)
- {
- picH=gImage_1234[k++];
- picL=gImage_1234[k++];
- Lcd_WriteData(picH);
- Lcd_WriteData(picL);
-
-
- }
- }
-
- #else
- {
- k=0;
- for(i=0;i<160;i++)
- for(j=0;j<128;j++)
- {
- picH=gImage_123[k++];
- picL=gImage_123[k++];
- Lcd_WriteData(picH);
- Lcd_WriteData(picL);
- }
- }
- #endif
- }
- //畫圓 劃線 算法演示
- void show_Circle(void)
- {
- Lcd_Clear(GRAY0);
-
- Gui_DrawFont_GBK16(8,10,BLUE,GRAY0,"Circle顯示測試");
-
- delay_ms(1000);
-
- Lcd_Clear(GRAY0);
-
- #if USE_HORIZONTAL==1 //使用橫屏
- Gui_DrawLine(0, 0,159,0,RED);//畫一條直徑線
- Gui_DrawLine(0, 1,159,1,RED);//畫一條直徑線
-
- Gui_DrawLine(159, 0,159,127,RED);//畫一條直徑線
- Gui_DrawLine(158, 0,158,127,RED);//畫一條直徑線
-
- Gui_DrawLine(0, 127,159,127,RED);//畫一條直徑線
- Gui_DrawLine(0, 126,159,126,RED);//畫一條直徑線
-
- Gui_DrawLine(0, 0,0, 127,RED);//畫一條直徑線
- Gui_DrawLine(1, 0,1, 127,RED);//畫一條直徑線
-
- #else //豎屏顯示
-
- Gui_DrawLine(0, 0,127,0,RED);//畫一條直徑線
- Gui_DrawLine(0, 1,127,1,RED);//畫一條直徑線
-
- Gui_DrawLine(127, 0,127,159,RED);//畫一條直徑線
- Gui_DrawLine(126, 0,126,159,RED);//畫一條直徑線
-
- Gui_DrawLine(0, 159,127,159,RED);//畫一條直徑線
- Gui_DrawLine(0, 158,127,158,RED);//畫一條直徑線
-
- Gui_DrawLine(0, 0,0, 159,RED);//畫一條直徑線
- Gui_DrawLine(1, 0,1, 159,RED);//畫一條直徑線
- #endif
-
- Gui_Circle(64,64,50,RED);//畫一個圓形
- Gui_Circle(64,64,40,GREEN);
- Gui_Circle(64,64,30,BLUE);
-
-
- Gui_DrawLine(10, 79,110, 79,BLACK);//畫一條黑色的直徑線
- Gui_DrawLine(10, 80,110, 80,BLACK);//畫一條黑色的直徑線
- Gui_DrawLine(10, 81,110, 81,BLACK);//畫一條黑色的直徑線
- }
- u16 ID=0;
- int main(void)
- {
- SystemInit();
- delay_init(72);//延時初始化
- Lcd_Init();//初始化硬件SPI
-
- while(1)
- {
-
- // LCD_LED_SET;//通過IO控制背光亮
- Redraw_Mainmenu();
- Color_Test();//簡單純色填充測試
- Num_Test();
- Font_Test();//中英文顯示測試
- show_pic();//圖片顯示示例
- delay_ms(1200);
- show_Circle();//繪圖算法顯示---畫圓
- delay_ms(2000);
-
- // LCD_LED_CLR;//IO控制背光滅
- }
- }
- void RCC_Configuration(void)
- {
- /* Setup the microcontroller system. Initialize the Embedded Flash Interface,
- initialize the PLL and update the SystemFrequency variable. */
- SystemInit();
- }
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼 全部資料51hei下載地址:
1.80寸tft.7z
(475.5 KB, 下載次數(shù): 34)
2019-1-2 01:34 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|