Simple library for interfacing to Nokia 5110 LCD display (as found on the SparkFun website). revised to clear a circle when required with typecirc integer
Dependents: L2_2645_project Space_Teroid_Game
Fork of N5110 by
Diff: N5110.cpp
- Revision:
- 18:7aaa6802ce64
- Parent:
- 17:780a542d5f8b
--- a/N5110.cpp Tue Mar 17 12:56:03 2015 +0000 +++ b/N5110.cpp Fri May 08 09:24:39 2015 +0000 @@ -285,7 +285,7 @@ } // function to draw circle -void N5110:: drawCircle(int x0,int y0,int radius,int fill) +void N5110:: drawCircle(int x0,int y0,int radius,int fill,int typecirc) { // from http://en.wikipedia.org/wiki/Midpoint_circle_algorithm int x = radius; @@ -294,6 +294,7 @@ while(x >= y) { +if (typecirc == 1){ // if transparent, just draw outline if (fill == 0) { setPixel( x + x0, y + y0); @@ -313,7 +314,28 @@ drawLine(y+x0,-x+y0,-y+x0,-x+y0,type); drawLine(x+x0,-y+y0,-x+x0,-y+y0,type); } + } + else +{ + if (fill == 0) { + clearPixel( x + x0, y + y0); + clearPixel(-x + x0, y + y0); + clearPixel( y + x0, x + y0); + clearPixel(-y + x0, x + y0); + clearPixel(-y + x0, -x + y0); + clearPixel( y + x0, -x + y0); + clearPixel( x + x0, -y + y0); + clearPixel(-x + x0, -y + y0); + } else { // drawing filled circle, so draw lines between points at same y value + int type = (fill==1) ? 1:0; // black or white fill + + drawLine(x+x0,y+y0,-x+x0,y+y0,type); + drawLine(y+x0,x+y0,-y+x0,x+y0,type); + drawLine(y+x0,-x+y0,-y+x0,-x+y0,type); + drawLine(x+x0,-y+y0,-x+x0,-y+y0,type); + } + } y++; if (radiusError<0) { @@ -376,14 +398,23 @@ refresh(); } -void N5110::drawRect(int x0,int y0,int width,int height,int fill) + +void N5110::drawRectc(int x0,int y0,int width,int height,int fill,int typo) { if (fill == 0) { // transparent, just outline + if(typo == 1){ drawLine(x0,y0,x0+width,y0,1); // top drawLine(x0,y0+height,x0+width,y0+height,1); // bottom drawLine(x0,y0,x0,y0+height,1); // left drawLine(x0+width,y0,x0+width,y0+height,1); // right + } + if(typo == 0){ + drawLine(x0,y0,x0+width,y0,0); // top + drawLine(x0,y0+height,x0+width,y0+height,0); // bottom + drawLine(x0,y0,x0,y0+height,0); // left + drawLine(x0+width,y0,x0+width,y0+height,0); // right + } } else { // filled rectangle int type = (fill==1) ? 1:0; // black or white fill for (int y = y0; y<= y0+height; y++) { // loop through rows of rectangle