hi !
I am writing the AVR gcc routines for this display from Newhaven but other than fill screen with colors nothing else is working.
can you see what iam doing wrong with drawing a pixel or drawing a line?
the display is in 8bit mode.
since i can display colors on the screen I know that comm_out() and data_out() functions are good and so is the init_TFT().
and the hardware wiring of display must be good so I am missing something in drawing or setting the pixel.
thanks
void setCol(int16_t StartCol,int16_t EndCol)
{
comm_out(0x2A);
upperNibble = StartCol >> 4;
lowerNibble = StartCol & 0x0f;
data_out(upperNibble);
data_out(lowerNibble);
upperNibble = EndCol >> 4;
lowerNibble = EndCol & 0x0f;
data_out(upperNibble);
data_out(lowerNibble);
}
void setPage(int16_t StartPage,int16_t EndPage)
{
comm_out(0x2B);
upperNibble = StartPage >> 4;
lowerNibble = StartPage & 0x0f;
data_out(upperNibble);
data_out(lowerNibble);
upperNibble = EndPage >> 4;
lowerNibble = EndPage & 0x0f;
data_out(upperNibble);
data_out(lowerNibble);
}
void setXY(int16_t poX, int16_t poY)
{
setCol(poX, poX);
setPage(poY, poY);
comm_out(0x2c);
}
void setPixel(int16_t poX, int16_t poY,int16_t color)
{
setXY(poX, poY);
data_out(color);
}
void drawLine( int16_t x0,int16_t y0,int16_t x1, int16_t y1,int16_t color)
{
int x = x1-x0;
int y = y1-y0;
int dx = abs(x), sx = x0<x1 ? 1 : -1;
int dy = -abs(y), sy = y0<y1 ? 1 : -1;
int err = dx+dy, e2; /* error value e_xy /
for (;;){ / loop /
setPixel(x0,y0,color);
e2 = 2err;
if (e2 >= dy) { /* e_xy+e_x > 0 /
if (x0 == x1) break;
err += dy; x0 += sx;
}
if (e2 <= dx) { / e_xy+e_y < 0 */
if (y0 == y1) break;
err += dx; y0 += sy;
}
}
}
void write_8(unsigned char c)
{
PORTB = (PORTB & ~DMSK)|(c & DMSK);
PORTC = (PORTC & DMSK)|(c & ~DMSK);
WRLO;
WRHI;
}
void TFT_setup(void)
{
DDRB |= DMSK;
DDRC |= ~DMSK;
DDRC |= 0x3C; //RS, RW, RD, RES
RDHI;
WRHI;
init_TFT();
}
void comm_out(unsigned char data)
{
RSLO;
write_8(data);
}
void data_out(unsigned char data)
{
RSHI;
write_8(data);
}
void disp_color(int16_t Color)
{
unsigned int i;
comm_out(0x2C); //command to begin writing to frame memory
uint8_t upperNibble = Color >> 4;
uint8_t lowerNibble = Color & 0x0f;
for (i = 0; i < 38400; i++) //fill screen with blue pixels
{
data_out(upperNibble);
data_out(lowerNibble);
data_out(upperNibble);
data_out(lowerNibble);
}
}
void disp()
{
unsigned int i;
comm_out(0x2C); //command to begin writing to frame memory
for (i = 0; i < 38400; i++) //fill screen with blue pixels
{
data_out(0xF8);
data_out(0x10);
data_out(0xF8);
data_out(0x10);
}
for (i = 0; i < 38400; i++) //fill screen with green pixels
{
data_out(0x07);
data_out(0xE0);
data_out(0x07);
data_out(0xE0);
}
}