给各位参考下
单片机源程序如下:
- //==================================如何切换横竖屏显示=======================================//
- //打开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,"嵌入式开发网");
- Gui_DrawFont_GBK16(32,36,BLACK,GRAY0,"中文测试");
- Gui_DrawFont_GBK16(16,52,BLUE,GRAY0,"专注液晶批发");
- 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, 下载次数: 34)
|