Pages: [1]   Go Down
Author Topic: TFT von SaintSmart ansteuerung  (Read 2911 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hallo ich bin Marko und habe mir ein Mega 2560 Budel gekauft
SainSmart Mega2560+3.2"TFT Touch LCD.SD Reader+Expansion Board 4 Arduino R3 1280

nun hab ich einige test gemacht nur bekomme ich das TFT 3,2" nicht zum laufen wie kann ich testen ob es funktioniert da ich noch neu in der materie bin kann mir dazu jemand helfen?

habe mir zum Testen von http://henningkarlsen.com die TFT Touch geladen nur bringt er mir ständige fehler beim hochladen

lg

marko

Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
nur bringt er mir ständige fehler beim hochladen

Verratest Du uns die Fehlermeldungen? Welchen Sketch verwendest Du (bitte beim posten die Code-Tags [#-Knopf im Formular] verwenden)?
Logged

Forum Moderator
BZ (I)
Offline Offline
Brattain Member
*****
Karma: 262
Posts: 21578
+39 349 2158303
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Einen Link auf eine nicht öffentliche Internetseite (fragt nach Zugangsdaten) ist auch wenig hilfreich für Hilfestellungen
Grüße Uwe
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

das script zum touch calibration

// ITDB02_Touch_Calibration (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program can be used to calibrate the touchscreen
// of the ITDB02 modules.
// This program requires the ITDB02_Graph library (8bit mode)
// or ITDB02_Graph16 (16bit mode).
//
// It is assumed that the ITDB02 module is connected to a
// ITDB02 Shield, a ITDB02 Mega Shield or that you know how
// to change the pin numbers in the setup.
//
// Instructions will be given on the display.
//

// Remember to change the next line if you are using as 16bit module!
#include <ITDB02_Graph.h>
#include <ITDB02_Touch.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

// Uncomment the next two lines for the ITDB02 Shield
ITDB02        myGLCD(19,18,17,16);
ITDB02_Touch  myTouch(15,10,14,9,8);

// Uncomment the next two lines for the ITDB02 Mega Shield
//ITDB02        myGLCD(38,39,40,41);   // Remember to add ASPECT_16x9 if you are using an ITDB02-3.2WC!
//ITDB02_Touch  myTouch(6,5,4,3,2);

int cx, cy;
int rx[10], ry[10];
float px, py;
int ox, oy;

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_LOW);
}

void drawCrossHair(int x, int y)
{
  myGLCD.drawRect(x-10, y-10, x+10, y+10);
  myGLCD.drawLine(x-5, y, x+5, y);
  myGLCD.drawLine(x, y-5, x, y+5);
}

void readCoordinates()
{
  int iter = 2000;
  int cnt = 0;
  unsigned long tx=0;
  unsigned long ty=0;
  boolean OK = false;
 
  while (OK == false)
  {
    while (myTouch.dataAvailable() == false) {}
    while ((myTouch.dataAvailable() == true) && (cnt<iter))
    {
      myTouch.read();
      tx += myTouch.TP_X;
      ty += myTouch.TP_Y;
      cnt++;
    }
    if (cnt>=iter)
    {
      OK = true;
    }
    else
    {
      tx = 0;
      ty = 0;
      cnt = 0;
    }
  }

  cx = tx / iter;
  cy = ty / iter;

}

void calibrate(int x, int y, int i)
{
  myGLCD.setColor(255, 255, 255);
  drawCrossHair(x,y);
  readCoordinates();
  myGLCD.setColor(80, 80, 80);
  drawCrossHair(x,y);
 
  rx=cx;
  ry=cy;
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
  }
}

void waitForTouch()
{
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
  }
  while (myTouch.dataAvailable() == false) {}
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
  }
}

