// Purpose: Draw a line on a graphic LCD using Bresenham's
// line drawing algorithm
// Inputs: (x1, y1) - the start coordinate
// (x2, y2) - the end coordinate
// color - ON or OFF
// Dependencies: glcd_pixel()
void glcd_line(int x1, int y1, int x2, int y2, int1 color)
{
signed int x, y, addx, addy, dx, dy;
signed long P;
int i;
dx = abs((signed int)(x2 - x1));
dy = abs((signed int)(y2 - y1));
x = x1;
y = y1;
if(x1 > x2)
addx = -1;
else
addx = 1;
if(y1 > y2)
addy = -1;
else
addy = 1;
if(dx >= dy)
{
P = 2*dy - dx;
for(i=0; i<=dx; ++i)
{
glcd_pixel(x, y, color);
if(P < 0)
{
P += 2*dy;
x += addx;
}
else
{
P += 2*dy - 2*dx;
x += addx;
y += addy;
}
}
}
else
{
P = 2*dx - dy;
for(i=0; i<=dy; ++i)
{
glcd_pixel(x, y, color);
if(P < 0)
{
P += 2*dx;
y += addy;
}
else
{
P += 2*dx - 2*dy;
x += addx;
y += addy;
}
}
}
}
Thanks so much TechToys i discovered that i had aproblem in function of drawpixel as in the same page when i write on a certain location on acertain pixel when i wrote in the same location in new pixel the first pixel disappeared so i will try to fix it and for the second time thanks so much
OK. That is what I thought for your problem at the very beginning. Interfacing with KS0107/8 LCD uses all 8-bit data in a verticle manner. Writing a value of, say, 0xFF will draw 8 pixels at a certain column at one of the 128 pixel columns of the screen.
When a single pixel is needed but not affecting the other pixel on a certain PAGE, I use the READ function to read the original verticle byte pattern of a particular PAGE first, then a bitwise OR operation is done to make sure when a single pixel is lited at a certain co-ordinate in the the verticle direction, the other pixels will not be affected.
Hopefully on tomorrow, I will finish the last chapter of my development board's manual, which is about the graphical LCD. Detailed description will be written.
Hi TechToys
I got your solution but the problem that the read instruction itself i have aproblem in it this is the problem i'm facing now, that the prevoius data is not correct espectially in the first time.
Abd good luck for your development board's manual [/quote]
hi ,is there anyone can help me in my topic. i need to an algorithm using MPLAB that can draw me a line on the AMPIRE 128*64 graphical LCD using KS018 driver or even some help in the interface between the AMPIRE LCD and pic 18 .10x in advance
Hi
The best chip for graphical lcd is T6963c of Toshiba and the best software for work with graphical lcd is bascom.
this software has very usefull built in functions for this chip...
Other chip is ks0108 ... but T6963c is very better than ks0108