#include #include #include #include #include #include "8x12_horizontal_MSB_1.h" #include "global.h" #include "lcd.h" unsigned char * const mem=(unsigned char * const)DDRAM; unsigned char cgram[16][8]; unsigned char viewstart; void lcd_init(void) { cli(); wdt_disable(); #ifdef WAITSTATE MCUCR=(1<0) sdx=1; else { sdx=-1; dx=-dx; } if (dy==0) sdy=0; if (dy>0) sdy=1; else { sdy=-1; dy=-dy; } x=dx*2; y=dy*2; px=x1; py=y1; lcd_setpixel (px,py,color); if (dx>=dy) // the line is more horizontal than vertical { for(i=0;i=dx) { y-=dx; py+=sdy; } px+=sdx; lcd_setpixel (px,py,color); } } else // the line is more vertical than horizontal { for(i=0;i=dy) { x-=dy; px+=sdx; } py+=sdy; lcd_setpixel (px,py,color); } } } void lcd_line (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char color) { unsigned short temp; if (y1==y2) { if (x1>x2) { temp=x1; x1=x2; x2=temp; } for (temp=x1; temp<=x2; temp++) lcd_setpixel (temp,y1,color); } else if (x1==x2) { if (y1>y2) { temp=y1; y1=y2; y2=temp; } for (temp=y1; temp<=y2; temp++) lcd_setpixel (x1,temp,color); } else bresenham_line (x1, y1, x2, y2, color); } void lcd_circle(unsigned short xm, unsigned short ym, unsigned char r, unsigned char color1, unsigned char color2) { unsigned short x; unsigned char y=r; signed short p; if ((r>xm)||(r>ym)||(r<1)) return; y=r; p=(3-(2*r)); for (x=0; x<=y; x++) { lcd_line(xm-x,ym+y,xm+x,ym+y,color1); lcd_line(xm-x,ym-y,xm+x,ym-y,color1); lcd_line(xm-y,ym+x,xm+y,ym+x,color1); lcd_line(xm-y,ym-x,xm+y,ym-x,color1); if(p<0) p+=((4*x)+6); else { y--; p+=((4*(x-y))+10); } } y=r; p=(3-(2*r)); for (x=0; x<=y; x++) { lcd_setpixel((xm+x),(ym+y),color2); lcd_setpixel((xm+y),(ym+x),color2); lcd_setpixel((xm+y),(ym-x),color2); lcd_setpixel((xm+x),(ym-y),color2); lcd_setpixel((xm-x),(ym-y),color2); lcd_setpixel((xm-y),(ym-x),color2); lcd_setpixel((xm-y),(ym+x),color2); lcd_setpixel((xm-x),(ym+y),color2); if(p<0) p+=((4*x)+6); else { y--; p+=((4*(x-y))+10); } } } void lcd_block (unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char color1, unsigned char color2) { unsigned short y; if (x2>x1+1) { for (y=y1+1; yXSIZE) xend=XSIZE; //Bitmap abschneiden wenn außerhalb des Displays bwidth=width/8; //Anzahl Bytes horizontal /8 if((width%8)!=0) bwidth++; //Bei Rest noch ein Byte mehr yp=ypos; for(i=0; i>=1; //Nächstes Bit }//for k bitmap++; } //for j yp++; //Nächste Zeile } //for i } */ //########################################################## // Loads a bitmap from FLASH in 4 graustufen void LoadBitmap_4gray(unsigned const char *bitmap,unsigned short xpos , unsigned char ypos, unsigned short width, unsigned char height) //########################################################## { unsigned char i,j,k; unsigned char mask,bwidth,yp; unsigned char by; unsigned short xend,xp; xend=(unsigned short)xpos + (unsigned short)width; if(xend>XSIZE) xend=XSIZE; //Bitmap abschneiden wenn außerhalb des Displays bwidth=width/8; //Anzahl Bytes horizontal /8 if((width%8)!=0) bwidth++; //Bei Rest noch ein Byte mehr yp=ypos; for(i=0; i>=1; //Nächstes Bit }//for k bitmap++; } //for j yp++; //Nächste Zeile } //for i } //########################################################## // Loads a bitmap from FLASH in 8 graustufen void LoadBitmap_8gray(unsigned const char *bitmap,unsigned short xpos , unsigned char ypos, unsigned short width, unsigned char height) //########################################################## { unsigned char i,j,k; unsigned char mask,bwidth,yp; unsigned char by; unsigned short xend,xp; xend=(unsigned short)xpos + (unsigned short)width; if(xend>XSIZE) xend=XSIZE; //Bitmap abschneiden wenn außerhalb des Displays bwidth=width/8; //Anzahl Bytes horizontal /8 if((width%8)!=0) bwidth++; //Bei Rest noch ein Byte mehr yp=ypos; for(i=0; i>=1; //Nächstes Bit }//for k bitmap++; } //for j yp++; //Nächste Zeile } //for i } void lcd_setstartx(unsigned char pos) { #ifdef GRAYSCALE if (pos>24) pos=24; pos*=2; #else if (pos>88) pos=88; pos*=2; #endif viewstart=pos; }