void startup()
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 239, 13);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.drawLine(0, 14, 239, 14);
  myGLCD.print("ITDB02 TOUCH CALIBRATION", CENTER, 1);
  myGLCD.setBackColor(0, 0, 0);
 
  myGLCD.print("INSTRUCTIONS", CENTER, 30);
  myGLCD.print("Use a stylus or something", LEFT, 50);
  myGLCD.print("similar to touch as close to", LEFT, 62);
  myGLCD.print("the center of the highlighted", LEFT, 74);
  myGLCD.print("crosshair as possible. Keep as", LEFT, 86);
  myGLCD.print("still as possible and keep", LEFT, 98);
  myGLCD.print("holding until the highlight is", LEFT, 110);
  myGLCD.print("removed. Repeat for all", LEFT, 122);
  myGLCD.print("crosshairs in sequence.", LEFT, 134);
  myGLCD.print("Further instructions will be", LEFT, 158);
  myGLCD.print("displayed when the calibration", LEFT, 170);
  myGLCD.print("is complete.", LEFT, 182);
  myGLCD.print("Do NOT use your finger as a", LEFT, 206);
  myGLCD.print("calibration stylus or the", LEFT, 218);
  myGLCD.print("result WILL BE very imprecise.", LEFT, 230);
  myGLCD.print("Touch screen to continue", CENTER, 305);

  waitForTouch();
  myGLCD.clrScr();
}

void done()
{
  myGLCD.clrScr();
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 239, 13);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.drawLine(0, 14, 239, 14);
  myGLCD.print("ITDB02 TOUCH CALIBRATION", CENTER, 1);
  myGLCD.setBackColor(0, 0, 0);
 
  myGLCD.print("CALIBRATION COMPLETE", CENTER, 30);
  myGLCD.print("To use the new calibration", LEFT, 50);
  myGLCD.print("settings you must edit the", LEFT, 62);
  myGLCD.setColor(160, 160, 255);
  myGLCD.print("ITDB02_Touch.cpp", LEFT, 74);
  myGLCD.setColor(255, 255, 255);
  myGLCD.print("file and", 136, 74);
  myGLCD.print("change the following values.", LEFT, 86);
  myGLCD.print("The values are located right", LEFT, 98);
  myGLCD.print("below the opening comment in", LEFT, 110);
  myGLCD.print("the file.", LEFT, 122);
  myGLCD.print("PixSizeX", LEFT, 158);
  myGLCD.print("PixOffsX", LEFT, 170);
  myGLCD.print("PixSizeY", LEFT, 182);
  myGLCD.print("PixOffsY", LEFT, 194);
  myGLCD.print("Connected module:", LEFT, 250);
  myGLCD.drawLine(0, 155, 239, 155);
  myGLCD.drawLine(0, 209, 239, 209);

  myGLCD.printNumF(px, 2, 100, 158);
  myGLCD.printNumI(ox, 100, 170);
  myGLCD.printNumF(py, 2, 100, 182);
  myGLCD.printNumI(oy, 100, 194);
  if (px>=0)
    myGLCD.print("2.4\"", 144, 250);
  else
  {
    if (py>=0)
    {
      myGLCD.print("3.2\"", 144, 250);
      myGLCD.print("Negative numbers for PixSizeX", LEFT, 270);
      myGLCD.print("is expected smiley", LEFT, 282);
    }
    else
    {
      myGLCD.print("3.2\" Wide", 144, 250);
      myGLCD.print("Negative numbers for PixSizeX", LEFT, 270);
      myGLCD.print("and PixSizeY are expected smiley", LEFT, 282);
    }
  }
}

