Fork of Dimiter program. "Wait" commands adjusted and added Arial 10 font.
Fork of KS0108 by
Diff: KS0108.cpp
- Revision:
- 2:03d27b3fce6e
- Parent:
- 1:a368f2688222
- Child:
- 3:366a6b7d6259
diff -r a368f2688222 -r 03d27b3fce6e KS0108.cpp --- a/KS0108.cpp Wed Jan 05 00:01:45 2011 +0000 +++ b/KS0108.cpp Fri Jan 28 01:08:45 2011 +0000 @@ -43,7 +43,7 @@ DI.write(0); RW.write(0); - SelectSide(side); + SelectSide(side); //select controller wait(0.0000003); // 300ns E.write(1); @@ -55,7 +55,7 @@ void KS0108::WriteData(unsigned int data,unsigned char side){ - E.write(0); + E.write(0); DI.write(1); RW.write(0); @@ -321,7 +321,7 @@ // If the starting X coordinate is larger than the ending X coordinate, - // then swap the start and end coordinates. + // swap the start and end coordinates. if(lX1 > lX2){ lError = lX1; lX1 = lX2; @@ -331,7 +331,7 @@ lY2 = lError; } - // Compute the difference between the start and end coordinates in each axis. + // Compute the difference between the start and end coordinates. lDeltaX = lX2 - lX1; lDeltaY = (lY2 > lY1) ? (lY2 - lY1) : (lY1 - lY2); @@ -562,7 +562,24 @@ } } - +void KS0108::CustomImage(Image* image,unsigned int x, unsigned int y, unsigned int color){ + unsigned int i, j, bit_idx, pixelByte, imgHeight, imgSize; + + imgHeight = image->imgHeight; //get height of the image array + imgSize = (image->imgWidth)>>3; //number of bytes = width of icon/8 + + for(i=0;i<imgHeight;i++){ + for(j=0;j<imgSize;j++){ + pixelByte = image->imgarray[i*imgSize+j]; + for(bit_idx=0;bit_idx<8;bit_idx++){ + if(pixelByte&(0x80>>bit_idx)) + SetPixel(x+bit_idx+8*j, y+i, color) + else + SetPixel(x+bit_idx+8*j, y+i, !color); + } + } + } +} /******************************************************************************************/