I post this in case others have or find the same display, as shown in the pictures below. It doesn't take too much to get it to do what I want.
The display comes in a brown box with no identification whatsoever. No data either
It runs on the standard Cold Tears universal shield for Mega, no change to jumpers.
it is 400x240
The colours are CMY additive with black being 255,255,255. This is probably not the manufacturer's intention, but that is no longer relevant. The "M" is really violet and I believe anybody contemplating putting colour pictures on this would be well-advised to get another display.
It can be made to work with the Henning Karlsen UTFT library using the 480x320 demo for the CTE32HR. This appears to be a better place to start than any of the 400x320 examples therein, although wave and pattern commands were lifted from them.
The 400x240 area occupies the top right hand corner of a 480x320, i.e. start drawing at x=81. This means that the RIGHT shortcut works but the others don't. I imagine the library could be edited to fix the LEFT and CENTRE commands, but I haven't looked at it. The y coordinates go down from 0 to 239 in the normal manner.
The code shows a practical demo. It is a bit rough in places but proves the point, actually shows more than the original, and can be adapted for just about anything except bitmaps. The Henning Karlsen UTFT manual has everything else you need.
// UTFT_Demo_400x240 Nick Pyner
// Kudos to Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
// MEGA
#include <UTFT.h>
// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
// Arduino Mega
UTFT myGLCD(CTE32HR,38,39,40,41);
void setup()
{
randomSeed(analogRead(0));
Serial.begin(9600);
int Xsize = myGLCD.getDisplayXSize();
Serial.print(Xsize);
// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}
void loop()
{
int buf[478];
int x, x2;
int y, y2;
int r;
// Clear the screen and draw the frame
myGLCD.clrScr();
myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(80, 0, 479, 13);
myGLCD.setColor(0, 0, 255);
myGLCD.fillRect(80, 226, 479, 240);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("* Universal Color TFT Display Library *",120, 1);
myGLCD.setBackColor(0, 0, 255);
myGLCD.setColor(255,255,0);
myGLCD.print("<http://electronics.henningkarlsen.com>", 120, 226);
myGLCD.setColor(255,255,255);
myGLCD.fillRect(80,15,478,224);
// Draw crosshairs
myGLCD.setColor(255, 0, 255);
myGLCD.setBackColor(255, 255, 255);
myGLCD.drawLine(280, 15, 280, 224);
myGLCD.drawLine(80, 120, 478, 120);
for (int i=89; i<470; i+=10)
myGLCD.drawLine(i, 118, i, 122);
for (int i=1; i<220; i+=10)
myGLCD.drawLine(278, i, 282, i);
// Draw sin-, cos- and tan-lines
myGLCD.setColor(0,255,255); //red
myGLCD.print("Sin", 85, 15);
for (int i=80; i<478; i++)
{
myGLCD.drawPixel((i-20),119+(sin(((i*0.9)*3.14)/180)*95));
}
delay(2000);
myGLCD.setColor(255,50,255); //green
myGLCD.print("Cos", 85, 27);
for (int i=80; i<478; i++)
{
myGLCD.drawPixel((i-20),119+(cos(((i*0.9)*3.14)/180)*95));
}
delay(2000);
myGLCD.setColor(0,0,0);
myGLCD.print("Tan", 85, 39);
for (int i=80; i<478; i++)
{
y=119+(tan(((i*0.9)*3.14)/180));
if ((y>15) && (y<224))
myGLCD.drawPixel((i-20),y);
}
delay(6000);
// Draw a moving sinewave
myGLCD.setColor(255,255,255);
myGLCD.fillRect(80,15,478,224);
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(280, 15, 280, 304);
myGLCD.drawLine(81, 120, 478, 120);
x=1;
for (int i=1; i<(478*15); i++)
{
x++;
if (x==479)
x=80;
if (i>479)
{
if ((x==199)||(buf[x-1]==119))
myGLCD.setColor(0,0,255);
else
myGLCD.setColor(0,255,0);
myGLCD.drawPixel(x,buf[x-1]);
}
myGLCD.setColor(0,255,255);
y=119+(sin(((i)*3.14)/180)*(90-(i / 100)));
myGLCD.drawPixel(x,y);
buf[x-1]=y;
}
delay(2000);
// Draw some filled rectangles
myGLCD.setColor(255,255,255);
myGLCD.fillRect(80,15,478,224);
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillRect(280-(i*20), 30+(i*20), 340-(i*20), 90+(i*20));
}
delay(2000);
// Draw some filled circles
myGLCD.setColor(255,255,255);
myGLCD.fillRect(80,15,478,224);
for (int i=1; i<7; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,0); // cyan
break;
case 2:
myGLCD.setColor(0,255,0); // magenta
break;
case 3:
myGLCD.setColor(0,64,255); // yellow
break;
case 4:
myGLCD.setColor(0,255,255); // red
break;
case 5:
myGLCD.setColor(255,0,255); //green
break;
case 6:
myGLCD.setColor(255,255,0); // blue
break;
}
myGLCD.fillCircle(160+(i*30),45+(i*20), 30);
}
delay(2000);
// Draw some lines in a pattern
myGLCD.setColor(255,255,255);
myGLCD.fillRect(80,15,478,224);
myGLCD.setColor (255,0,0);
for (int i=15; i<224; i+=5)
{
myGLCD.drawLine(80, i, (i*1.77)-10, 224);
}
myGLCD.setColor (255,0,0);
for (int i=224; i>15; i-=5)
{
myGLCD.drawLine(478, i, (i*1.77)-11, 15);
}
myGLCD.setColor (0,255,255);
for (int i=224; i>15; i-=5)
{
myGLCD.drawLine(80, i, 491-(i*1.77), 15);
}
myGLCD.setColor (0,255,255);
for (int i=15; i<224; i+=5)
{
myGLCD.drawLine(478, i, 490-(i*1.77), 224);
}
delay(6000);
myGLCD.fillScr(0, 0, 255);
myGLCD.setColor(255, 0, 0);
myGLCD.fillRoundRect(195, 70, 365, 169);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("That's it!", 220, 93);
myGLCD.print("Restarting in a", 220, 119);
myGLCD.print("few seconds...", 220, 132);
myGLCD.setFont(BigFont);
myGLCD.setColor(0, 255, 255);
myGLCD.setBackColor(0, 0, 255);
myGLCD.print("Runtime: msecs", 85, 200);
myGLCD.setFont(SevenSegNumFont);
myGLCD.printNumI(millis(), 320, 185);
delay (5000);
myGLCD.setFont(SmallFont);
}