Fork of LCD-Window which works with Enhanced TextLCD from Wim

Fork of LcdWindow by Hendrik Lipka

Revision:
2:5ac5bab7daaf
Parent:
1:65f72ed914fa
Child:
3:e5d5e2fe4bf6
--- a/ks0108_8bit.cpp	Tue Nov 16 20:49:18 2010 +0000
+++ b/ks0108_8bit.cpp	Sat Nov 27 22:54:13 2010 +0000
@@ -30,11 +30,10 @@
 
 #define ENABLE 1
 
-void KS0108LCD8bit::writeText(const unsigned int line, const unsigned int pos, const char text[]) {
-    printf("print to %d,%d {%s}\n",line,pos,text);
+void KS0108LCD8bit::writeText(const unsigned int column, const unsigned int row, const char text[]) {
     int i=0;
     while (text[i]!=0) {
-        setChar(line, pos+i,text[i]);
+        character(column+i, row,text[i]);
         i++;
     }
 }
@@ -48,10 +47,10 @@
 void KS0108LCD8bit::clearHalf(DigitalOut* cs) {
     for (int x=0;x<8;x++)
     {
+        sendCmd(0xb8|x,cs); 
+        wait_us(1);    
         for (int y=0;y<64;y++)
         {
-            sendCmd(0xb8|x,cs); 
-            wait_us(1);    
             sendCmd(0x40|y,cs); 
             wait_us(1);    
             sendData(0,cs);
@@ -60,13 +59,13 @@
     }
 }
 
-void KS0108LCD8bit::setChar(const unsigned int line, const unsigned int pos, const char c) {
+void KS0108LCD8bit::character(int column, int row, int c){
     DigitalOut* cs=NULL;
-    int column=pos;
-    if (column>7)
+    int icolumn=column;
+    if (icolumn>7)
     {
         cs=_right;
-        column-=8;
+        icolumn-=8;
     }
     else
     {
@@ -75,9 +74,9 @@
     if (NULL==cs)
         return;
     
-    sendCmd(0xb8|line,cs); // set x page    
+    sendCmd(0xb8|row,cs); // set x page    
 
-    unsigned int y=column*8;
+    unsigned int y=icolumn*8;
     sendCmd(0x40|y,cs); // set start line
     
     // send character data
@@ -89,8 +88,8 @@
 }
 
 KS0108LCD8bit::KS0108LCD8bit
-(const unsigned int width, const unsigned int height, BusOut *data, const PinName enable, const PinName rs, const PinName leftCS, const PinName rightCS)
-        :TextLCDBase(width, height) {
+(const unsigned int columns, const unsigned int rows, BusOut *data, const PinName enable, const PinName rs, const PinName leftCS, const PinName rightCS)
+        :TextLCDBase(columns, rows) {
     _data=data;
     _rs=new DigitalOut(rs);
     _enable=new DigitalOut(enable);
@@ -118,7 +117,6 @@
         wait_ms(10);
         sendCmd(0xc0, _right);
     }
-    printf("left vs. right: %d / %d\n",_left,_right);
     wait_ms(50);
     clear();
 }
@@ -139,7 +137,6 @@
 
 void KS0108LCD8bit::sendByte(const unsigned char byte, DigitalOut *cs) {
     // display reads flags with rising flank of E
-//    printf("send to %d\n",cs);
     _enable->write(0);
     cs->write(ENABLE);
     _data->write(byte);