Hi everyone, i am facing a problem when i try to draw on the tft screen.. i will post the code
// UTFT_Demo_320x240 (C)2012 uCtronics
// web: http://www.uctronics.com
// UTFT_Demo_320x240 is derived from
// UTFT_Demo_320x240 (C)2010 Henning Karlsen
// web: Electronics - Henning Karlsen
// to fit for our 3.2 inch TFT LCD shield for Arduino/Maple/Chipkit
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution
// of 320x240 pixels.
//
// This program requires the UTFT library (8bit mode)
// and the code is compatible with both UNO and Mega board.
// No code modification required.
//
// if I want to use a GLUE class that implements the UTFT API
// with the Adafruit classes, I MUST include those headers
// because the Arduino Java does not look at nested includes !
#include <Adafruit_GFX.h>
//#include <Adafruit_TFTLCD.h> // this header is not needed
#include <UTFTGLUE.h> // class methods are in here
//UTFTGLUE myGLCD; // use for default shield
//UTFTGLUE myGLCD(0x9320,A2,A1,A3,A4,A0);
//UTFTGLUE myGLCD(0x9325,A2,A1,A3,A4,A0);
//UTFTGLUE myGLCD(0x7783,A2,A1,A3,A4,A0);
//UTFTGLUE myGLCD(0x1289,A1,A2,A0,0,A3); // this might choose the pins
UTFTGLUE myGLCD(0x0154,A2,A1,A3,A4,A0);
/*
#include <UTFT.h>
//#include <SD.h>
//UTFT myGLCD(ILI9325C,A2,A1,A3,A4); // Remember to change the model parameter to suit your display module!
//UTFT myGLCD(ILI9325D_8,A2,A1,A3,A4); // Remember to change the model parameter to suit your display module!
UTFT myGLCD(SSD1289_8,A1,A2,A0,A3); // Remember to change the model parameter to suit your display module!
*/
// Uncomment the next line for Arduino 2009/Uno
// UTFT(byte model, int RS, int WR,int CS,int RD)
//UTFT myGLCD(ILI9325C,A2,A1,A3,A0); // Remember to change the model parameter to suit your display module!
//Adafruit_UTFT myGLCD;
// Declare which fonts we will be using
extern uint8_t SmallFont[];
int analog_in = A8;
unsigned long previousMillis = 0;
const long interval = 5;
void setup()
{
pinMode(A8, INPUT);
Serial.begin(9600);
// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}
void loop()
{
int x;
// Clear the screen and draw the frame
myGLCD.clrScr();
myGLCD.setColor(0, 0, 255);
myGLCD.drawRect(0, 14, 319, 225);
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
previousMillis = currentMillis;
Serial.println(analogRead(A8)-70);
// Draw a moving sinewave
x = 1 ;
for (int i=1; i<(300*20); i++)
{
if (x < 319){
x ++ ;
myGLCD.setColor(0,255,255);
int y=(analogRead(A8)-70);
myGLCD.drawPixel(x,y);
delay(5);
}
else
{
x = 1;
myGLCD.clrScr();
}
}
}
}
from the above code, i am able to read the analog_input at A8 in to my y axis on the screen, and it does clear the screen after x reach to the maximum (very right to the screen) and draw again. however, i am just wondering its only showing number of pixels, so its not lines, how do i connect every pixel into lines?