Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: PORGFINAL SpaceInvadersFINAL
Fork of NokiaLCD by
Revision 3:65a915f69fa2, committed 2013-03-05
- Comitter:
- zlee9
- Date:
- Tue Mar 05 20:29:31 2013 +0000
- Parent:
- 2:2d1b23692cbb
- Commit message:
- Final Version of Space Invaders
Changed in this revision
| NokiaLCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/NokiaLCD.cpp Fri Nov 19 22:12:28 2010 +0000
+++ b/NokiaLCD.cpp Tue Mar 05 20:29:31 2013 +0000
@@ -9,7 +9,7 @@
#define NOKIALCD_ROWS 16
#define NOKIALCD_COLS 16
#define NOKIALCD_WIDTH 130
-#define NOKIALCD_HEIGHT 130
+#define NOKIALCD_HEIGHT 132
#define NOKIALCD_FREQUENCY 5000000
NokiaLCD::NokiaLCD(PinName mosi, PinName sclk, PinName cs, PinName rst, LCDType type)
@@ -67,7 +67,7 @@
case LCD6610:
command(0xCA); // display control
data(0);
- data(31);
+ data(32);
data(0);
command(0xBB);
data(1);
@@ -115,7 +115,7 @@
}
void NokiaLCD::_window(int x, int y, int width, int height) {
- int x1 = x + 2;
+ int x1=x+0;
int y1 = y + 0;
int x2 = x1 + width - 1;
int y2 = y1 + height - 1;
@@ -302,10 +302,31 @@
_cs = 1;
}
+
void NokiaLCD::pixel(int x, int y, int colour) {
_cs = 0;
_window(x, y, 1, 1);
- _putp(colour);
+ switch (_type) {
+ case LCD6100:
+ case PCF8833:
+
+ _putp(colour);
+
+ break;
+ case LCD6610:
+
+ 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;
+ }
_cs = 1;
}
@@ -322,14 +343,14 @@
case LCD6610:
for (int i=0; i<width*height/2; i++) {
int r4 = (colour >> (16 + 4)) & 0xF;
- int g4 = (colour >> (8 + 4)) & 0xF;
+ int g4 = (colour >> (8 + 4)) & 0xF;
int b4 = (colour >> (0 + 4)) & 0xF;
- int d1 = (r4 << 4) | g4;
+ int d1 = (r4 << 4) | g4;
int d2 = (b4 << 4) | r4;
int d3 = (g4 << 4) | b4;
data(d1);
- data(d2);
- data(d3);
+ data(d2);
+ data(d3);
}
break;
}
@@ -350,19 +371,19 @@
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 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);
+ 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;
}
@@ -388,24 +409,24 @@
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 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 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);
+ 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;
}
