Really improved the paint program enough to draw some seriously detailed paintings.
But last night, since acquiring 2 UNOs to play with, noticed the paint sketch (mini-paint 1.3 nor the old original one) would not load on the uno.
So like always, I become temporarily obsessed with a fix.
No biggie, took no time, simple task.
But I like the size of these UNOs when TFT screen is used as the whole assembly is much lighter and compact with the MC board hardly even the size of the TFT module. Feels light and simple in the hand.
Thinking about it some more, I realized I hadnt shared it much except long time ago at sparkfun , and had never shared the UNO solution to the TFT issue because -well- I just fixed it up.
So before I forget, Im posting this before work here so Arduino mega users and now Uno users with a 2.8 TFT touch screen can play with the best paint proggy out there so far for these things!
Enjoy!
Rusty's Mini-Paint v1.3 (for Mega 1280 or 2560)
Code: Select all
// 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;}}
Rusty's Mini-Paint v1.3 (for Arduino UNO)
Code: Select all
// 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);//~~~~for Arduino MEGA 2650
// #else
ts = TouchScreen(14, A1, A2, 17, 300); //~~~~for Arduino UNO
// #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); //~~~~for Arduino MEGA 2650
// #else
ts = TouchScreen(17, A2, A1, 14, 300); //~~~~for Arduino UNO
// #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;}}