Library for interfacing to Nokia 5110 LCD display (as found on the SparkFun website).

Dependents:   LV7_LCDtest LV7_Grupa5_Tim003_Zadatak1 lv7_Grupa5_Tim008_zad1 LV7_PAI_Grupa5_tim10_Zadatak1 ... more

This library is designed to make it easy to interface an mbed with a Nokia 5110 LCD display.

These can be found at Sparkfun (https://www.sparkfun.com/products/10168) and Adafruit (http://www.adafruit.com/product/338).

The library uses the SPI peripheral on the mbed which means it is much faster sending data to the display than other libraries available on other platforms that use software SPI.

The library can print strings as well as controlling individual pixels, meaning that both text and primitive graphics can be displayed.

Revision:
37:c708b92609aa
Parent:
36:00ebd449b6f3
Child:
40:c9262294f2e1
--- a/N5110.h	Tue Mar 07 16:55:43 2017 +0000
+++ b/N5110.h	Tue Mar 07 16:59:03 2017 +0000
@@ -57,9 +57,22 @@
 #include "mbed.h"
 #include "N5110.h"
 
+//      rows,cols
+int sprite[8][5] =   {
+    { 0,0,1,0,0 },
+    { 0,1,1,1,0 },
+    { 0,0,1,0,0 },
+    { 0,1,1,1,0 },
+    { 1,1,1,1,1 },
+    { 1,1,1,1,1 },
+    { 1,1,0,1,1 },
+    { 1,1,0,1,1 },
+};
+
 //    VCC,SCE,RST,D/C,MOSI,SCLK,LED
 //N5110 lcd(p7,p8,p9,p10,p11,p13,p21);  // LPC1768 - pwr from GPIO
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);  // K64F - pwr from 3V3
+N5110 lcd(p8,p9,p10,p11,p13,p21);  // LPC1768 - powered from +3V3 - JP1 in 2/3 position
+//N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);  // K64F - pwr from 3V3
 
 int main()
 {
@@ -72,6 +85,12 @@
         lcd.normalMode();      // normal colour mode
         lcd.setBrightness(0.5); // put LED backlight on 50%
 
+        lcd.clear();
+        // x origin, y origin, rows, cols, sprite 
+        lcd.drawSprite(20,6,8,5,(int *)sprite);
+        lcd.refresh();
+        wait(5.0);
+
         lcd.clear(); // clear buffer at start of every loop
         // can directly print strings at specified co-ordinates (must be less than 84 pixels to fit on display)
         lcd.printString("Hello, World!",0,0);
@@ -101,6 +120,14 @@
         lcd.refresh();
         wait(5.0);
 
+        for(int i = 0; i < 3; i++) {
+            for(int j = 0; j < 5; j++) {
+                printf("%d,%d = %d\n",i,j,glyph[i][j]);
+            }
+        }
+
+     
+
         // can check status of pixel using getPixel(x,y);
         lcd.clear();  // clear buffer
         lcd.setPixel(2,2);  // set random pixel in buffer
@@ -109,8 +136,6 @@
 
         int pixel_to_test = lcd.getPixel(2,2);
 
-        printf("2,2 Pixel value = %i\n",pixel_to_test);
-
         if ( pixel_to_test ) {
             lcd.printString("2,2 is set",0,4);
         }
@@ -118,8 +143,6 @@
         // this one shouldn't be set
         pixel_to_test = lcd.getPixel(3,3);
 
-        printf("3,3 Pixel value = %i\n",pixel_to_test);
-
         if ( pixel_to_test == 0 ) {
             lcd.printString("3,3 is clear",0,5);
         }
@@ -169,12 +192,14 @@
         //          origin x,y,width,height,type
         lcd.drawRect(10,10,50,30,FILL_BLACK);  // filled black rectangle
         lcd.drawRect(15,15,20,10,FILL_WHITE);  // filled white rectange (no outline)
-        lcd.drawRect(2,2,70,40,  FILL_TRANSPARENT);    // transparent, just outline
+        lcd.drawRect(2,2,70,40,FILL_TRANSPARENT);    // transparent, just outline
         lcd.refresh();  // refresh after drawing shapes
         wait(5.0);
+
     }
 }
 
+
 @endcode
 */
 class N5110