Paint Program for TFT v2 screen ~ 10 colors ~ 5 brushes

I had modified Adafruit’s paint program for arduino TFT screens last year.
When I got the new upgrade TFT screen (version-2) from Seeed Studios last week, the programs I had written
needed retrofitting and new libraries.
It didn’t take me long to figure out the needed changes, without documentation…
So, I decided to share the Arduino code with other experimenters using Seed Studios TFT screens.
Its got a 10 color palette, and 5 brush thicknesses.
You can really make some detailed graphical images using this.
If you want to “erase” any pixels, just choose the color -Black, and paint them out of sight.
Hope you have as much fun as I did doing this.
Enjoy.

Black
Gray 2
Gray 1
White
Yellow
Light Blue
Blue
Green
Red
Magenta

1,2,4,7,11 - pixels thick brushes- (brush 1,2,3,4,5)

When program loads, you must pick a brush thickness (1,2,3,4,5) before any drawing happens.
The color White is loaded by default.
Use a small stylus such as a toothpick or other non abrasive point to draw with.
Girls with finger nails can do Ok themselves.

IMAG0245.jpg

Arduino code below



//START OF PROGRAM CODE

// Rusty’s Mini-Paint - 1.4

// Revision 1.4 — 5 variable thickness strokes + 2 added colors ---- by CircuitBurner ---- 7/25/14

// LATEST REVISION FOR USING SEEED STUDIOS TFT V-2 SCREEN

#include <stdint.h>
#include <TouchScreen.h>
#include <TFTv2.h>
#include <SPI.h>

unsigned int TS2_MINX, TS2_MAXX, TS2_MINY, TS2_MAXY;
unsigned int MapX1, MapX2, MapY1, MapY2;
unsigned int s;
TouchScreen ts = TouchScreen(17, A2, A1, 14, 300);
int color = WHITE;
void setup()
{
Tft.TFTinit();
initTouchScreenParameters();
Tft.fillRectangle(0,0,15,20,BRIGHT_RED);
Tft.fillRectangle(15,0,15,20,RED);
Tft.fillRectangle(30,0,15,20,GREEN);
Tft.fillRectangle(45,0,15,20,BLUE);
Tft.fillRectangle(60,0,15,20,CYAN);
Tft.fillRectangle(75,0,15,20,YELLOW);
Tft.fillRectangle(90,0,15,20,WHITE);
Tft.fillRectangle(105,0,15,20,GRAY1);
Tft.fillRectangle(120,0,15,20,GRAY2);
Tft.fillRectangle(135,0,15,20,BLACK);
Tft.drawRectangle(156,0,17,20,BRIGHT_RED);
Tft.drawRectangle(173,0,17,20,BRIGHT_RED);
Tft.drawRectangle(190,0,17,20,BRIGHT_RED);
Tft.drawRectangle(207,0,17,20,BRIGHT_RED);
Tft.drawRectangle(224,0,17,20,BRIGHT_RED);
Tft.drawRectangle(0,0,150,20,GRAY2);
}
void loop()
{
;Point p = ts.getPoint();
if (p.z > ts.pressureThreshhold) {
p.x = map(p.x, TS2_MINX, TS2_MAXX, MapX1, MapX2);
p.y = map(p.y, TS2_MINY, TS2_MAXY, MapY1, MapY2);
if(p.y < 20)
{if(p.x >= 0 && p.x < 15)
{color = BRIGHT_RED;}
if(p.x >= 16 && p.x < 30)
{color = RED;
}if(p.x >= 31 && p.x < 45)
{color = GREEN;}
if(p.x >= 46 && p.x < 60)
{color = BLUE;}
if(p.x >= 61 && p.x < 75)
{color = CYAN;}
if(p.x >= 76 && p.x < 90)
{color = YELLOW;}
if(p.x >= 91 && p.x < 105)
{color = WHITE;}
if(p.x >= 106 && p.x < 120)
{color = GRAY1;}
if(p.x >= 121 && p.x < 135)
{color = GRAY2;}
if(p.x >= 136 && p.x < 150)
{color = BLACK;}
if(p.x >= 156 && p.x < 173)
{s = 11;}
if(p.x >= 172 && p.x < 189)
{s = 7;}
if(p.x >= 190 && p.x < 207)
{s = 4;}
if(p.x >= 208 && p.x < 225)
{s = 2;}
if(p.x >= 226 && p.x < 243)
{s = 1;}
}
else
{

Tft.fillCircle(p.x,p.y,s,color);
    }
  }
}

void initTouchScreenParameters()
{

//if(Tft.IC_CODE == 0x5408)
{
#if defined(AVR_ATmega1280) || defined(AVR_ATmega2560)
ts = TouchScreen(54, A1, A2, 57, 300);
#else
ts = TouchScreen(14, A1, A2, 17, 300);
#endif
TS2_MINX = 120;
TS2_MAXX = 910;
TS2_MINY = 120;
TS2_MAXY = 950;

MapX1 = 239;
MapX2 = 0;
MapY1 = 0;
MapY2 = 319;
  }
//  else   {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ts = TouchScreen(57, A2, A1, 54, 300);
#else
ts = TouchScreen(17, A2, A1, 14, 300);
#endif
 Tft.drawString("Rusty's Mini-Paint v1.4",98,308,1,BLUE);
 Tft.drawString("Rusty's Mini-Paint v1.4",101,309,1,WHITE);
 Tft.drawString("5",160,7,1,BLUE);
 Tft.drawString("5",162,8,1,YELLOW);
 Tft.drawString("4",177,7,1,BLUE);
 Tft.drawString("4",179,8,1,YELLOW);
 Tft.drawString("3",195,7,1,BLUE);
 Tft.drawString("3",197,8,1,YELLOW);
 Tft.drawString("2",211,7,1,BLUE);
 Tft.drawString("2",213,8,1,YELLOW);
 Tft.drawString("1",227,7,1,BLUE);
 Tft.drawString("1",229,8,1,YELLOW);
 TS2_MINX = 140;
 TS2_MAXX = 900;
 TS2_MINY = 120;
 TS2_MAXY = 940;
 MapX1 = 239;
 MapX2 = 0;
 MapY1 = 319;
 MapY2 = 0;}

//END OF PROGRAM CODE

Very cool, Thank you!!

You seem to know quite a bit about this TFT sheild. If i make a bunch of menu buttons is there anyway to get an interrupt with this shield? The ADAfruit sheild has an interrupt pin available. I cant find where anyone has talked about interrupts with this seeed tft V2.