PlatformIO基于ESP32S2的SPI软串口LCD屏调试

2023-11-02


VSCode PlatformIO Arduino ESP32S2 SPI LCD 320*240

SPI串口LCD屏使用较少的IO,适用于ESP32系列这种IO口不算太多的MCU。由于lcdwiki.com提供的案例程序包括Arduino,但是并不完全适用于ESP32,需要做小幅调整。以下以2.8寸SPI型号ILI9341为例。


一、准备工作

下载SPI屏配套程序http://www.lcdwiki.com/res/Program/Common_SPI/2.8inch/SPI_ILI9341_MSP2807_V1.1/2.8inch_SPI_Module_ILI9341_MSP2807_V1.1.zip,里面包括Arduino库和示例程序。由于ESP32硬件SPI口数量有限,我们使用软件虚拟实现SPI驱动,这里参考案例文件夹Demo_Mega2560_Software_SPI。
但是对于ESP32和ESP32S2,需要对Arduino库文件进行修改,主要改动数据类型定义。我们直接使用Prentice David修改好的LCDWIKI_SPI(https://github.com/prenticedavid/LCDWIKI_SPI)和LCDWIKI_GUI(https://github.com/prenticedavid/LCDWIKI_GUI)。

二、测试

1.全屏检测

复制clear_screen代码,对引脚和参数进行小幅修改,我用的是Nodemcu-32-S2开发板,示例代码如下:

// IMPORTANT: LCDWIKI_SPI LIBRARY MUST BE SPECIFICALLY
//This program is a demo of clearing screen to display black,white,red,green,blue.

#include <Arduino.h>
#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_SPI.h> //Hardware-specific library

//paramters define
#define MODEL ILI9341	//2.8inch_SPI_Module
#define MISO  3
#define LED   4   //if you don't need to control the LED pin,you should set it to -1 and set it to 3.3V
#define SCK   5
#define MOSI  6
#define DC    7
#define RESET 8
#define CS    9

//the definiens of software spi mode as follow:
//if the IC model is known or the modules is unreadable,you can use this constructed function
LCDWIKI_SPI mylcd(MODEL,CS,DC,MISO,MOSI,RESET,SCK,LED); //model,cs,dc,miso,mosi,reset,sck,led
//if the IC model is not known and the modules is readable,you can use this constructed function
//LCDWIKI_SPI mylcd(240,320,CS,DC,MISO,MOSI,RESET,SCK,LED); //width,height,cs,dc,miso,mosi,reset,sck,led

void setup() 
{
    mylcd.Init_LCD(); //initialize lcd
    mylcd.Fill_Screen(0xFFFF); //display white
}

void loop() 
{ 
    //Sequential display black,white,red,green,blue
    mylcd.Fill_Screen(0,0,0);  
    mylcd.Fill_Screen(255,255,255); 
    mylcd.Fill_Screen(255,0,0); 
    mylcd.Fill_Screen(0,255,0);
    mylcd.Fill_Screen(0,0,255);
    delay(3000);
    mylcd.Fill_Screen(0x0000);
    delay(1000);
    mylcd.Fill_Screen(0xFFFF);
    delay(1000);
    mylcd.Fill_Screen(0xF800);
    delay(1000);
    mylcd.Fill_Screen(0x07E0);
   delay(1000);
   mylcd.Fill_Screen(0x001F);
   delay(1000);
}

2.图形测试

复制colligate_test代码,对引脚和参数进行小幅修改,注意这里面如果不修改字符组数据定义的话,会如下报错,导致编译失败。对show_string和show_str定义的数据类型进行修改,改为const char后完成。

报错

示例代码如下:

// IMPORTANT: LCDWIKI_SPI LIBRARY MUST BE SPECIFICALLY
//This program is a demo of how to use most of the functions 
//of the library with a supported display modules.

#include <Arduino.h>
#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_SPI.h> //Hardware-specific library

//paramters define
#define MODEL ILI9341
#define MISO  3
#define LED   4   //if you don't need to control the LED pin,you should set it to -1 and set it to 3.3V
#define SCK   5
#define MOSI  6
#define DC    7
#define RESET 8
#define CS    9

//the definiens of software spi mode as follow:
//if the IC model is known or the modules is unreadable,you can use this constructed function
LCDWIKI_SPI my_lcd(MODEL,CS,DC,MISO,MOSI,RESET,SCK,LED); //model,cs,dc,miso,mosi,reset,sck,led
//if the IC model is not known and the modules is readable,you can use this constructed function
//LCDWIKI_SPI my_lcd(240,320,CS,DC,MISO,MOSI,RESET,SCK,LED); //width,height,cs,dc,miso,mosi,reset,sck,led

void show_string(const char *str,int16_t x,int16_t y,uint8_t csize,uint16_t fc, uint16_t bc,boolean mode)
{
    my_lcd.Set_Text_Mode(mode);
    my_lcd.Set_Text_Size(csize);
    my_lcd.Set_Text_colour(fc);
    my_lcd.Set_Text_Back_colour(bc);
    my_lcd.Print_String(str,x,y);
}

//display main surface
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);
    show_string("* Universal Color TFT Display Library *",CENTER,3,1,0x07E0, 0,1);

    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);
    show_string("<http://www.lcdwiki.com>",CENTER,my_lcd.Get_Display_Height()-11,1,0xFFFF, 0,1);
    
    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;
}

//display triangle functions
unsigned long show_triangle_function(void)
{
     uint16_t i;
     unsigned long time_start = micros();
     // Draw crosshairs
     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_Height()- 32)/2/10;i++)
     {
         my_lcd.Draw_Fast_HLine(my_lcd.Get_Display_Width()/2-1-2, my_lcd.Get_Display_Height()/2-1-i*10, 5);
         my_lcd.Draw_Fast_HLine(my_lcd.Get_Display_Width()/2-1-2, my_lcd.Get_Display_Height()/2-1+i*10, 5);
     }
     for(i = 1;i <= (my_lcd.Get_Display_Width()-2)/2/10;i++)
     {
         my_lcd.Draw_Fast_VLine(my_lcd.Get_Display_Width()/2-1-i*10, my_lcd.Get_Display_Height()/2-1-2, 5);
         my_lcd.Draw_Fast_VLine(my_lcd.Get_Display_Width()/2-1+i*10, my_lcd.Get_Display_Height()/2-1-2, 5);
     }
     
     // Draw sin lines
     show_string("sin",5,17,1,0x07FF, 0,0);
     my_lcd.Set_Draw_color(0, 255, 255); 
     for (i=1; i<my_lcd.Get_Display_Width()-2; i++)
     {
        my_lcd.Draw_Pixel(i,my_lcd.Get_Display_Height()/2-1+(sin(((i*1.13)*3.14)/180)*95));
     }

     // Draw cos lines
     show_string("cos",5,25,1,0x07E0, 0,0);
     my_lcd.Set_Draw_color(0, 255, 0);
     for (i=1; i<my_lcd.Get_Display_Width()-2; i++)
     {
        my_lcd.Draw_Pixel(i,my_lcd.Get_Display_Height()/2-1+(cos(((i*1.13)*3.14)/180)*95));
     }

     // Draw tan lines
     show_string("tan",5,33,1,0xFFE0, 0,0);
     my_lcd.Set_Draw_color(255, 255, 0);
     for (i=1; i<my_lcd.Get_Display_Width()-2; i++)
     {
        my_lcd.Draw_Pixel(i,my_lcd.Get_Display_Height()/2-1+(tan(((i*1.13)*3.14)/180)*10));
     }

     // Draw cot lines
     show_string("cot",5,41,1,0xF800, 0,0);
     my_lcd.Set_Draw_color(255, 0, 0);
     for (i=1; i<my_lcd.Get_Display_Width()-2; i++)
     {
        my_lcd.Draw_Pixel(i,my_lcd.Get_Display_Height()/2-1+1/(tan(((i*1.13)*3.14)/180)*0.1));
     }
     return micros()-time_start;
}

// Draw a moving sinewave
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 t = 20;
   float k = 1.1;
   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;   
}

// Draw some filled rectangles
unsigned long show_fill_rectangle(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    uint16_t side_len = (my_lcd.Get_Display_Height()-40)/5;
    uint16_t x_spec = (my_lcd.Get_Display_Width()-5*side_len)/2;
    uint16_t y_spec = (my_lcd.Get_Display_Height()-5*side_len)/2;
    for(i = 0;i<5;i++)
    {
          switch (i)
          {
            case 0:
              my_lcd.Set_Draw_color(255,0,255);
              break;
            case 1:
              my_lcd.Set_Draw_color(255,0,0);
              break;
            case 2:
              my_lcd.Set_Draw_color(0,255,0);
              break;
            case 3:
              my_lcd.Set_Draw_color(0,0,255);
              break;
            case 4:
              my_lcd.Set_Draw_color(255,255,0);
              break;
            default:
              break;
          }   
          my_lcd.Fill_Rectangle(x_spec+i*side_len-1, y_spec+i*side_len-1, x_spec+(i+1)*side_len-1, y_spec+(i+1)*side_len-1);
          my_lcd.Fill_Rectangle(x_spec+i*side_len-1, y_spec+(5-i)*side_len-1, x_spec+(i+1)*side_len-1, y_spec+(4-i)*side_len-1); 
     }
     return micros()- time_start;   
}

// Draw some filled round rectangles
unsigned long show_fill_round_rectangle(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    uint16_t side_len = (my_lcd.Get_Display_Height()-40)/5;
    uint16_t x_spec = (my_lcd.Get_Display_Width()-5*side_len)/2;
    uint16_t y_spec = (my_lcd.Get_Display_Height()-5*side_len)/2;
    for(i = 0;i<5;i++)
    {
          switch (i)
          {
            case 0:
              my_lcd.Set_Draw_color(255,0,255);
              break;
            case 1:
              my_lcd.Set_Draw_color(255,0,0);
              break;
            case 2:
              my_lcd.Set_Draw_color(0,255,0);
              break;
            case 3:
              my_lcd.Set_Draw_color(0,0,255);
              break;
            case 4:
              my_lcd.Set_Draw_color(255,255,0);
              break;
            default:
              break;
          }   
          my_lcd.Fill_Round_Rectangle(x_spec+i*side_len-1, y_spec+i*side_len-1, x_spec+(i+1)*side_len-1, y_spec+(i+1)*side_len-1,10);
          my_lcd.Fill_Round_Rectangle(x_spec+i*side_len-1, y_spec+(5-i)*side_len-1, x_spec+(i+1)*side_len-1, y_spec+(4-i)*side_len-1,10); 
     }
     return micros()- time_start;   
}

// Draw some filled circles
unsigned long show_fill_circle(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    uint16_t r_len = (my_lcd.Get_Display_Height()-40)/5/2;
    uint16_t x_spec = (my_lcd.Get_Display_Width()-5*r_len*2)/2;
    uint16_t y_spec = (my_lcd.Get_Display_Height()-5*r_len*2)/2;
    for(i = 0;i<5;i++)
    {
          switch (i)
          {
            case 0:
              my_lcd.Set_Draw_color(255,0,255);
              break;
            case 1:
              my_lcd.Set_Draw_color(255,0,0);
              break;
            case 2:
              my_lcd.Set_Draw_color(0,255,0);
              break;
            case 3:
              my_lcd.Set_Draw_color(0,0,255);
              break;
            case 4:
              my_lcd.Set_Draw_color(255,255,0);
              break;
            default:
              break;
          }   
          my_lcd.Fill_Circle(x_spec+r_len+i*r_len*2-1, y_spec+r_len+i*r_len*2-1,r_len);
          my_lcd.Fill_Circle(x_spec+r_len+i*r_len*2-1, y_spec+(5-i)*r_len*2-r_len-1,r_len); 
     }
     return micros()- time_start;   
 }

// Draw some filled triangles
unsigned long show_fill_triangle(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    uint16_t h_len = (my_lcd.Get_Display_Height()-40)/5;
    uint16_t side_len = (h_len*115)/100;
    uint16_t x_spec = (my_lcd.Get_Display_Width()-5*side_len)/2;
    uint16_t y_spec = (my_lcd.Get_Display_Height()-5*h_len)/2;
    for(i = 0;i<5;i++)
    {
          switch (i)
          {
            case 0:
              my_lcd.Set_Draw_color(255,0,255);
              break;
            case 1:
              my_lcd.Set_Draw_color(255,0,0);
              break;
            case 2:
              my_lcd.Set_Draw_color(0,255,0);
              break;
            case 3:
              my_lcd.Set_Draw_color(0,0,255);
              break;
            case 4:
              my_lcd.Set_Draw_color(255,255,0);
              break;
            default:
              break;
          } 
          my_lcd.Fill_Triangle(x_spec+i*side_len-1,y_spec+(i+1)*h_len-1,x_spec+side_len/2+i*side_len-1,y_spec+i*h_len-1,x_spec+(i+1)*side_len-1,y_spec+(i+1)*h_len-1); 
          my_lcd.Fill_Triangle(x_spec+i*side_len-1,y_spec+(5-i)*h_len-1,x_spec+side_len/2+i*side_len-1,y_spec+(4-i)*h_len-1,x_spec+(i+1)*side_len-1,y_spec+(5-i)*h_len-1);  
     }
     return micros()- time_start;   
}

