void Serialread()
{

  char c ;
int xt, yt;
  int x1, y1;
  bool ter = 0;
  x1 = 30;
  y1 = 40;

  myGLCD.fillScr(0, 0, 0);
  //  myGLCD.fillScr(BIRD_BG);
  myGLCD.setColor(VGA_WHITE);
  myGLCD.setBackColor(VGA_BLACK);
  myGLCD.setFont(BigFont);
  myGLCD.print("SERIAL 9600", CENTER, 10);
  myGLCD.setColor(0, 0, 255);

  myGLCD.fillRect(20, 30, 390, 450); //1 ter
  myGLCD.fillRect(410, 30, 780, 450); //2 ter
  myGLCD.setColor(VGA_WHITE);
  myGLCD.drawRect(25, 35, 385, 445);//1ter obv
  myGLCD.drawRect(415, 35, 775, 445);//2 ter obv
  myGLCD.setBackColor(0, 0, 255);
  digitalWrite(18, LOW);
  delay(3000);
  digitalWrite(18, HIGH);//reset WIFI
  myGLCD.print("    reset     " , 280, 457);
  delay(5000);
  myGLCD.print("    redy    " , 280, 457);
  while (1)
  {
    //***********  T  O  U  C  H  ********************
    if (myTouch.dataAvailable())
    { //myGLCD.fillScr(0, 0, 0);
      myTouch.read();
      xt = myTouch.getX();
      yt = myTouch.getY();
      // Serial.print("xt=");
      // Serial.println(xt);
      // Serial.print("yt=");
      //  Serial.println(yt);
      myGLCD.drawPixel(xt, yt);
      if ((xt >= 600) && (xt <= 800)) // Upper row
      { if ((yt >= 0) && (yt <= 30)) menu(); // Exit
        if ((yt >= 50) && (yt <= 150))
        { Serial2.print("7"); // Exit
          myGLCD.print("   touch 7    " , 280, 457);
          delay(1000);
        }
        if ((yt >= 200) && (yt < 300))
        { Serial2.print("1");; // Exit
          myGLCD.print("   touch 1    " , 280, 457);
          delay(1000);
        }
        if ((yt >= 350) && (yt < 400))
        { Serial2.print("2");; // Exit
          myGLCD.print("   touch 2    " , 280, 457);
          delay(1000);
        }
      }
      if ((xt >= 0) && (xt <= 100)) // Upper row
      { //if ((yt >= 0) && (yt <= 30)) menu(); // Exit
        if ((yt >= 50) && (yt <= 150))
        { //Serial2.print("7");; // Exit
          digitalWrite(18, LOW);
          delay(3000);
          digitalWrite(18, HIGH);//reset WIFI
          myGLCD.print("    reset     " , 280, 457);
          //delay(5000);
        }
        if ((yt >= 200) && (yt < 300))
        {
          myGLCD.print("   touch     " , 280, 457);
        }
        if ((yt >= 350) && (yt < 400))
        {
          myGLCD.print("   touch     " , 280, 457);
        }
      }



    }
    //delay(500);
    if (Serial2.available()) {

      c = Serial2.read();

      if (c == '\r')
      {

      }
      else if (c == '\n')
      { y1 = y1 + 20;

        if (y1 > 430)
        { y1 = 40;
          if (ter == 0)
          { myGLCD.setColor(0, 0, 255);
            myGLCD.fillRect(410, 30, 780, 450); //2 ter
            myGLCD.setColor(VGA_WHITE);
            myGLCD.drawRect(415, 35, 775, 445);
            // myGLCD.print(String(c) ,420, y1);
          }
          else
          { myGLCD.setColor(0, 0, 255);
            myGLCD.fillRect(20, 30, 390, 450); //1 ter
            myGLCD.setColor(VGA_WHITE);
            myGLCD.drawRect(25, 35, 385, 445);//1ter obv
            // myGLCD.print(String(c) ,30, 40);
          }
          ter = !ter;
        }
        if (ter == 0)x1 = 30;
        if (ter == 1)x1 = 420;
      }
      else
      { myGLCD.print(String(c) , x1, y1);
        x1 = x1 + 15;
        if (ter == 0)
        { if (x1 > 365)
          { x1 = 30;
            y1 = y1 + 20;
          }
          if (y1 > 430)
          { y1 = 40;
            myGLCD.setColor(0, 0, 255);
            myGLCD.fillRect(410, 30, 780, 450); //2 ter
            myGLCD.setColor(VGA_WHITE);
            myGLCD.drawRect(415, 35, 775, 445);
            ter = 1;
            //myGLCD.print(String(c) ,420, y1);
            x1 = 420;
          }


        }
        else
        { if (x1 > 755)
          { x1 = 420;
            y1 = y1 + 20;
          }
          if (y1 > 430)
          { y1 = 40;
            myGLCD.setColor(0, 0, 255);
            myGLCD.fillRect(20, 30, 390, 450); //1 ter
            myGLCD.setColor(VGA_WHITE);
            myGLCD.drawRect(25, 35, 385, 445);//1ter obv
            ter = 0;
            // myGLCD.print(String(c) ,30, y1);
            x1 = 30;
          }


        }
      }
    }
  }
}
