Mini-Paint v1.3

Worked on the paint program some today, pushed it up a notch.

Now we have 2 added colors to complete the palette, and one more brush thickness to round out

a 5-brush set.

Added BRIGHT_RED to palette (Pink)

Added GREY2 to palette (darker grey)

streamlined the flow a little bit, cleaned house.

Ability for even finer detailed paintings is now possible.

Suggested that a stylus made from toothpick or similar semi-sharp non-scratching object

be used, as blunt objects or fingers are now too clumsy for the smaller buttons and details.

**Next revision FAT storage option for SD shields for harvesting your image.

Enjoy

// Mini-Paint
// Revision 1.3 --- 5 - variable thickness strokes + 2 added colors ---- by CircuitBurner ---- 3/25/13

#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
static unsigned int TS_MINX, TS_MAXX, TS_MINY, TS_MAXY;
static unsigned int MapX1, MapX2, MapY1, MapY2;
static unsigned int s;
TouchScreen ts = TouchScreen(17, A2, A1, 14, 300);
int color = WHITE;
void setup()
{
  Tft.init();
  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, TS_MINX, TS_MAXX, MapX1, MapX2);
    p.y = map(p.y, TS_MINY, TS_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
TS_MINX = 120;
TS_MAXX = 910;
TS_MINY = 120;
TS_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("Mini-Paint v1.3",118,308,1,BLUE);
Tft.drawString("Mini-Paint v1.3",120,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);
 TS_MINX = 140;
 TS_MAXX = 900;
 TS_MINY = 120;
 TS_MAXY = 940;
 MapX1 = 239;
 MapX2 = 0;
 MapY1 = 319;
 MapY2 = 0;}}