Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 20th June 2009, 09:37 PM   #136
Default

NICE! dude thats awesome
AtomSoft is online now  
Old 20th June 2009, 09:42 PM   #137
Default

how do you call it? Whats top, left, x,y ?

x0 = ?
x1 = ?

y0 = ?
y1 = ?
AtomSoft is online now  
Old 20th June 2009, 09:53 PM   #138
Default

now, I have added the circle function: lcd_setcircle().

Code:
/**********************************************************
           draw a circle between two points
					 code shamelessly stolen from Jim Lynch's 6100 driver
					 which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setcircle(char x0, char y0, char radius) {

	int f = 1 - radius;
	int ddF_x = 0;
	int ddF_y = -2 * radius;
	int x = 0;
	int y = radius;

	lcd_setpixel(x0, y0 + radius);
	lcd_setpixel(x0, y0 - radius);
	lcd_setpixel(x0 + radius, y0);
	lcd_setpixel(x0 - radius, y0);
	while(x < y) {
		if(f >= 0) {
			y--;
			ddF_y += 2;
			f += ddF_y;
		}
		x++;
		ddF_x += 2;
		f += ddF_x + 1;
		lcd_setpixel(x0 + x, y0 + y);
		lcd_setpixel(x0 - x, y0 + y);
		lcd_setpixel(x0 + x, y0 - y);
		lcd_setpixel(x0 - x, y0 - y);
		lcd_setpixel(x0 + y, y0 + x);
		lcd_setpixel(x0 - y, y0 + x);
		lcd_setpixel(x0 + y, y0 - x);
		lcd_setpixel(x0 - y, y0 - x);
	}
}
Attached Thumbnails
Graphic LCD 96x64 w/ SED1565 Controller-nokia-7110-glcd-2.png  
millwood is offline  
Old 20th June 2009, 09:55 PM   #139
Default

Quote:
Originally Posted by AtomSoft View Post
how do you call it? Whats top, left, x,y ?

x0 = ?
x1 = ?

y0 = ?
y1 = ?
the upper left is (0,0), the lower right is (64, 132).

however, the first and the last 18 columns in the Nokia screen don't show. so you will have to remember that.

I did it that way so the program can be easily ported to other true SED1565 displays.
millwood is offline  
Old 20th June 2009, 10:27 PM   #140
Default

lol i meant the calling it:
Does:

x0= top
x1= left
y0= right
y1= bottom

? how do you figure it out?
AtomSoft is online now  
Old 20th June 2009, 10:34 PM   #141
Default

i think i got it now lol im so dumb lol

Its cool i edited like this : (cuz i forget everything trust me lol )
Code:
/**********************************************************
           draw a line between two points
					 code shamelessly stolen from Jim Lynch's 6100 driver
					 which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setline(char top0, char left0, char top1, char left1) {

	int dy = left1 - left0;
	int dx = top1 - top0;
	int stepx, stepy;

	if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
	if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
	dy <<= 1; // dy is now 2*dy
	dx <<= 1; // dx is now 2*dx
	lcd_setpixel(top0, left0);
	
	if (dx > dy) {
		int fraction = dy - (dx >> 1); // same as 2*dy - dx
		while (top0 != top1) {
			if (fraction >= 0) {
				left0 += stepy;
				fraction -= dx; // same as fraction -= 2*dx
			}
			top0 += stepx;
			fraction += dy; // same as fraction -= 2*dy
			lcd_setpixel(top0, left0);
		}
	} else {
		int fraction = dx - (dy >> 1);
		while (left0 != left1) {
			if (fraction >= 0) {
				top0 += stepx;
				fraction -= dy;
			}
			left0 += stepy;
			fraction += dx;
			lcd_setpixel(top0, left0);
		}
	}
}
/**********************************************************
           draw a circle between two points
					 code shamelessly stolen from Jim Lynch's 6100 driver
					 which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setcircle(char top, char left, char radius) {

	int f = 1 - radius;
	int ddF_x = 0;
	int ddF_y = -2 * radius;
	int x = 0;
	int y = radius;

	lcd_setpixel(top, left + radius);
	lcd_setpixel(top, left - radius);
	lcd_setpixel(top + radius, left);
	lcd_setpixel(top - radius, left);
	while(x < y) {
		if(f >= 0) {
			y--;
			ddF_y += 2;
			f += ddF_y;
		}
		x++;
		ddF_x += 2;
		f += ddF_x + 1;
		lcd_setpixel(top + x, left + y);
		lcd_setpixel(top - x, left + y);
		lcd_setpixel(top + x, left - y);
		lcd_setpixel(top - x, left - y);
		lcd_setpixel(top + y, left + x);
		lcd_setpixel(top - y, left + x);
		lcd_setpixel(top + y, left - x);
		lcd_setpixel(top - y, left - x);
	}
}

Last edited by AtomSoft; 20th June 2009 at 10:48 PM.
AtomSoft is online now  
Old 20th June 2009, 10:47 PM   #142
Default

Quote:
Originally Posted by AtomSoft View Post
i think i got it now lol im so dumb lol

Its cool i edited like this lol : Point0(x,y) and Point1(x.y)
it would be quite nice to develop a structure type like that. not terribly important but nice. in my last iteration, I added another parameter to decide on if I want to set or clear the line / circle / rect / ..., rather than using a set() and then a clr().

Last edited by millwood; 20th June 2009 at 10:48 PM.
millwood is offline  
Old 20th June 2009, 10:54 PM   #143
Default

heh i like the normal names because i might be smart sometimes but im dumb the rest and tend to forget a lot of things. This just helps... hence why i changed again to

Top0, Left0
Top1, Left1
AtomSoft is online now  
Old 20th June 2009, 11:57 PM   #144
Default

Quote:
Originally Posted by millwood View Post
the upper left is (0,0), the lower right is (64, 132).

however, the first and the last 18 columns in the Nokia screen don't show. so you will have to remember that.

I did it that way so the program can be easily ported to other true SED1565 displays.
why not just +18 like:

Code:
void lcd_setline(char top0, char left0, char top1, char left1) {

	int dy;
	int dx;
	int stepx, stepy;

   	left0 = left0 + 18;
	left1 = left1 + 18;

	dy = left1 - left0;
	dx = top1 - top0;

	if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
	if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
	dy <<= 1; // dy is now 2*dy
	dx <<= 1; // dx is now 2*dx
	lcd_setpixel(top0, left0);
	
	if (dx > dy) {
		int fraction = dy - (dx >> 1); // same as 2*dy - dx
		while (top0 != top1) {
			if (fraction >= 0) {
				left0 += stepy;
				fraction -= dx; // same as fraction -= 2*dx
			}
			top0 += stepx;
			fraction += dy; // same as fraction -= 2*dy
			lcd_setpixel(top0, left0);
		}
	} else {
		int fraction = dx - (dy >> 1);
		while (left0 != left1) {
			if (fraction >= 0) {
				top0 += stepx;
				fraction -= dy;
			}
			left0 += stepy;
			fraction += dx;
			lcd_setpixel(top0, left0);
		}
	}
}
AtomSoft is online now  
Old 21st June 2009, 12:02 AM   #145
Default

Now you can:

Code:
		lcd_setline(0,95,64,95);
		lcd_setline(64,0,64,95);
		lcd_setline(0,0,64,0);
		lcd_setline(0,0,0,95);
to get:
Attached Thumbnails
Graphic LCD 96x64 w/ SED1565 Controller-square.jpg  
AtomSoft is online now  
Old 21st June 2009, 12:17 AM   #146
Default

I am going to edit some of the code with the +18 because its a few functions with that issue.

More coding would give you:


Code:
Code:
		lcd_setline(0,95,64,95);
		lcd_setline(64,0,64,95);
		lcd_setline(0,0,64,0);
		lcd_setline(0,0,0,95);

		lcd_setline(52,0,52,95);

		lcd_setline(52,40,64,40);
		lcd_setline(52,54,64,54);

		lcd_str(55,7,"Menu1",NORMAL);
		lcd_str(55,60,"Menu2",NORMAL);
		lcd_str(55,46,"k",NORMAL);

		lcd_setcircle(58,47,5);
using this altered code:
Code:
/**********************************************************
           draw a line between two points
					 code shamelessly stolen from Jim Lynch's 6100 driver
					 which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setline(char top0, char left0, char top1, char left1) {

	int dy;
	int dx;
	int stepx, stepy;

   	left0 += 18;
	left1 += 18;

	dy = left1 - left0;
	dx = top1 - top0;

	if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
	if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
	dy <<= 1; // dy is now 2*dy
	dx <<= 1; // dx is now 2*dx
	lcd_setpixel(top0, left0);
	
	if (dx > dy) {
		int fraction = dy - (dx >> 1); // same as 2*dy - dx
		while (top0 != top1) {
			if (fraction >= 0) {
				left0 += stepy;
				fraction -= dx; // same as fraction -= 2*dx
			}
			top0 += stepx;
			fraction += dy; // same as fraction -= 2*dy
			lcd_setpixel(top0, left0);
		}
	} else {
		int fraction = dx - (dy >> 1);
		while (left0 != left1) {
			if (fraction >= 0) {
				top0 += stepx;
				fraction -= dy;
			}
			left0 += stepy;
			fraction += dx;
			lcd_setpixel(top0, left0);
		}
	}
}
/**********************************************************
           draw a circle between two points
					 code shamelessly stolen from Jim Lynch's 6100 driver
					 which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setcircle(char top, char left, char radius) {

	int f = 1 - radius;
	int ddF_x = 0;
	int ddF_y = -2 * radius;
	int x = 0;
	int y = radius;

	left += 18;

	lcd_setpixel(top, left + radius);
	lcd_setpixel(top, left - radius);
	lcd_setpixel(top + radius, left);
	lcd_setpixel(top - radius, left);
	while(x < y) {
		if(f >= 0) {
			y--;
			ddF_y += 2;
			f += ddF_y;
		}
		x++;
		ddF_x += 2;
		f += ddF_x + 1;
		lcd_setpixel(top + x, left + y);
		lcd_setpixel(top - x, left + y);
		lcd_setpixel(top + x, left - y);
		lcd_setpixel(top - x, left - y);
		lcd_setpixel(top + y, left + x);
		lcd_setpixel(top - y, left + x);
		lcd_setpixel(top + y, left - x);
		lcd_setpixel(top - y, left - x);
	}
}
/**********************************************************
           Write a string at current screen position
**********************************************************/
void lcd_str(char lcd_row, char lcd_col, const char *str, char attribute) {

	char i=0;
	lcd_col += 18;
  while (*str) {
		lcd_chr(lcd_row, lcd_col+i, *str++, attribute); 
		i+=6;
	}
	
}
I didnt touch lcd_chr just incase it gets called somewhere else in the future
Attached Thumbnails
Graphic LCD 96x64 w/ SED1565 Controller-menu.jpg  