// Draw some lines in a pattern
unsigned long show_grid_lines(void)
{
    uint16_t i;
    unsigned long time_start = micros();
   float k=1.44;
    my_lcd.Set_Draw_color(255,0,0);
    for (i=16; i<my_lcd.Get_Display_Height()-17; i+=5)
    {
       my_lcd.Draw_Line(1, i, (i*k)-10, my_lcd.Get_Display_Height()-17);
     }
     my_lcd.Set_Draw_color(255,0,0);
     for (i=my_lcd.Get_Display_Height()-17; i>16; i-=5)
    {
      my_lcd.Draw_Line(my_lcd.Get_Display_Width()-2, i, (i*k)-11, 16);
    }
    my_lcd.Set_Draw_color(0,255,255);
    for (i=my_lcd.Get_Display_Height()-16; i>16; i-=5)
    {
        my_lcd.Draw_Line(1, i, (my_lcd.Get_Display_Height()-17)*k+10-(i*k), 16);
    }
    my_lcd.Set_Draw_color(0,255,255);
    for (int i=15; i<my_lcd.Get_Display_Height()-17; i+=5)
    {
        my_lcd.Draw_Line(my_lcd.Get_Display_Width()-2, i, (my_lcd.Get_Display_Height()-17)*k+10-(i*k), my_lcd.Get_Display_Height()-17);
    }
    return micros()- time_start;   
}

// Draw some random pixels
unsigned long show_random_pixels(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    for(i = 0;i< 5000;i++)
    {
       my_lcd.Set_Draw_color(random(255),random(255),random(255));
       my_lcd.Draw_Pixel(2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34));
    }
    return micros()- time_start; 
}

// Draw some random lines
unsigned long show_random_lines(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    for(i = 0;i< 300;i++)
    {
       my_lcd.Set_Draw_color(random(255),random(255),random(255));
       my_lcd.Draw_Line(2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34),2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34));
    }
    return micros()- time_start; 
}

// Draw some random rectangles
unsigned long show_random_rectangles(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    for(i = 0;i< 150;i++)
    {
       my_lcd.Set_Draw_color(random(255),random(255),random(255));
       my_lcd.Draw_Rectangle(2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34),2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34));
    }
    return micros()- time_start; 
}

// Draw some random round rectangles
unsigned long show_random_round_rectangles(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    for(i = 0;i< 150;i++)
    {
       my_lcd.Set_Draw_color(random(255),random(255),random(255));
       my_lcd.Draw_Round_Rectangle(2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34),2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34),5);
    }
    return micros()- time_start; 
}

// Draw some random circles
unsigned long show_random_circles(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    for(i = 0;i< 150;i++)
    {
       my_lcd.Set_Draw_color(random(255),random(255),random(255));
       my_lcd.Draw_Circle(41+random(my_lcd.Get_Display_Width()-82), 56+random(my_lcd.Get_Display_Height()-112), random(40));
    }
    return micros()- time_start; 
}

// Draw some random triangles
unsigned long show_random_triangles(void)
{
    uint16_t i;
    unsigned long time_start = micros();
    for(i = 0;i< 150;i++)
    {
       my_lcd.Set_Draw_color(random(255),random(255),random(255));
       my_lcd.Draw_Triangle(2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34),2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34),2+random(my_lcd.Get_Display_Width()-4),17+random(my_lcd.Get_Display_Height()-34));
    }
    return micros()- time_start; 
}