void loop()
{
  startup();
 
  myGLCD.setColor(80, 80, 80);
  drawCrossHair(10,10);
  drawCrossHair(10,160);
  drawCrossHair(10,309);
  drawCrossHair(120,10);
  drawCrossHair(120,160);
  drawCrossHair(120,309);
  drawCrossHair(229,10);
  drawCrossHair(229,160);
  drawCrossHair(229,309);
 
  calibrate(10, 10, 0);
  calibrate(10, 160, 1);
  calibrate(10, 309, 2);
  calibrate(120, 10, 3);
  calibrate(120, 160, 4);
  calibrate(120, 309, 5);
  calibrate(229, 10, 6);
  calibrate(229, 160, 7);
  calibrate(229, 309, smiley-cool;
 
  px = ((float(rx[0]+rx[1]+rx[2])/3)-(float(rx[6]+rx[7]+rx[8])/3))/220;
  if (px>=0)
    ox = (((rx[6]+rx[7]+rx[8])/3))-(px*10);
  else
    ox = (((rx[0]+rx[1]+rx[2])/3))+(px*10);

  py = ((float(ry[0]+ry[3]+ry[6])/3)-(float(ry[2]+ry[5]+ry[8])/3))/300;
  if (py>=0)
    oy = (((ry[2]+ry[5]+ry[8])/3))-(py*10);
  else
    oy = (((ry[0]+ry[3]+ry[6])/3))+(py*10);
   

  done();
  while(true) {}


die fehlermeldung

ITDB02_Touch_Calibration.cpp:17:26: error: ITDB02_Graph.h: No such file or directory
ITDB02_Touch_Calibration:23: error: 'ITDB02' does not name a type
ITDB02_Touch_Calibration.cpp: In function 'void setup()':
ITDB02_Touch_Calibration:37: error: 'myGLCD' was not declared in this scope
ITDB02_Touch_Calibration.cpp: In function 'void drawCrossHair(int, int)':
ITDB02_Touch_Calibration:47: error: 'myGLCD' was not declared in this scope
ITDB02_Touch_Calibration.cpp: In function 'void calibrate(int, int, int)':
ITDB02_Touch_Calibration:89: error: 'myGLCD' was not declared in this scope
ITDB02_Touch_Calibration.cpp: In function 'void startup()':
ITDB02_Touch_Calibration:118: error: 'myGLCD' was not declared in this scope
ITDB02_Touch_Calibration:123: error: 'CENTER' was not declared in this scope
ITDB02_Touch_Calibration:127: error: 'LEFT' was not declared in this scope
ITDB02_Touch_Calibration.cpp: In function 'void done()'
ITDB02_Touch_Calibration:149: error: 'myGLCD' was not declared in this scope
ITDB02_Touch_Calibration:155: error: 'CENTER' was not declared in this scope
ITDB02_Touch_Calibration:159: error: 'LEFT' was not declared in this scope
ITDB02_Touch_Calibration.cpp: In function 'void loop()':
ITDB02_Touch_Calibration:204: error: 'myGLCD' was not declared in this scope}


« Last Edit: October 26, 2012, 10:57:32 am by Poser » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code Tags! Ist das soooo schwierig?

Quote
ITDB02_Touch_Calibration.cpp:17:26: error: ITDB02_Graph.h: No such file or directory

Diese Fehlermeldung besagt, dass Du die ITDB02_Graph-Bibliothek nicht oder falsch installiert hast.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wohin installiere ich die? Dumm frage
woher bekomme ich die Graph.h? sie ist nicht dabei :-(
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Wohin installiere ich die?

In Deinem sketchbook-Verzeichnis ein Unterverzeichnis anlegen mit Namen "libraries", dort drin die Bibliothek entpacken (müsste ein Verzeichnis "ITDB02_Graph" oder "ITDB02_Graph16" ergeben.

Quote
woher bekomme ich die Graph.h?

http://henningkarlsen.com/electronics/library.php?id=38

bzw.

http://henningkarlsen.com/electronics/library.php?id=39
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

jetzt kommt diese meldung :-(

ITDB02_Touch_ButtonTest.cpp.o: In function `setup':
C:\Temp\build6312532056827934767.tmp/ITDB02_Touch_ButtonTest.cpp:48: undefined reference to `BigFont'
C:\Temp\build6312532056827934767.tmp/ITDB02_Touch_ButtonTest.cpp:48: undefined reference to `BigFont'

C:\Dokumente und Einstellungen\priv\Desktop\arduino-0023\hardware\tools\avr\bin\avr-ar: pins_arduino.c.o: No such file or directory
« Last Edit: October 26, 2012, 01:45:05 pm by Poser » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Entweder hast Du die Datei DefaultFonts.cpp aus dem Verzeichnis herausgelöscht oder Deine IDE ist irgendwie verschossen.

Wieso verwendest Du eine uralte IDE-Version (0.23)?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

da bekomme ich noch mehr fehler











In file included from ITDB02_Touch_ButtonTest.cpp:15:
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:52:22: error: WProgram.h: No such file or directory
In file included from ITDB02_Touch_ButtonTest.cpp:15:
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:56: error: ISO C++ forbids declaration of 'uint8_t' with no type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:56: error: expected ';' before '*' token
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:57: error: 'uint8_t' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:58: error: 'uint8_t' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:59: error: 'uint8_t' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:60: error: 'uint8_t' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:67: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:68: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:72: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:72: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:72: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:79: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:79: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:79: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:80: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:80: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:80: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:83: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:84: error: 'uint8_t' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:89: error: 'byte' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:90: error: 'byte' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:91: error: 'byte' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:92: error: ISO C++ forbids declaration of 'uint8_t' with no type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:92: error: expected ';' before '*' token
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:93: error: 'uint8_t' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:95: error: 'byte' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:101: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:101: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:101: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:104: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:106: error: 'byte' has not been declared
In file included from ITDB02_Touch_ButtonTest.cpp:16:
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:57: error: 'word' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:59: error: expected `)' before 'tclk'
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:61: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:66: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:69: error: 'byte' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:70: error: 'byte' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:71: error: 'byte' does not name a type
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:73: error: 'byte' has not been declared
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:74: error: 'word' does not name a type
ITDB02_Touch_ButtonTest.pde:-1: error: no matching function for call to 'ITDB02_Touch::ITDB02_Touch(int, int, int, int, int)'
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:55: note: candidates are: ITDB02_Touch::ITDB02_Touch()
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Touch.h:55: note:                 ITDB02_Touch::ITDB02_Touch(const ITDB02_Touch&)
ITDB02_Touch_ButtonTest.cpp: In function 'void setup()':
ITDB02_Touch_ButtonTest.pde:-1: error: no matching function for call to 'ITDB02::setFont(uint8_t [])'
C:\Dokumente und Einstellungen\priv\Desktop\arduino-1.0.1\libraries\ITDB02_Touch/ITDB02_Graph.h:84: note: candidates are: void ITDB02::setFont(int*)


and

no matching funktion for call to ITDB02_Touch: ITDB02_Touch(int,int,int,int)
Logged

Forum Moderator
BZ (I)
Offline Offline
Brattain Member
*****
Karma: 262
Posts: 21578
+39 349 2158303
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

was zu erwarten war.
Hallo an alle
Ab IDE 1.0 wurden einige Bibiotheken umbenannt/zusammengefaßt. Deshalb funktionieren Bibiotheken für IDE0023 und älter unter Umständen nicht mehr mit IDE1.0
Die Bibiothek WProgram.h wurde in Arduino.h umbenannt.
Um eine Bibiothek für beide IDE Versionen kompatibel zu machen, muß man in die Bibiothek statt #include"WProgram.h" folgendes schreiben:
Code:
  #if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
  #else
  #include "WProgram.h"
  #endif

Eine gute Informationsquelle sind die Release Notes: http://arduino.cc/en/Main/ReleaseNotes
viele Grüße Uwe   
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So das Display geht

Jetzt habe ich nur noch eine Frage

wie Kann ich text schreiben??



Code:
// ITDB02_Touch_ButtonTest (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
// Modified to work with UTFT on Mega w/Arduino 1.0.1 (C)2012 Otmar Ebenhoech,
//
// This program is a quick demo of how create and use buttons.
//
// This program requires the ITDB02_Graph library (8bit mode)
// or ITDB02_Graph16 (16bit mode).
//
// It is assumed that the ITDB02 module is connected to a
// ITDB02 Shield, a ITDB02 Mega Shield or that you know how
// to change the pin numbers in the setup.
//

#include <UTFT.h>
#include <ITDB02_Touch.h>

// Declare which fonts we will be using
extern uint8_t BigFont[];// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int Relais6 = 13;
int Relais5 = 12;
int Relais4 = 11;
int Relais3 = 10;
int Relais2 = 9;
int Relais1 = 8;

// Uncomment the next line for Arduino 2009/Uno
//UTFT myGLCD(ITDB32S,19,18,17,16);   // Remember to change the model parameter to suit your display module!
//ITDB02_Touch  myTouch(15,10,14,9,8);

// Uncomment the next line for Arduino Mega
UTFT myGLCD(ITDB32S,38,39,40,41);   // Remember to change the model parameter to suit your display module!
ITDB02_Touch  myTouch(6,5,4,3,2);

int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

void setup()
{
// Initial setup
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);

  myGLCD.setFont(BigFont);
  myGLCD.setBackColor(0, 0, 255);

// initialize the digital pin as an output.
  pinMode(Relais6, OUTPUT);
  pinMode(Relais5, OUTPUT);
  pinMode(Relais4, OUTPUT);
  pinMode(Relais3, OUTPUT);
  pinMode(Relais2, OUTPUT);
  pinMode(Relais1, OUTPUT);

 
 
// Draw the upper row of buttons
  for (x=0; x<5; x++)
  {
    myGLCD.setColor(0, 0, 255);
    myGLCD.fillRoundRect (10+(x*60), 10, 60+(x*60), 60);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect (10+(x*60), 10, 60+(x*60), 60);
    myGLCD.printNumI(x+1, 27+(x*60), 27);
  }
// Draw the center row of buttons
  for (x=0; x<5; x++)
  {
    myGLCD.setColor(0, 0, 255);
    myGLCD.fillRoundRect (10+(x*60), 70, 60+(x*60), 120);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect (10+(x*60), 70, 60+(x*60), 120);
    if (x<4)
      myGLCD.printNumI(x+6, 27+(x*60), 87);
  }
  myGLCD.print("0", 267, 87);
// Draw the lower row of buttons
  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRoundRect (10, 130, 150, 180);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (10, 130, 150, 180);
  myGLCD.print("Clear", 40, 147);
  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRoundRect (160, 130, 300, 180);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (160, 130, 300, 180);
  myGLCD.print("Enter", 190, 147);
  myGLCD.setBackColor (0, 0, 0);
}

void updateStr(int val)
{
  if (stCurrentLen<20)
  {
    stCurrent[stCurrentLen]=val;
    stCurrent[stCurrentLen+1]='\0';
    stCurrentLen++;
    myGLCD.setColor(0, 255, 0);
    myGLCD.print(stCurrent, LEFT, 224);
  }
  else
  {
    myGLCD.setColor(255, 0, 0);
    myGLCD.print("BUFFER FULL!", CENTER, 192);
    delay(500);
    myGLCD.print("            ", CENTER, 192);
    delay(500);
    myGLCD.print("BUFFER FULL!", CENTER, 192);
    delay(500);
    myGLCD.print("            ", CENTER, 192);
    myGLCD.setColor(0, 255, 0);
  }
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable())
    myTouch.read();
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
}

void loop()
{
  while (true)
  {
    if (myTouch.dataAvailable())
    {
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();
     
      if ((y>=10) && (y<=60))  // Upper row
      {
        if ((x>=10) && (x<=60))  // Button: 1
        digitalWrite(Relais1, LOW);   // turn the LED on (HIGH is the voltage level)
        {
        //  waitForIt(10, 10, 60, 60);
        //  updateStr('1');
        }
        if ((x>=70) && (x<=120))  // Button: 2
        digitalWrite(Relais1, HIGH);   // turn the LED on (HIGH is the voltage level)
        {
        //  waitForIt(70, 10, 120, 60);
        //  updateStr('2');
        }
        if ((x>=130) && (x<=180))  // Button: 3
        digitalWrite(Relais2, LOW);   // turn the LED on (HIGH is the voltage level)
        {
          waitForIt(130, 10, 180, 60);
          updateStr('3');
        }
        if ((x>=190) && (x<=240))  // Button: 4
        digitalWrite(Relais2, HIGH);   // turn the LED on (HIGH is the voltage level)
        {
          waitForIt(190, 10, 240, 60);
          updateStr('4');
        }
        if ((x>=250) && (x<=300))  // Button: 5
        digitalWrite(Relais3, LOW);   // turn the LED on (HIGH is the voltage level)
        {
          waitForIt(250, 10, 300, 60);
          updateStr('5');
        }
      }

      if ((y>=70) && (y<=120))  // Center row
      {
        if ((x>=10) && (x<=60))  // Button: 6
        digitalWrite(Relais3, HIGH);   // turn the LED on (HIGH is the voltage level)
        {
        //  waitForIt(10, 70, 60, 120);
        //  updateStr('6');
        }
        if ((x>=70) && (x<=120))  // Button: 7
        digitalWrite(Relais4, LOW);   // turn the LED on (HIGH is the voltage level)
        {
        //  waitForIt(70, 70, 120, 120);
        //  updateStr('7');
        }
        if ((x>=130) && (x<=180))  // Button: 8
        digitalWrite(Relais4, HIGH);   // turn the LED on (HIGH is the voltage level)
        {
        //  waitForIt(130, 70, 180, 120);
        //  updateStr('8');
        }
        if ((x>=190) && (x<=240))  // Button: 9
        digitalWrite(Relais5, LOW);   // turn the LED on (HIGH is the voltage level)
        {
          waitForIt(190, 70, 240, 120);
          updateStr('9');
        }
        if ((x>=250) && (x<=300))  // Button: 0
        digitalWrite(Relais5, HIGH);   // turn the LED on (HIGH is the voltage level)
        {
          waitForIt(250, 70, 300, 120);
          updateStr('0');
        }
      }

      if ((y>=130) && (y<=180))  // Upper row
      {
        if ((x>=10) && (x<=150))  // Button: Clear
        {
          waitForIt(10, 130, 150, 180);
          stCurrent[0]='\0';
          stCurrentLen=0;
          myGLCD.setColor(0, 0, 0);
          myGLCD.fillRect(0, 224, 319, 239);
        }
        if ((x>=160) && (x<=300))  // Button: Enter
        {
          waitForIt(160, 130, 300, 180);
          if (stCurrentLen>0)
          {
            for (x=0; x<stCurrentLen+1; x++)
            {
              stLast[x]=stCurrent[x];
            }
            stCurrent[0]='\0';
            stCurrentLen=0;
            myGLCD.setColor(0, 0, 0);
            myGLCD.fillRect(0, 208, 319, 239);
            myGLCD.setColor(0, 255, 0);
            myGLCD.print(stLast, LEFT, 208);
          }
          else
          {
            myGLCD.setColor(255, 0, 0);
            myGLCD.print("BUFFER EMPTY", CENTER, 192);
            delay(500);
            myGLCD.print("            ", CENTER, 192);
            delay(500);
            myGLCD.print("BUFFER EMPTY", CENTER, 192);
            delay(500);
            myGLCD.print("            ", CENTER, 192);
            myGLCD.setColor(0, 255, 0);
          }
        }
      }
    }
  }
}

[EDIT] Hab Code-Tags hinzugehügt. Grüße Uwe [EDIT/]
« Last Edit: October 27, 2012, 05:13:30 pm by uwefed » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Schau Dir mal Deinen Code an. Begreifst Du, warum die Code-Tags notwendig sind?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hallo zusammen,

ich bin noch "Pre"-Anfänger, d.h. ich habe noch keinen Arduino und suche noch nach dem passenden Einstieg. Dabei bin ich aber auch über das oben genannte Bundle gestolpert und habe eine Frage dazu: bleiben noch genug I/O-Pins übrig wenn man das Display auf dem SainSmart Mega2560 installiert hat? Ich möchte damit zwei 8er-Relaisboards ansteuern (eBay: 5V 8-Kanal Relais Modul Platine für Arduino PIC ). Kann mir jemand sagen ob dies damit machbar ist oder bin ich da auf dem Holzweg?

VG,4u
Logged

Pages: [1]   Go Up
Jump to: