STM32CubeMX-Keil_uVision5/FinalHomework/Core/Src/test.c

272 lines
10 KiB
C
Raw Permalink Normal View History

2025-01-07 10:02:18 +08:00
/****************************************************************************************************
//=========================================<3D><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>================================================//
// LCDģ<44><C4A3> STM32<33><32>Ƭ<EFBFBD><C6AC>
// VCC <20><> DC5V/3.3V //<2F><>Դ
// GND <20><> GND //<2F><>Դ<EFBFBD><D4B4>
//=======================================Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD>==========================================//
//<2F><>ģ<EFBFBD><C4A3>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪSPI<50><49><EFBFBD><EFBFBD>
// LCDģ<44><C4A3> STM32<33><32>Ƭ<EFBFBD><C6AC>
// SDA <20><> PB15 //Һ<><D2BA><EFBFBD><EFBFBD>SPI<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>ź<EFBFBD>
//=======================================Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD>==========================================//
// LCDģ<44><C4A3> STM32<33><32>Ƭ<EFBFBD><C6AC>
// LED <20><> PB9 //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>5V<35><56>3.3V
// SCK <20><> PB13 //Һ<><D2BA><EFBFBD><EFBFBD>SPI<50><49><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ź<EFBFBD>
// A0 <20><> PB10 //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
// RESET <20><> PB12 //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
// CS <20><> PB11 //Һ<><D2BA><EFBFBD><EFBFBD>Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
//=========================================<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=========================================//
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E9B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><DCBB>ߴ<EFBFBD><DFB4>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// LCDģ<44><C4A3> STM32<33><32>Ƭ<EFBFBD><C6AC>
// T_IRQ <20><> PC10 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ź<EFBFBD>
// T_DO <20><> PC2 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SPI<50><49><EFBFBD>߶<EFBFBD><DFB6>ź<EFBFBD>
// T_DIN <20><> PC3 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SPI<50><49><EFBFBD><EFBFBD>д<EFBFBD>ź<EFBFBD>
// T_CS <20><> PC13 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
// T_CLK <20><> PC0 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SPI<50><49><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ź<EFBFBD>
**************************************************************************************************/
/* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, QD electronic SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
**************************************************************************************************/
#include "lcd.h"
#include "gui.h"
#include "test.h"
#include "pic.h"
#include "main.h"
//========================variable==========================//
uint16_t ColorTab[5]={RED,GREEN,BLUE,YELLOW,BRED};//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
//=====================end of variable======================//
/*****************************************************************************
* @name :void DrawTestPage(uint8_t *str)
* @date :2018-08-09
* @function :Drawing test interface
* @parameters :str:the start address of the Chinese and English strings
* @retvalue :None
******************************************************************************/
void DrawTestPage(uint8_t *str)
{
//<2F><><EFBFBD>ƹ̶<C6B9><CCB6><EFBFBD>up
LCD_Clear(WHITE);
LCD_Fill(0,0,lcddev.width,20,BLUE);
//<2F><><EFBFBD>ƹ̶<C6B9><CCB6><EFBFBD>down
LCD_Fill(0,lcddev.height-20,lcddev.width,lcddev.height,BLUE);
POINT_COLOR=WHITE;
Gui_StrCenter(0,2,WHITE,BLUE,str,16,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
Gui_StrCenter(0,lcddev.height-18,WHITE,BLUE,"www.lcdwiki.com",16,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
//<2F><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
}
/*****************************************************************************
* @name :void main_test(void)
* @date :2018-08-09
* @function :Drawing the main Interface of the Comprehensive Test Program
* @parameters :None
* @retvalue :None
******************************************************************************/
void main_test(void)
{
DrawTestPage("<EFBFBD>ۺϲ<EFBFBD><EFBFBD>Գ<EFBFBD><EFBFBD><EFBFBD>");
Gui_StrCenter(0,23,RED,BLUE,"ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",16,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
Gui_StrCenter(0,40,RED,BLUE,"<EFBFBD>ۺϲ<EFBFBD><EFBFBD>Գ<EFBFBD><EFBFBD><EFBFBD>",16,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
Gui_StrCenter(0,57,GREEN,BLUE,"1.8\" ST7735S",16,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
Gui_StrCenter(0,74,GREEN,BLUE,"128X160",16,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
Gui_StrCenter(0,91,BLUE,BLUE,"2018-08-22",16,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
HAL_Delay(1500);
HAL_Delay(1500);
}
/*****************************************************************************
* @name :void Test_Color(void)
* @date :2018-08-09
* @function :Color fill test(white,black,red,green,blue)
* @parameters :None
* @retvalue :None
******************************************************************************/
void Test_Color(void)
{
//DrawTestPage("<22><><EFBFBD><EFBFBD>1:<3A><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
LCD_Fill(0,0,lcddev.width,lcddev.height,WHITE);
Show_Str(20,30,BLUE,YELLOW,"BL Test",16,1);HAL_Delay(800);
LCD_Fill(0,0,lcddev.width,lcddev.height,RED);
Show_Str(20,30,BLUE,YELLOW,"RED ",16,1);HAL_Delay(800);
LCD_Fill(0,0,lcddev.width,lcddev.height,GREEN);
Show_Str(20,30,BLUE,YELLOW,"GREEN ",16,1);HAL_Delay(800);
LCD_Fill(0,0,lcddev.width,lcddev.height,BLUE);
Show_Str(20,30,RED,YELLOW,"BLUE ",16,1);HAL_Delay(800);
}
/*****************************************************************************
* @name :void Test_FillRec(void)
* @date :2018-08-09
* @function :Rectangular display and fill test
Display red,green,blue,yellow,pink rectangular boxes in turn,
1500 milliseconds later,
Fill the rectangle in red,green,blue,yellow and pink in turn
* @parameters :None
* @retvalue :None
******************************************************************************/
void Test_FillRec(void)
{
uint8_t i=0;
DrawTestPage("GUI<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
for (i=0; i<5; i++)
{
POINT_COLOR=ColorTab[i];
LCD_DrawRectangle(lcddev.width/2-40+(i*16),lcddev.height/2-40+(i*13),lcddev.width/2-40+(i*16)+30,lcddev.height/2-40+(i*13)+30);
}
HAL_Delay(1500);
LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
for (i=0; i<5; i++)
{
POINT_COLOR=ColorTab[i];
LCD_DrawFillRectangle(lcddev.width/2-40+(i*16),lcddev.height/2-40+(i*13),lcddev.width/2-40+(i*16)+30,lcddev.height/2-40+(i*13)+30);
}
HAL_Delay(1500);
}
/*****************************************************************************
* @name :void Test_Circle(void)
* @date :2018-08-09
* @function :circular display and fill test
Display red,green,blue,yellow,pink circular boxes in turn,
1500 milliseconds later,
Fill the circular in red,green,blue,yellow and pink in turn
* @parameters :None
* @retvalue :None
******************************************************************************/
void Test_Circle(void)
{
uint8_t i=0;
DrawTestPage("GUI<EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
for (i=0; i<5; i++)
gui_circle(lcddev.width/2-40+(i*15),lcddev.height/2-25+(i*13),ColorTab[i],15,0);
HAL_Delay(1500);
LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
for (i=0; i<5; i++)
gui_circle(lcddev.width/2-40+(i*15),lcddev.height/2-25+(i*13),ColorTab[i],15,1);
HAL_Delay(1500);
}
/*****************************************************************************
* @name :void English_Font_test(void)
* @date :2018-08-09
* @function :English display test
* @parameters :None
* @retvalue :None
******************************************************************************/
void English_Font_test(void)
{
DrawTestPage("Ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Show_Str(10,22,BLUE,YELLOW,"6X12:abcdefgh01234567",12,0);
Show_Str(10,34,BLUE,YELLOW,"6X12:ABCDEFGH01234567",12,1);
Show_Str(10,47,BLUE,YELLOW,"6X12:~!@#$%^&*()_+{}:",12,0);
Show_Str(10,60,BLUE,YELLOW,"8X16:abcde01234",16,0);
Show_Str(10,76,BLUE,YELLOW,"8X16:ABCDE01234",16,1);
Show_Str(10,92,BLUE,YELLOW,"8X16:~!@#$%^&*()",16,0);
HAL_Delay(1200);
}
/*****************************************************************************
* @name :void Test_Triangle(void)
* @date :2018-08-09
* @function :triangle display and fill test
Display red,green,blue,yellow,pink triangle boxes in turn,
1500 milliseconds later,
Fill the triangle in red,green,blue,yellow and pink in turn
* @parameters :None
* @retvalue :None
******************************************************************************/
void Test_Triangle(void)
{
uint8_t i=0;
DrawTestPage("GUI Tri<72><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
for(i=0;i<5;i++)
{
POINT_COLOR=ColorTab[i];
Draw_Triangel(lcddev.width/2-40+(i*15),lcddev.height/2-12+(i*11),lcddev.width/2-25-1+(i*15),lcddev.height/2-12-26-1+(i*11),lcddev.width/2-10-1+(i*15),lcddev.height/2-12+(i*11));
}
HAL_Delay(1500);
LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
for(i=0;i<5;i++)
{
POINT_COLOR=ColorTab[i];
Fill_Triangel(lcddev.width/2-40+(i*15),lcddev.height/2-12+(i*11),lcddev.width/2-25-1+(i*15),lcddev.height/2-12-26-1+(i*11),lcddev.width/2-10-1+(i*15),lcddev.height/2-12+(i*11));
}
HAL_Delay(1500);
}
/*****************************************************************************
* @name :void Chinese_Font_test(void)
* @date :2018-08-09
* @function :chinese display test
* @parameters :None
* @retvalue :None
******************************************************************************/
void Chinese_Font_test(void)
{
DrawTestPage("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Show_Str(10,25,BLUE,YELLOW,"16X16:ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD>ӭ",16,0);
Show_Str(10,45,BLUE,YELLOW,"24X24:<3A><><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>",24,1);
Show_Str(10,70,BLUE,YELLOW,"32X32:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",32,1);
HAL_Delay(1200);
}
/*****************************************************************************
* @name :void Pic_test(void)
* @date :2018-08-09
* @function :picture display test
* @parameters :None
* @retvalue :None
******************************************************************************/
void Pic_test(void)
{
DrawTestPage("ͼƬ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
//LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
Gui_Drawbmp16(20,30,gImage_qq);
Show_Str(20+12,75,BLUE,YELLOW,"QQ",16,1);
Gui_Drawbmp16(70,30,gImage_qq);
Show_Str(70+12,75,BLUE,YELLOW,"QQ",16,1);
// Gui_Drawbmp16(150,30,gImage_qq);
// Show_Str(150+12,75,BLUE,YELLOW,"QQ",16,1);
HAL_Delay(1200);
}
/*****************************************************************************
* @name :void Rotate_Test(void)
* @date :2018-08-09
* @function :rotate test
* @parameters :None
* @retvalue :None
******************************************************************************/
void Rotate_Test(void)
{
uint8_t i=0;
uint8_t *Direction[4]={"Rotation:0","Rotation:90","Rotation:180","Rotation:270"};
for(i=0;i<4;i++)
{
LCD_direction(i);
DrawTestPage("<EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Show_Str(20,30,BLUE,YELLOW,Direction[i],16,1);
Gui_Drawbmp16(30,50,gImage_qq);
HAL_Delay(1000);HAL_Delay(1000);
}
LCD_direction(USE_HORIZONTAL);
}