ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Revision:
23:9be87557b89a
Parent:
1:0001cb3eb053
Child:
24:67dc71a8f009
--- a/N5110/N5110.h	Mon May 06 11:21:39 2019 +0000
+++ b/N5110/N5110.h	Wed May 08 08:46:11 2019 +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
@@ -388,6 +413,21 @@
                   unsigned int const height,
                   FillType const     fill);
 
+    /** Draw Sprite
+    *
+    *   This function draws a sprite as defined in a 2D array
+    *   @param  x0 - x-coordinate of origin (top-left)
+    *   @param  y0 - y-coordinate of origin (top-left)
+    *   @param  nrows - number of rows in sprite
+    *   @param  ncols - number of columns in sprite
+    *   @param  sprite - 2D array representing the sprite
+    */
+    void drawSprite(int x0,
+                    int y0,
+                    int nrows,
+                    int ncols,
+                    int *sprite);
+                    
 private:
 // methods
     void setXYAddress(unsigned int const x,