Mohammed Al Mahrouqi / N5110

Fork of N5110 by Craig Evans

Files at this revision

API Documentation at this revision

Comitter:
eencae
Date:
Tue May 20 19:43:52 2014 +0000
Parent:
8:40abe5736eca
Child:
10:6f3abb40202b
Commit message:
printString() has been modified. Rather than sending the string to the display using the printChar(), it now writes the character bitmap data to the screen buffer and refreshes the display. This means that pixels and strings can now be used together.

Changed in this revision

N5110.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/N5110.cpp	Mon May 19 18:45:48 2014 +0000
+++ b/N5110.cpp	Tue May 20 19:43:52 2014 +0000
@@ -237,11 +237,21 @@
     // loop through string and print character
     while(*str) {
 
-        setXYAddress(x+6*n,y);  // leave 1 pixel (6 = 5 + 1) between each character
-        printChar(*str);   // print the char - can probably do *str++ and remove next line
+        // This is the old version - strings are printed using the printChar function
+        //setXYAddress(x+6*n,y);  // leave 1 pixel (6 = 5 + 1) between each character
+        //printChar(*str);   // print the char - can probably do *str++ and remove next line
+        
+        // the new version writes the character bitmap data to the buffer, so that
+        // text and pixels can be displayed at the same time
+        for (int i = 0; i < 5 ; i++ ) {
+            buffer[x+i+n*6][y] = font5x7[(*str - 32)*5 + i];
+        }
+        
         str++;  // go to next character in string
         n++;    // increment index
     }
+    
+    refresh();  // this sends the buffer to the display and sets address (cursor) back to 0,0
 
 }
 
@@ -272,7 +282,7 @@
         // elements are normalised from 0.0 to 1.0, so multiply
         // by 47 to convert to pixel range, and subtract from 47
         // since top-left is 0,0 in the display geometry
-        setPixel(i,47 - (int) array[i]*47.0);
+        setPixel(i,47 - int(array[i]*47.0));
     }    
     
     refresh();