Code check requested pls

Hi
Pls help me check code & fix error(s) Thx

// Paint example specifically for the TFTLCD breakout board.
// If using the Arduino shield, use the tftpaint_shield.pde sketch instead!
// DOES NOT CURRENTLY WORK ON ARDUINO LEONARDO
//Technical support:goodtft@163.com

#include <Elegoo_GFX.h>    // Core graphics library
#include <Elegoo_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>
#include <EEPROM.h>
#if defined(__SAM3X8E__)
    #undef __FlashStringHelper::F(string_literal)
    #define F(string_literal) string_literal
#endif

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
//   D0 connects to digital pin 8  (Notice these are
//   D1 connects to digital pin 9   NOT in order!)
//   D2 connects to digital pin 2
//   D3 connects to digital pin 3
//   D4 connects to digital pin 4
//   D5 connects to digital pin 5
//   D6 connects to digital pin 6
//   D7 connects to digital pin 7

// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
//   D0 connects to digital pin 22
//   D1 connects to digital pin 23
//   D2 connects to digital pin 24
//   D3 connects to digital pin 25
//   D4 connects to digital pin 26
//   D5 connects to digital pin 27
//   D6 connects to digital pin 28
//   D7 connects to digital pin 29

// For the Arduino Due, use digital pins 33 through 40
// (on the 2-row header at the end of the board).
//   D0 connects to digital pin 33
//   D1 connects to digital pin 34
//   D2 connects to digital pin 35
//   D3 connects to digital pin 36
//   D4 connects to digital pin 37
//   D5 connects to digital pin 38
//   D6 connects to digital pin 39
//   D7 connects to digital pin 40
/*
#define YP 9  // must be an analog pin, use "An" notation!
#define XM 8  // must be an analog pin, use "An" notation!
#define YM A2   // can be a digital pin
#define XP A3   // can be a digital pin
*/

#define YP A3  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 9   // can be a digital pin
#define XP 8   // can be a digital pin
/*
#define TS_MINX 50
#define TS_MAXX 920

#define TS_MINY 100
#define TS_MAXY 940
*/
//Touch For New ILI9341 TP
#define TS_MINX 120
#define TS_MAXX 900

#define TS_MINY 70
#define TS_MAXY 920

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
// optional
#define LCD_RESET A4

// Assign human-readable names to some common 16-bit color values:
#define DARKBLUE 0x0010
#define VIOLET 0x8888
#define RED     0xF800//
#define GREEN   0x07E0//
#define CYAN    0x07FF//
#define MAGENTA 0xF81F//
#define YELLOW  0xFFE0//
#define WHITE   0xFFFF//
#define GREY   0x7777//
#define Black 0x0000
#define GOLD 0xFEA0//
#define BROWN 0xA145//
#define SILVER 0xC618//
#define BLACK 0x0000
#define LIME 0x07E0//
#define ORANGE 0xFD20//
#define ORANGERED 0xFA20//


Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define BOXSIZE 18
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
  //byte txt = "About Arduino :What is Arduino?Arduino designs, manufactures, and supports electronic devices and software, allowing people around the world to easily access advanced technologies that interact with the physical world. Our products are straightforward, simple, and powerful, ready to satisfy users’ needs from students to makers and all the way to professional developers.Our Mission & VisionArduino’s mission is to enable anyone to enhance their lives through accessible electronics and digital technologies. There was once a barrier between the electronics, design, and programming world and the rest of the world. Arduino has broken down that barrier.Over the years, our products have been the brains behind thousands of projects, from everyday objects to complex scientific instruments. A worldwide community, comprising students, hobbyists, artists, programmers, and professionals, has gathered around this open-source platform, their contributions adding up to an incredible amount of accessible knowledge.Our vision is to make Arduino available to everyone, whether you are a student, maker or professional, which is why we now have three segments to our business. These segments work together as an ecosystem with a shared mindset: we started with Maker, and that has evolved into Education and PRO solutions.Find creative solutions to everyday challengesFor makers around the world, our goal is to democratize the most advanced technologies and create a new set of opportunities for creative people, whether that’s through connected products, advanced sensors, Cloud & Apps, machine learning, AI, etc.Arduino empowers creative minds to master technology and intuitively solve everyday problems. Our platform simplifies the use of otherwise complex tools. For example, programming a securely connected IoT device is just a few clicks away with the use of the Arduino Cloud.Empower the next generations of students to be the disruptors of the futureFor middle school, high school, and university educators who want to deliver relevant, fun, and creative STEAM lessons that enable all students to thrive, Arduino Education’s open-source approach and cross-curriculum content are essential tools that develop and empower students as they progress through their STEAM education.Our classroom programs include kits, bundles, and boards with project-based learning paths for individual and collaborative educational approaches. Teaching remotely? We have kits designed for remote, individual learning, making hands-on STEAM education accessible even when the classroom isn’t.Enable businesses of any size to exploit the potential of AI and IoT.The PRO line is designed to enable businesses to quickly and securely connect remote sensors to business logic within one simple IoT application development platform, transferring the productivity and creativity that makers enjoy with Arduino into the business world.We aim to help companies transform their business models with IoT, providing robust, hackable, and understandable IoT hardware and SaaS platforms.Arduino can support the full development, production, and operation lifecycle, from hardware and firmware to low code, Cloud, and mobile apps.The Arduino Team:Founders:Massimo Banzi, Co-founder, CMO & Chairman.Massimo Banzi.";

  Serial.begin(9600);
  Serial.println(F("Paint!"));
  
  tft.reset();
  
  uint16_t identifier = tft.readID();
  if(identifier == 0x9325) {
    Serial.println(F("Found ILI9325 LCD driver"));
  } else if(identifier == 0x9328) {
    Serial.println(F("Found ILI9328 LCD driver"));
  } else if(identifier == 0x4535) {
    Serial.println(F("Found LGDP4535 LCD driver"));
  }else if(identifier == 0x7575) {
    Serial.println(F("Found HX8347G LCD driver"));
  } else if(identifier == 0x9341) {
    Serial.println(F("Found ILI9341 LCD driver"));
  } else if(identifier == 0x8357) {
    Serial.println(F("Found HX8357D LCD driver"));
  } else if(identifier==0x0101)
  {     
      identifier=0x9341;
       Serial.println(F("Found 0x9341 LCD driver"));
  }else {
    Serial.print(F("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    Serial.println(F("If using the Elegoo 2.8\" TFT Arduino shield, the line:"));
    Serial.println(F("  #define USE_Elegoo_SHIELD_PINOUT"));
    Serial.println(F("should appear in the library header (Elegoo_TFT.h)."));
    Serial.println(F("If using the breakout board, it should NOT be #defined!"));
    Serial.println(F("Also if using the breakout, double-check that all wiring"));
    Serial.println(F("matches the tutorial."));
    identifier=0x9341;
   
  }

  tft.begin(identifier);
  tft.setRotation(2);

  tft.fillScreen(BLACK);
//  tft.fillRoundRect(0,0,BOXSIZE,BOXSIZE,RED);
}
void loop(){}
  ///*
  drawbx(24.9);
  //TFT.drawRect
  currentcolor = ORANGERED;
  //tft.invertDisplay(true);
//  pinMode( 13, OUTPUT);

  
}

#define MINPRESSURE 10
#define MAXPRESSURE 1000

void loop()
{
  //digitalWrite(13, HIGH);
  TSPoint p = ts.getPoint();
  //digitalWrite(13, LOW);

  // if sharing pins, you'll need to fix the directions of the touchscreen pins
  //pinMode(XP, OUTPUT);
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //pinMode(YM, OUTPUT);

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
    /
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
   
    
    if (p.y < (TS_MINY-5)) {
      Serial.println("erase");
      // press the bottom of the screen to erase 
      tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
    }
    // scale from 0->1023 to tft.width
    p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    //p.x = tft.width()-map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    p.y = (tft.height()-map(p.y, TS_MINY, TS_MAXY, tft.height(), 0));
     //p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
    
    Serial.print("("); Serial.print(p.x);
    Serial.print(", "); Serial.print(p.y);
    Serial.println(")");
   
    if (p.y < BOXSIZE) {
       oldcolor = currentcolor;

       if (p.x < BOXSIZE) { 
         currentcolor = RED; 
         tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*2) {
         currentcolor = YELLOW;
         tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*3) {
         currentcolor = GREEN;
         tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*4) {
         currentcolor = CYAN;
         tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*5) {
         currentcolor = DARKBLUE;
         tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*6) {
        currentcolor = MAGENTA;
         tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*7){
        tft.drawRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, VIOLET);
        currentcolor = BLACK;
       }else if(p.x < BOXSIZE*8){
        currentcolor=BROWN;
         tft.drawRect(BOXSIZE*7,0, BOXSIZE, BOXSIZE, WHITE);
       }else if(p.x < BOXSIZE*9){
        currentcolor=LIME;
        tft.drawRect(BOXSIZE*8,0, BOXSIZE, BOXSIZE, WHITE);
        //writeEeprom(1, currentcolor+oldcolor+tft.width()+tft.height()+tft.readID()+tft.read()), WHITE);
       }else if(p.x < BOXSIZE*10){
        currentcolor=GREY;
        tft.drawRect(BOXSIZE*9,0, BOXSIZE, BOXSIZE, WHITE);
       }else if(p.x < BOXSIZE*11){
        currentcolor=LIME;
        tft.drawRect(BOXSIZE*10,0, BOXSIZE, BOXSIZE, WHITE);
       }else if(p.x < BOXSIZE*12){
        currentcolor=ORANGE;
        tft.drawRect(BOXSIZE*11,0, BOXSIZE, BOXSIZE, WHITE);
       }else if(p.x < BOXSIZE*12){
        //byte txt = "About Arduino :What is Arduino?Arduino designs, manufactures, and supports electronic devices and software, allowing people around the world to easily access advanced technologies that interact with the physical world. Our products are straightforward, simple, and powerful, ready to satisfy users’ needs from students to makers and all the way to professional developers.Our Mission & VisionArduino’s mission is to enable anyone to enhance their lives through accessible electronics and digital technologies. There was once a barrier between the electronics, design, and programming world and the rest of the world. Arduino has broken down that barrier.Over the years, our products have been the brains behind thousands of projects, from everyday objects to complex scientific instruments. A worldwide community, comprising students, hobbyists, artists, programmers, and professionals, has gathered around this open-source platform, their contributions adding up to an incredible amount of accessible knowledge.Our vision is to make Arduino available to everyone, whether you are a student, maker or professional, which is why we now have three segments to our business. These segments work together as an ecosystem with a shared mindset: we started with Maker, and that has evolved into Education and PRO solutions.Find creative solutions to everyday challengesFor makers around the world, our goal is to democratize the most advanced technologies and create a new set of opportunities for creative people, whether that’s through connected products, advanced sensors, Cloud & Apps, machine learning, AI, etc.Arduino empowers creative minds to master technology and intuitively solve everyday problems. Our platform simplifies the use of otherwise complex tools. For example, programming a securely connected IoT device is just a few clicks away with the use of the Arduino Cloud.Empower the next generations of students to be the disruptors of the futureFor middle school, high school, and university educators who want to deliver relevant, fun, and creative STEAM lessons that enable all students to thrive, Arduino Education’s open-source approach and cross-curriculum content are essential tools that develop and empower students as they progress through their STEAM education.Our classroom programs include kits, bundles, and boards with project-based learning paths for individual and collaborative educational approaches. Teaching remotely? We have kits designed for remote, individual learning, making hands-on STEAM education accessible even when the classroom isn’t.Enable businesses of any size to exploit the potential of AI and IoT.The PRO line is designed to enable businesses to quickly and securely connect remote sensors to business logic within one simple IoT application development platform, transferring the productivity and creativity that makers enjoy with Arduino into the business world.We aim to help companies transform their business models with IoT, providing robust, hackable, and understandable IoT hardware and SaaS platforms.Arduino can support the full development, production, and operation lifecycle, from hardware and firmware to low code, Cloud, and mobile apps.The Arduino Team:Founders:Massimo Banzi, Co-founder, CMO & Chairman.Massimo Banzi.";

        
       }else if(p.x < BOXSIZE*13){
        currentcolor=LIME;
        tft.drawRect(BOXSIZE*12,0, BOXSIZE, BOXSIZE, WHITE);
        tft.fillScreen(Black);
        drawbx();
        }
       
       

       if (oldcolor != currentcolor) {
          if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
          if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
          if (oldcolor == GREEN) tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
          if (oldcolor == CYAN) tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
          if (oldcolor == DARKBLUE) tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, DARKBLUE);
          if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
          if (oldcolor == WHITE) tft.fillRect(BOXSIZE*6,0,BOXSIZE,BOXSIZE,WHITE);
       }
    }
    if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
      tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
    }
  }
}
void writeEeprom(int address, byte* data, byte oldclr){
  EEPROM.write(address, data);
  delay(10);
  tft.setTextColor(WHITE);
  tft.print("Saving to EEPROM...Buffer Full...Readtest start...");
  if(EEPROM.read(address) == data){
    tft.print("Pass!Write OK!Test 2 start...");
    byte app = EEPROM.read(address);
    if (app == data){
      tft.print("OK!");
    }
    else{
      tft.print("FAIL!");
      while(1){}
    }
  }
  else{
    tft.print("Fail. Revert in 3.2.1.");
    delay(3000);
    tft.invertDisplay(true);
    
  }
}
void drawbx(int a){
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, DARKBLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
   tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, 0xFFFF);
 tft.fillRect(BOXSIZE*7,0,BOXSIZE,BOXSIZE, BROWN);
  tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
  tft.fillRect(BOXSIZE*8,0,BOXSIZE,BOXSIZE, GREY);
  tft.fillRect(BOXSIZE*9,0,BOXSIZE,BOXSIZE, SILVER);
  tft.fillRect(BOXSIZE*10,0,BOXSIZE,BOXSIZE, LIME);
  tft.fillRect(BOXSIZE*11,0,BOXSIZE,BOXSIZE, ORANGE);
  tft.fillRect(BOXSIZE*12,0,BOXSIZE,BOXSIZE, Black);
  
}
//NodeMCU
void readBk(char* text, int i){
  tft.fillScreen(BLACK);
  tft.setCursor(0,0);
  tft.setTextSize(i);
  tft.print(text);
}
*/

Error(s);

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"





















tftpaint:156:9: error: expected constructor, destructor, or type conversion before '(' token

   drawbx(24.9);

         ^

tftpaint:158:3: error: 'currentcolor' does not name a type

   currentcolor = ORANGERED;

   ^~~~~~~~~~~~

tftpaint:163:1: error: expected declaration before '}' token

 }

 ^

exit status 1

expected constructor, destructor, or type conversion before '(' token



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Two void loops.
What happens if you comment the first one out.

If you enable line numbering (in preferences), then you can see where the problems are.
(line 156, 158 and 163)
Leo..

The LED doesn’t blink for me either !

what happens if "tft" was put in front of drawbox(24.9)? Like tft.drawbox(3453);.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.