// Draw some random bit maps
unsigned long show_random_bit_map(void)
{
    uint16_t buf[48],i;
    unsigned long time_start = micros();
    int16_t len = (my_lcd.Get_Display_Height()*3/4)/6;
    for(i = 0;i< 48; i++)
    {
       my_lcd.Set_Draw_color(random(255), random(255), random(255));
       buf[i] = my_lcd.Get_Draw_color();
    }
    for(i = 1;i<=6;i++)
    {
        my_lcd.Draw_Bit_Map(my_lcd.Get_Display_Width()/2-1-((len/2)*4/3)*i, my_lcd.Get_Display_Height()/2-1-(len/2)*i, 8, 6, buf, i*(len/6));
        delay(100);
    }
    return micros()- time_start; 
}

//Clear the screen
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_triangle_function,
                                          show_sinewave,
                                          show_fill_rectangle,
                                          show_fill_round_rectangle,
                                          show_fill_circle,
                                          show_fill_triangle,
                                          show_grid_lines,
                                          show_random_pixels,
                                          show_random_lines,
                                          show_random_rectangles,
                                          show_random_round_rectangles,
                                          show_random_circles,
                                          show_random_triangles,
                                          show_random_bit_map,
                                          };

 static const char* show_str[] =
 {
                       "TEST_TX  :", 
                       "TEST_TF  :",
                       "TEST_SW  :",
                       "TEST_FR  :",
                       "TEST_FRR :",
                       "TEST_FC  :",
                       "TEST_FT  :",
                       "TEST_GL  :",
                       "TEST_RP  :",
                       "TEST_RL  :",
                       "TEST_RR  :",
                       "TEST_RRR :",
                       "TEST_RC  :",
                       "TEST_RT  :",
                       "TEST_RBM :"
                     };
//display the running time of programs 
unsigned long show_total_time(void)
{
     uint16_t i;
     unsigned long buf[15];
     unsigned long time_start = micros();
     for(i = 0;i< 15;i++)
     {
        buf[i] = show_function[i](); 
        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[i], (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[i], (my_lcd.Get_Display_Width()-260)/2-1+200, (my_lcd.Get_Display_Height()-150)/2+i*10-1, 0, ' ', 10);
     }
     delay(5000);
     return micros()- time_start; 
}

//display ending and total running time
void show_end(unsigned long run_time)
{
    my_lcd.Fill_Screen(0, 255, 255);
    my_lcd.Set_Draw_color(255, 0, 0);
    my_lcd.Fill_Round_Rectangle(my_lcd.Get_Display_Width()/2-1-120+1, my_lcd.Get_Display_Height()/2-1-60+1, my_lcd.Get_Display_Width()/2-1+120-1, my_lcd.Get_Display_Height()/2-1+60-1,5);
    show_string("Running over!",CENTER,my_lcd.Get_Display_Height()/2-1-40,1,0x07FF, 0,1);
    show_string("That's ok!",CENTER,my_lcd.Get_Display_Height()/2-1-30,1,0x07FF, 0,1);
    show_string("After a few seconds,",CENTER,my_lcd.Get_Display_Height()/2-1-20,1,0x07FF, 0,1);
    show_string("it will restart.",CENTER,my_lcd.Get_Display_Height()/2-1-10,1,0x07FF, 0,1);
    show_string("Please wait ...",CENTER,my_lcd.Get_Display_Height()/2-1,1,0x07FF, 0,1);
    show_string("Total runtime(us):  ",my_lcd.Get_Display_Width()/2-1-90,my_lcd.Get_Display_Height()/2-1+40,1,0xFFE0, 0,1);
    my_lcd.Set_Text_colour(0, 255, 0);
    my_lcd.Print_Number_Int(run_time, my_lcd.Get_Display_Width()/2-1+30, my_lcd.Get_Display_Height()/2-1+40, 0, ' ', 10);  
    delay(10000);   
}

void setup() 
{
  my_lcd.Init_LCD();
  my_lcd.Fill_Screen(0x0);  
  my_lcd.Set_Rotation(1);  
}

void loop() 
{
    unsigned long total_time;
    my_lcd.Fill_Screen(0x0); 
    total_time = show_total_time();
    show_end(total_time);    
}

下载后运行测试如下。

运行测试


参考资料

[1] http://www.lcdwiki.com/zh/2.8inch_SPI_Module_ILI9341_SKU:MSP2807
[2] https://github.com/prenticedavid/LCDWIKI_GUI
[3] https://github.com/prenticedavid/LCDWIKI_SPI

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PlatformIO基于ESP32S2的SPI软串口LCD屏调试 的相关文章

  • Arduino F()宏的实现

    我试图了解 Arduino 中的 F 宏实际上对 PGMEM 和 RAM 做了什么以及运行时的影响是什么 有人可以指出定义这个宏的文件吗 这可能是旧版本 但定义它的一个地方是Wstring h as in here http andybro
  • Arduino:将数据存储在 EEPROM 中的轻量级压缩算法

    我想将大量数据存储到我的 Arduino 上ATmega168 http www atmel com devices atmega168 aspx ATmega328 http www atmel com devices atmega328
  • Arduino Nano 上的 WiFi

    我无法找到的虚拟问题 我用来将 WiFi 802 11b g n 添加到 Raspberry Pi 的扩展板也可以在 Nano 上使用吗 换句话说 向 Arduino Nano 板添加 WiFi 有多容易 可行 Thanks Arduino
  • Fedora 中的 Arduino 上传错误“stk500_recv(): 程序员没有响应”

    我正在尝试上传库存Blink在 Fedora Core 15 Linux 中使用 Arduino IDE 绘制草图 我收到此错误 avrdude stk500 recv 程序员没有响应 要重现该问题 通过 USB 线插入 Arduino U
  • 蓝牙 HC-05 发送错误 1F 仅适用于 INQ 命令

    我的新蓝牙 HC 05 模块有问题 在 AT 模式下 它可以与我需要的所有命令完美配合 除了 INQ 我已经尝试事先发送一大堆其他命令 AT INIT OK AT ORGL OK AT ROLE 1 OK AT CLASS 0 OK 他们都
  • PySerial 从 Arduino 读取线路的延迟

    我正在使用带有基本 DigitalReadSerial 设置的 arduino uno 如下所述 http arduino cc en Tutorial DigitalReadSerial http arduino cc en Tutori
  • 如何将值从 Arduino 发送到 Python,然后使用该值

    我正在构建一个使用 Python 进行远程控制的机器人 通过简单的 GUI 通过互联网发送控制消息 我的部分代码 GUI 和控制系统 运行得很好 但我陷入了困境 我正在尝试使用视差平传感器来获取与物体的距离信息Arduino Mega ht
  • DCF77 解码器与噪声信号

    我几乎完成了我的开源 DCF77 解码器项目 当我注意到标准 Arduino DCF77 库在噪声信号上表现非常差时 这一切就开始了 特别是当天线靠近计算机或洗衣机正在运行时 我永远无法从解码器中获取时间 我的第一个方法是向输入信号添加 数
  • 如何通过蓝牙在Raspberry Pi 4和Arduino Nano BLE之间进行读写?

    我能够通过 Rpi4 的 bluepy 和 Arduino Nano BLE 的 ArduinoBLE h 连接 Raspberry Pi 4 和 Arduino Nano BLE 不幸的是 当我尝试从 Rpi4 写入 Arduino Na
  • 终止导致设备或资源繁忙的进程:“/dev/ttyUSB0”?

    我使用以下 Python 代码连接到我的 Arduino 板 device glob glob dev ttyUSB 0 time sleep 1 arduino serial Serial device 115200 timeout 5
  • 是否有通用 I2C 命令来查看设备是否仍然存在于总线上?

    是否有通用的 I2C 命令来查看设备在初始化一次后是否仍然存在于总线上 例如 OLED 显示器 我问这个的原因是为了避免主程序由于库代码中存在无限循环而冻结 当设备断开连接时 例如 Wire 库 在 MCU 启动时 我想检查设备是否可用 并
  • Arduino 的 C++ 类文件中的字符串无法编译

    我正在用 C 为 Arduino 编写一个堆栈类sketch http www arduino cc en Tutorial Sketch 我相信它完全符合AVR 如果这就是它的名字 我记不清了 编译器 我都用过malloc and fre
  • Arduino - 高效地迭代 C 数组

    我有以下数组 PROGMEM prog uint16 t show hide info 4216 8900 4380 580 500 600 500 580 1620 580 500 600 500 580 500 600 480 600
  • Arduino:连接字符串时崩溃和错误

    我尝试将 AES 256 加密的输出连接到一个字符串 将此字符串与从 Android 手机发送的加密字符串进行比较 基本上 连接似乎有效 但在几次运行后会出现错误 不可读的字符 字符串变得更短而不是更长 或崩溃 它是可重现的 重启后在同一点
  • 如何为 Arduino 或类似的微控制器编写 JavaScript 编译器? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我意识到这个问题会引起一些人的注意 并且我意识到 JavaScript 传统上是一种解释性语言 请让我解释一下 我是一名专门从事 We
  • 在 Arduino 上将整数/小数转换为十六进制?

    如何将整数或小数变量转换为十六进制字符串 我可以做相反的事情 将十六进制转换为整数 但我无法找出其他方法 这是为了Serial print 数组中的十六进制值 查看 Arduino 字符串教程here http arduino cc en
  • Arduino C++ 析构函数?

    我知道在Arduino中你不能使用delete 那么什么时候调用 C 类中定义的析构函数呢 同样 如果我想创建一个指向数组的指针 我必须使用malloc and free 当对象被销毁时 析构函数被调用 对于自动 堆栈上 变量 它在离开其作
  • 从 iBeacon 接收 BLE 信号到 Bluno(arduino with BLE)

    我想从 iBeacon 到 Bluno 接收 rssi 信号和 UUID Arduino 板具有 BLE 对此有一些疑问 有没有从 BLE 到 BLE 接收 UUID 和 rssi 的解决方案 两个BLE设备可以互相通信吗 我想找一些网站来
  • 如何在 Arduino 中将 char 变量作为数字打印到串行端口?

    我正在使用 Arduino Uno 我正在从 EEPROM 读取一个字节值并将该值存储在类型变量中char 1 字节 我想将变量的值作为数字 而不是相应的 ASCII 代码 打印到串行监视器 例如考虑char val 5 我想查看串行监视器
  • 仅从日期计算夏令时

    我正在使用 Arduino 和实时时钟芯片 该芯片补偿了闰年等 因此它始终具有正确的日期 但我认为由于区域复杂性 它不处理夏令时 时钟可以给出日 月 年 从 1 开始 以及星期几 星期日 0 到星期六 6 因为我需要与用户输入的日期和时间进

随机推荐

  • 【排序算法】快速排序的分析改进

    基本的快速排序 最基本的快速排序是由C A R Hoare在1960年提出的 快速排序的算法是一种分治排序算法 它将数组划分为两个部分 然后分别对两个部分进行排序 快速每次对数组重新排序 选择一个基准值key 然后让数组满足下面的两个个条件
  • TensorFlow:实战Google深度学习框架(六)图像数据处理

    第七章 图像数据处理 7 1 TFRecord输入数据格式 TensorFlow提供了一种统一的格式来存储数据 TFRecord格式 7 1 1 TFRecord格式介绍 7 1 2 TFRecord样例程序 7 2 图像数据处理 7 2
  • linux中shell中使用expect实现自动应答

    linux中shell中使用expect实现自动应答 expect有两种方式 一种是为了单纯的进行自动应答 还有一种是为了结合shell脚本 大多数情况下都是为了结合shell脚本 这里示例两种写法 但在使用时应该尽量使用结合shell方式
  • 杀毒软件 clamav 的安装和使用

    目录 一 clamAV介绍 二 安装ClamAV clamdscan 三 手动更新数据库 四 用法 4 1 clamscan用法 4 2 clamdscan用法 五 python判定有无检测出病毒 一 clamAV介绍 ClamAV 杀毒是
  • python入门基础-数据类型&有序序列和无序序列;

    目录 python优点 python缺点 python应用场景 Python数据类型 字符串 string 列表 list 元组 tuple 不可变数据 1 2 3 set 集合 1 2 3 无序 自动去重 dict字典 key value
  • 基于YOLO的3D人脸关键点检测方案

    目录 前言 一 任务列表 二 3D人脸关键点数据 H3WB 2 下载方法 3 任务 4 评估 5 使用许可 3DFAW AFLW2000 3D 三 3D关键点的Z维度信息 1 基于3DMM模型的方法 2 H3WB 四 当前SOTA的方法 1
  • STM32串口下载

    使用FlyMCU下载程序 1 上电前 设置BOOT0 1 BOOT1 0 或者是在上电后 设置BOOT0 1 BOOT1 0之后 然后按一下复位按键 从而通过串口下载程序 2 在MDK编译加载生成的hex文件 并勾选右边的编程前重装文件 这
  • Unity进阶 - 动画系统 - Animations选项卡

    Unity进阶 动画系统 Animations选项卡 相关文章阅读 Unity 进阶 动画系统 Mecanim动画系统 Unity进阶 动画系统 给人物角色制作动画 Unity进阶 动画系统 人形动画的导入 Unity进阶 动画系统 导入设
  • 中国移动笔试有感

    被3号的中国移动笔试给深深地虐了 以前被像阿里阿这样的大企业虐就没啥子感觉 笔试完依旧是嘻嘻哈哈 像恒生这样的企业 笔试对我来说还是比较容易的虽然面试被刷了 说明还是需要多读书啊 但是中国移动的笔试 真的深深的激起了我学习的动力 我也不知道
  • C语言_带参宏和函数的区别及各自优缺点

    前言 C语言中 要想解决某子问题 可以自定义一个函数来专门处理该问题 比如 我想比较两个数的大小 那么我可以地定义一个函数max来完成两个数求最大值功能 但是 C语言中我们也可以通过宏定义来定义一个求最值的函数MAX 然后通过使用带参宏来完
  • 善待自己:改变命运的N个人生哲理

    心灵的栅栏 人与月亮的距离并不遥远 因为人与人心灵间的距离更为遥远 王尔德 当玛格丽特的丈夫杰瑞因脑瘤去世后 她变得异常愤怒 生活太不公平 她憎恨孤独 孀居 年 她的脸变得紧绷绷的 一天 玛格丽特在小镇拥挤的路上开车 忽然发现一幢她喜欢的房
  • 《软件测试的艺术》读后感 Or 读书笔记

    软件测试的艺术 读后感 Or 读书笔记 第一章 一次自评价测试 第二章 软件测试的心理学和经济学 第三章 代码检查 走查与评审 第四章 测试用例的设计 第五章 模块 单元 测试 第六章 更高级别的测试 第七章 可用性 或用户体验 测试 第八
  • Java—类的加载概述

    1 1 类的加载概述 当程序要使用某个类时 如果该类还未被加载到内存中 则系统会通过加载 连接 初始化三步来实现对这个类进行初始化 1 加载 是将class文件读入内存 并为之创建一个Class对象 任何类被使用时系统都会建立一个Class
  • Docker中安装Gitlab详细全教程

    前言 一 安装Gitlab 1 搜索影像 2 下载影像 3 启动Git服务 4 查看Gitlab是否已经启动 二 配置Gitlab 1 首先 先进入容器 2 修改gitlab rb文件 3 修改gitlab rb文件中的IP与端口号 3 配
  • OpenCV——求直线交点

    您可以使用OpenCV中的cv Point和cv Vec4i数据类型来表示点和直线 然后使用cv intersect函数来计算两条直线的交点 下面是一个示例代码 其中line1和line2分别表示两条直线的起点和终点 cv Point li
  • 机器学习(11)——时间序列分析

    目录 1 时间序列数据的相关检验 1 1 白噪声检验 1 2 平稳性检验 1 3 自相关分析和偏自相关分析 2 移动平均算法 2 1 简单移动平均法 2 2 简单指数平滑法 2 3 霍尔特线性趋势法 2 4 Holt Winters 季节性
  • Centos7安装dig命令

    2019独角兽企业重金招聘Python工程师标准 gt gt gt Centos7安装dig命令 作者 jwj 时间 2018 10 17 分类 服务器 最近做一个项目 需要用到Gmail邮箱发送邮件 但发现发送不出去 排查问题时 需要用到
  • 最新SecureCRT 中文注册版

    SecureCRT是一款由VanDyke Software公司开发的终端仿真软件 它提供了类似于Telnet和SSH等协议的远程访问功能 SecureCRT专门为网络管理员 系统管理员和其他需要保密访问网络设备的用户设计 软件下载 Secu
  • filter IE滤镜(Internet Explorer)CSS

    http justcoding iteye com blog 940184 概述 CSS滤镜虽然只能在IE浏览器中表现出效果 但是仍不失为网页增加特效的好办法 1 CSS静态滤镜样式 filter CSS静态滤镜样式的使用方法 filter
  • PlatformIO基于ESP32S2的SPI软串口LCD屏调试

    文章目录 VSCode PlatformIO Arduino ESP32S2 SPI LCD 320 240 一 准备工作 二 测试 1 全屏检测 2 图形测试 参考资料 VSCode PlatformIO Arduino ESP32S2