|
本帖最后由 topdog 于 2021-4-17 01:12 编辑
用示例改了一下,把你需要的提取出来。
[pre]#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_KBV.h> //Hardware-specific library
//定义句柄
LCDWIKI_KBV my_lcd(ILI9341,A3,A2,A1,A0,A4); //model,cs,cd,wr,rd,reset
//显示眉头眉脚的提示
unsigned long show_text(void)
{
unsigned long time_start = micros();
my_lcd.Set_Draw_color(32, 0,255);
my_lcd.Fill_Rectangle(0, 0, my_lcd.Get_Display_Width()-1, 14);
my_lcd.Set_Text_colour(0, 255, 0);
my_lcd.Set_Text_Size(1);
my_lcd.Set_Text_Mode(1);
my_lcd.Print_String("* Universal Color TFT Display Library *", CENTER, 3);
my_lcd.Set_Draw_color(128, 128, 128);
my_lcd.Fill_Rectangle(0, my_lcd.Get_Display_Height()-15, my_lcd.Get_Display_Width()-1, my_lcd.Get_Display_Height()-1);
my_lcd.Set_Text_colour(255, 255, 255);
my_lcd.Set_Text_Size(1);
my_lcd.Set_Text_Mode(1);
my_lcd.Print_String("<https://www.arduino.cn>", CENTER, my_lcd.Get_Display_Height()-11);
my_lcd.Set_Draw_color(255, 0, 0);
my_lcd.Draw_Rectangle(0, 15, my_lcd.Get_Display_Width()-1, my_lcd.Get_Display_Height()-16);
return micros() - time_start;
}
//画一个移动的正弦波
unsigned long show_sinewave(void)
{
uint16_t buf[my_lcd.Get_Display_Width()-2],x = 1,i,y;
unsigned long time_start = micros();
int16_t wid = my_lcd.Get_Display_Width();
int16_t t;
float k;
if(wid == 320)
{
t = 20;
k = 1.1;
}
else
{
t = 15;
k = 0.7;
}
my_lcd.Set_Draw_color(0, 0, 255);
my_lcd.Draw_Fast_VLine(my_lcd.Get_Display_Width()/2-1, 16, my_lcd.Get_Display_Height()- 32);
my_lcd.Draw_Fast_HLine(1, my_lcd.Get_Display_Height()/2-1, my_lcd.Get_Display_Width()-2);
for (i=1; i<((my_lcd.Get_Display_Width()-2)*t); i++)
{
x++;
if (x==my_lcd.Get_Display_Width()-1)
{
x=1;
}
if (i>my_lcd.Get_Display_Width()-1)
{
if ((x==my_lcd.Get_Display_Width()/2-1)||(buf[x-1]==my_lcd.Get_Display_Height()/2-1))
{
my_lcd.Set_Draw_color(0, 0, 255);
}
else
{
my_lcd.Set_Draw_color(0, 0, 0);
}
my_lcd.Draw_Pixel(x,buf[x-1]);
}
my_lcd.Set_Draw_color(255, 64, 255);
y=my_lcd.Get_Display_Height()/2-1+(sin(((i*k)*3.14)/180)*(90-(i/100)));
my_lcd.Draw_Pixel(x,y);
buf[x-1]=y;
}
return micros()- time_start;
}
//清屏
void clear_screen(void)
{
delay(2000);
my_lcd.Set_Draw_color(0, 0, 0);
my_lcd.Fill_Rectangle(1, 16, my_lcd.Get_Display_Width()-2, my_lcd.Get_Display_Height()-17);
}
unsigned long (*show_function[])(void) = {
show_text,
show_sinewave,
};
uint8_t *show_str[]= {
"show text :",
"show sinewave :",
};
//显示程序的运行时间
void show_total_time(void)
{
uint16_t i;
unsigned long buf[15];
unsigned long time_start = micros();
for(i = 0;i< 15;i++)
{
buf = show_function();
clear_screen();
}
for(i = 0;i<15; i++)
{
my_lcd.Set_Text_colour(255, 165, 0);
my_lcd.Set_Text_Size(1);
my_lcd.Set_Text_Mode(1);
my_lcd.Print_String(show_str, (my_lcd.Get_Display_Width()-260)/2-1, (my_lcd.Get_Display_Height()-150)/2+i*10-1);
my_lcd.Set_Text_colour(0, 255, 0);
my_lcd.Print_Number_Int(buf, (my_lcd.Get_Display_Width()-260)/2-1+200, (my_lcd.Get_Display_Height()-150)/2+i*10-1, 0, ' ', 10);
}
delay(1000);
}
void setup()
{
my_lcd.Init_LCD();
my_lcd.Fill_Screen(0x0);
my_lcd.Set_Rotation(1);
}
void loop()
{
my_lcd.Fill_Screen(0x0);
show_total_time();
}[/pre]
|
|