Last edited by AtomSoft; 21st June 2009 at 12:23 AM.
AtomSoft is online now  
Old 21st June 2009, 12:59 AM   #147
Default

Jason: that will work. you can also use the lcd_setrect() function to draw a box.

I didn't +18 so the same code can be ported to true sed1565-based displays.
millwood is offline  
Old 21st June 2009, 01:05 AM   #148
Default

oh ok i see now... lol

you can simply add :
Code:
#ifdef NOKIA7110
	left += 18;
#endif
remember to
Code:
#define NOKIA7110
Code:
/**********************************************************
           Write a string at current screen position
**********************************************************/
void lcd_str(char lcd_row, char lcd_col, const char *str, char attribute) {

	char i=0;
#ifdef NOKIA7110
	lcd_col += 18;
#endif
  while (*str) {
		lcd_chr(lcd_row, lcd_col+i, *str++, attribute); 
		i+=6;
	}
	
}

/**********************************************************
           draw a line between two points
					 code shamelessly stolen from Jim Lynch's 6100 driver
					 which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setline(char top0, char left0, char top1, char left1) {

	int dy;
	int dx;
	int stepx, stepy;

#ifdef NOKIA7110
   	left0 += 18;
	left1 += 18;
#endif
	dy = left1 - left0;
	dx = top1 - top0;

	if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
	if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
	dy <<= 1; // dy is now 2*dy
	dx <<= 1; // dx is now 2*dx
	lcd_setpixel(top0, left0);
	
	if (dx > dy) {
		int fraction = dy - (dx >> 1); // same as 2*dy - dx
		while (top0 != top1) {
			if (fraction >= 0) {
				left0 += stepy;
				fraction -= dx; // same as fraction -= 2*dx
			}
			top0 += stepx;
			fraction += dy; // same as fraction -= 2*dy
			lcd_setpixel(top0, left0);
		}
	} else {
		int fraction = dx - (dy >> 1);
		while (left0 != left1) {
			if (fraction >= 0) {
				top0 += stepx;
				fraction -= dy;
			}
			left0 += stepy;
			fraction += dx;
			lcd_setpixel(top0, left0);
		}
	}
}
/**********************************************************
           draw a circle between two points
					 code shamelessly stolen from Jim Lynch's 6100 driver
					 which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setcircle(char top, char left, char radius) {

	int f = 1 - radius;
	int ddF_x = 0;
	int ddF_y = -2 * radius;
	int x = 0;
	int y = radius;
#ifdef NOKIA7110
	left += 18;
#endif
	lcd_setpixel(top, left + radius);
	lcd_setpixel(top, left - radius);
	lcd_setpixel(top + radius, left);
	lcd_setpixel(top - radius, left);
	while(x < y) {
		if(f >= 0) {
			y--;
			ddF_y += 2;
			f += ddF_y;
		}
		x++;
		ddF_x += 2;
		f += ddF_x + 1;
		lcd_setpixel(top + x, left + y);
		lcd_setpixel(top - x, left + y);
		lcd_setpixel(top + x, left - y);
		lcd_setpixel(top - x, left - y);
		lcd_setpixel(top + y, left + x);
		lcd_setpixel(top - y, left + x);
		lcd_setpixel(top + y, left - x);
		lcd_setpixel(top - y, left - x);
	}
}
This is what happens when you dont define the NOKIA7110...


and when you do:


EDIT

what setrect?
I didnt get that code
Attached Thumbnails
Graphic LCD 96x64 w/ SED1565 Controller-menu.jpg   Graphic LCD 96x64 w/ SED1565 Controller-nodefine.jpg  

Last edited by AtomSoft; 21st June 2009 at 01:11 AM.
AtomSoft is online now  
Old 21st June 2009, 01:38 AM   #149
Default

sorry, I may have added it after I posted it.

here is the latest. I just started but haven't finished yet the bmp function, lcd_setbmp(), so as is the program doesn't compile.
Attached Files
File Type: zip Nokia 7110.zip (6.2 KB, 23 views)
millwood is offline  
Old 21st June 2009, 01:39 AM   #150
Default

it would be easier and more flexible to just drop the bmp, but it will take up tons of memory - a trade-off.
millwood is offline  
Reply

Tags
96x64, controller, graphic, lcd, nokia7110, sed1565, w or

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Graphic LCD baberjaved Micro Controllers 2 13th November 2007 05:01 PM
Graphic LCD flemmard Micro Controllers 1 13th September 2007 03:32 AM
interfacing of PIC16F877A with graphic LCD controller T6963c rosamma Micro Controllers 1 24th March 2007 12:29 PM
graphic LCD PIC MCU tom_electronic Micro Controllers 4 28th February 2006 12:29 PM
graphic lcd help jijita General Electronics Chat 1 18th August 2004 07:32 AM



All times are GMT. The time now is 04:42 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker