Driver for the range of Nokia 130x130 displays as found on Sparkfun and Olimex breakout boards, supporting the 6100, 6610 and PCF8833 drivers

Dependents:   NokiaLCD_HelloWorld SpectrumAnalyzer MARMEX_OB_oled__HelloWorld GMT_counter ... more

Files at this revision

API Documentation at this revision

Comitter:
simon
Date:
Fri Nov 19 22:07:46 2010 +0000
Parent:
0:ff874f85ed33
Child:
2:2d1b23692cbb
Commit message:
Updated 6610 to support new Sparkfun breakout

Changed in this revision

NokiaLCD.cpp Show annotated file Show diff for this revision Revisions of this file
NokiaLCD.h Show annotated file Show diff for this revision Revisions of this file
--- a/NokiaLCD.cpp	Wed Jun 09 08:02:04 2010 +0000
+++ b/NokiaLCD.cpp	Fri Nov 19 22:07:46 2010 +0000
@@ -312,8 +312,26 @@
 void NokiaLCD::fill(int x, int y, int width, int height, int colour) {
     _cs = 0;
     _window(x, y, width, height);
-    for (int i=0; i<width*height; i++) {
-        _putp(colour);
+    switch (_type) {
+        case LCD6100:
+        case PCF8833:
+            for (int i=0; i<width*height; i++) {
+                _putp(colour);
+            }
+            break;
+        case LCD6610:
+            for (int i=0; i<width*height/2; i++) {
+                int r4 = (colour >> (16 + 4)) & 0xF;
+    	        int g4 = (colour >> (8 + 4)) & 0xF;
+                int b4 = (colour >> (0 + 4)) & 0xF;
+        	    int d1 = (r4 << 4) | g4;
+                int d2 = (b4 << 4) | r4;
+                int d3 = (g4 << 4) | b4;
+                data(d1); 
+    	        data(d2);   
+    	        data(d3);
+            }
+            break;
     }
     _window(0, 0, NOKIALCD_WIDTH, NOKIALCD_HEIGHT);
     _cs = 1;
@@ -322,9 +340,32 @@
 void NokiaLCD::blit(int x, int y, int width, int height, const int* colour) {
     _cs = 0;
     _window(x, y, width, height);
-    for (int i=0; i<width*height; i++) {
-        _putp(colour[i]);
-    }
+
+    switch (_type) {
+        case LCD6100:
+        case PCF8833:
+            for (int i=0; i<width*height; i++) {
+                 _putp(colour[i]);
+             }
+             break;
+        case LCD6610:
+            for (int i=0; i<width*height/2; i++) {
+        	    int r41 = (colour[i*2] >> (16 + 4)) & 0xF;
+        	    int g41 = (colour[i*2] >> (8 + 4)) & 0xF;
+        	    int b41 = (colour[i*2] >> (0 + 4)) & 0xF;
+    	   
+                int r42 = (colour[i*2+1] >> (16 + 4)) & 0xF;
+        	    int g42 = (colour[i*2+1] >> (8 + 4)) & 0xF;
+        	    int b42 = (colour[i*2+1] >> (0 + 4)) & 0xF;   
+        	    int d1 = (r41 << 4) | g41;
+        	    int d2 = (b41 << 4) | r42;
+        	    int d3 = (g42 << 4) | b42;               
+       	        data(d1); 
+    	        data(d2); 
+    	        data(d3); 
+            }
+            break;
+     }            
     _window(0, 0, NOKIALCD_WIDTH, NOKIALCD_HEIGHT);
     _cs = 1;
 }
@@ -332,12 +373,42 @@
 void NokiaLCD::bitblit(int x, int y, int width, int height, const char* bitstream) {
     _cs = 0;
     _window(x, y, width, height);
-    for (int i=0; i<height*width; i++) {
-        int byte = i / 8;
-        int bit = i % 8;
-        int colour = ((bitstream[byte] << bit) & 0x80) ? _foreground : _background;
-        _putp(colour);
-    }
+
+    switch (_type) {
+        case LCD6100:
+        case PCF8833:
+            for (int i=0; i<height*width; i++) {
+                int byte = i / 8;
+                int bit = i % 8;
+                int colour = ((bitstream[byte] << bit) & 0x80) ? _foreground : _background;
+                _putp(colour);
+            }
+            break;
+        case LCD6610:
+            for(int i=0; i<height*width/2; i++) {
+                int byte1 = (i*2) / 8;
+                int bit1 = (i*2) % 8;   
+        	    int colour1 = ((bitstream[byte1] << bit1) & 0x80) ? _foreground : _background;
+        	    int byte2 = (i*2+1) / 8;
+                int bit2 = (i*2+1) % 8;   
+                int colour2 = ((bitstream[byte2] << bit2) & 0x80) ? _foreground : _background;
+	
+        	    int r41 = (colour1 >> (16 + 4)) & 0xF;
+        	    int g41 = (colour1 >> (8 + 4)) & 0xF;
+        	    int b41 = (colour1 >> (0 + 4)) & 0xF;
+    	   
+                int r42 = (colour2 >> (16 + 4)) & 0xF;
+        	    int g42 = (colour2 >> (8 + 4)) & 0xF;
+        	    int b42 = (colour2 >> (0 + 4)) & 0xF;   
+        	    int d1 = (r41 << 4) | g41;
+        	    int d2 = (b41 << 4) | r42;
+        	    int d3 = (g42 << 4) | b42;               
+       	        data(d1); 
+    	        data(d2); 
+    	        data(d3); 
+            }
+            break;
+     }
     _window(0, 0, _width, _height);
     _cs = 1;
 }
--- a/NokiaLCD.h	Wed Jun 09 08:02:04 2010 +0000
+++ b/NokiaLCD.h	Fri Nov 19 22:07:46 2010 +0000
@@ -98,7 +98,6 @@
     void foreground(int c);
     void background(int c);
 
-
 protected:
     virtual void _window(int x, int y, int width, int height);
     virtual void _putp(int colour);