void...

I tryed to loop the paint example but after loading it returns. draw something issnt possible.
can someone tell me my fault?

void PAINT(){
  CLEAR();
#define BOXSIZE 40
#define PENRADIUS 0
  int currentcolor; 
  // make the color selection boxes
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
  tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  tft.setTextColor(ILI9341_WHITE);   
  tft.setTextSize(1);
  tft.setCursor(165,17); 
  tft.println("reset");
  tft.setCursor(209,17); 
  tft.println("EXIT");
  delay(2000);

  // select the current color 'red'
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  currentcolor = ILI9341_RED;
  Paint();
  TEST = 0;
}
void Paint(){
  if (TEST =0);{
   /* if (ts.bufferEmpty()) {
      Serial.println("return 1");
      TEST = 0;
      return;
    }
     */
  // You can also wait for a touch
     if (! ts.touched()) {
     return;TEST = 0;
     }
    
    TS_Point p = ts.getPoint();
    p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
    p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());

    if (p.y < BOXSIZE) {

      if (p.x < BOXSIZE) { 
        currentcolor = ILI9341_RED; 
        tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
        tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
      } 
      else if (p.x < BOXSIZE*2) {
        currentcolor = ILI9341_YELLOW;
        tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
        tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
      } 
      else if (p.x < BOXSIZE*3) {
        currentcolor = ILI9341_GREEN;
        tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
        tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
      } 
      else if (p.x < BOXSIZE*4) {
        currentcolor = ILI9341_BLUE;
        tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
        tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
      } 
      else if (p.x < BOXSIZE*5) {
        CLEAR();
        tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
        tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
        tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
        tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
        tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLACK);
        tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_BLACK);
        tft.setTextColor(ILI9341_WHITE);   
        tft.setTextSize(1);
        tft.setCursor(165,10); 
        tft.println("reset");  
        tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
        currentcolor = ILI9341_RED;     
      } 
      else if (p.x < BOXSIZE*6) {
        TEST=1;
      }

    }
    if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
      tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
    }

 
  return;} 
}

Probably not a good idea to have a PAINT() and paint() function, but in paint() you have a semicolon after the if statement.

Your thread title says it all to me. You don't have any voids in your code you have void functions. All that means is that they do not return any values when they are called. Can I suggest that you do some reading on the use of functions ?

Now onto other things. Having 2 functions with virtually the same name PAINT() and Paint() is nor a good idea. At best it is confusing and the names give no clue as to what the functions do.

Now a specific problem.

  if (TEST =0);

This line of code is intended to check whether the variable TEST is equal to zero, but instead it sets it to zero. To make things worse you have ended the line with a semi-colon which means that even if the check is written properly then no code will be executed whether the result of the check is true or false. I suggest that you read up on use of the if command too,

yea... but i had no idea to solve this another way... the semicolon .. didnt change the result

Have you fixed the other problem with

  if (TEST =0);

hey ukhelibob. i'm using the voids because i have over a hundred of different things to do in this sketch. PAINT and Paint could be one, but the check on the touch definitly wont work this way, so i split it. and yes if (TEST ==0){....} hard to code after 20h awake... and 3h to go

Despite what you say you have no voids in your program. However, there may be a few holes.....

Post the whole program so that we can see what you are doing, or trying to do.

Stop calling them voids, it marks you out as not having a clue what you are doing. They are not voids, they are functions that return no value. Badly written functions at that with multiple exit points.

the hole program has over 3000 lines…

the target is to use the touchpaint example, reset it and have a button to get beck to the void loop () .

grumpy: i’m not a computer scientist. sorry for that.

touchpaint example:

#include <Adafruit_GFX.h>    // Core graphics library
#include <SPI.h>
#include <Wire.h>      // this is needed even tho we aren't using it
#include <Adafruit_ILI9341.h>
#include <Adafruit_STMPE610.h>

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 550
#define TS_MINY 410
#define TS_MAXX 3600
#define TS_MAXY 3700

// The STMPE610 uses hardware SPI on the shield, and #8
#define STMPE_CS 8
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);

// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 10
#define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define PENRADIUS 0
int oldcolor, currentcolor;

void setup(void) {
 // while (!Serial);     // used for leonardo debugging
 
  Serial.begin(9600);
  Serial.println(F("Touch Paint!"));
  
  tft.begin();

  if (!ts.begin()) {
    Serial.println("Couldn't start touchscreen controller");
    while (1);
  }
  Serial.println("Touchscreen started");
  
  tft.fillScreen(ILI9341_BLACK);
  
  // make the color selection boxes
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
 
  // select the current color 'red'
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  currentcolor = ILI9341_RED;
}


void loop()
{
  // See if there's any  touch data for us
  if (ts.bufferEmpty()) {
    return;
  }
  /*
  // You can also wait for a touch
  if (! ts.touched()) {
    return;
  }
  */

  // Retrieve a point  
  TS_Point p = ts.getPoint();
  

  Serial.print("X = "); Serial.print(p.x);
  Serial.print("\tY = "); Serial.print(p.y);
  Serial.print("\tPressure = "); Serial.println(p.z);  
 
  // Scale from ~0->4000 to tft.width using the calibration #'s
  p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
  p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());


  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 = ILI9341_RED; 
       tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*2) {
       currentcolor = ILI9341_YELLOW;
       tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*3) {
       currentcolor = ILI9341_GREEN;
       tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*4) {
       currentcolor = ILI9341_CYAN;
       tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*5) {
       currentcolor = ILI9341_BLUE;
       tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*6) {
       currentcolor = ILI9341_MAGENTA;
       tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     }

     if (oldcolor != currentcolor) {
        if (oldcolor == ILI9341_RED) 
          tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
        if (oldcolor == ILI9341_YELLOW) 
          tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
        if (oldcolor == ILI9341_GREEN) 
          tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
        if (oldcolor == ILI9341_CYAN) 
          tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
        if (oldcolor == ILI9341_BLUE) 
          tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
        if (oldcolor == ILI9341_MAGENTA) 
          tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
     }
  }
  if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
    tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
  }
}

CanDo: void loop ()

You nearly had it that time, but it's still not quite right. Come on. You know you want to. It's not the void anything, it's the loop() function. Just call it that once and you will feel so much better. Maybe next time.

Now, what is that program supposed to do and what does it actually do ? Do you want a way of clearing the screen and starting all over again or something else ?

the hole program has over 3000 lines..

I bet the whole program has as well. :) ( I am dyslexic so I am allowed to make spelling jokes )

You can put the program as an attachment using the additional options triangle at the bottom left side of the reply box. Then we can compile it and see what we get.

I tryed to loop the paint example but after loading it returns. draw something issnt possible.

From the original post it sounds like you have a compile problem, probable due to a missing library, so please give a link to the libraries you have downloaded an installed for this code. I suspect that you get this message not after loading but during loading, but it is only a guess without seeing the code.

ok... reset.

My program is build up this style.

-librarys -definition of variables -setup void -void loop - a lot of void XYZ funktions called in the loop.

target is to recreate the touchpaint example as a void xyz funktion. features should be to -reset paint -exit by pushing exit.

CanDo: ok... reset.

My program is build up this style.

-librarys -definition of variables -setup void -void loop - a lot of void XYZ funktions called in the loop.

target is to recreate the touchpaint example as a void xyz funktion. features should be to -reset paint -exit by pushing exit.

Yes, and . . . ?

@CanDo I think you chose the wrong name, I think you should be called Won'tDo.

Solved. did it myself without the example. works the way it should 8)