![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #136 |
|
NICE! dude thats awesome
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #137 |
|
how do you call it? Whats top, left, x,y ? x0 = ? x1 = ? y0 = ? y1 = ?
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #138 |
|
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);
}
}
| |
| |
| | #139 | |
| Quote:
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. | ||
| |
| | #140 |
|
lol i meant the calling it: Does: x0= top x1= left y0= right y1= bottom ? how do you figure it out?
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #141 |
|
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);
}
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 20th June 2009 at 10:48 PM. | |
| |
| | #142 |
| 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. | |
| |
| | #143 |
|
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
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #144 | |
| Quote:
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);
}
}
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | ||
| |
| | #145 |
|
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);
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #146 |
|
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); 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;
}
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 21st June 2009 at 12:23 AM. | |
| |
| | #147 |
|
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. | |
| |
| | #148 |
|
oh ok i see now... lol you can simply add : Code: #ifdef NOKIA7110 left += 18; #endif 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);
}
}
![]() and when you do: ![]() EDIT what setrect? I didnt get that code
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 21st June 2009 at 01:11 AM. | |
| |
| | #149 |
|
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. | |
| |
| | #150 |
|
it would be easier and more flexible to just drop the bmp, but it will take up tons of memory - a trade-off.
| |
| |
|
| 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 |