Simple library for interfacing to Nokia 5110 LCD display (as found on the SparkFun website). Created by Craig A. Evans, University of Leeds.

Fork of N5110 by Craig Evans

Files at this revision

API Documentation at this revision

Comitter:
eencae
Date:
Mon May 19 18:45:48 2014 +0000
Parent:
7:3010f24e0a81
Child:
9:7701f0126ba7
Commit message:
Added plot function (untested).

Changed in this revision

N5110.cpp Show annotated file Show diff for this revision Revisions of this file
N5110.h Show annotated file Show diff for this revision Revisions of this file
--- a/N5110.cpp	Mon May 19 18:23:21 2014 +0000
+++ b/N5110.cpp	Mon May 19 18:45:48 2014 +0000
@@ -261,4 +261,21 @@
             buffer[i][j]=0;
         }
     }
+}
+
+// function to plot array on display
+void N5110::plotArray(float array[]) {
+    
+    int i;
+    
+    for (i=0; i<84; i++) {  // loop through array
+        // 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);
+    }    
+    
+    refresh();
+    
+    
 }
\ No newline at end of file
--- a/N5110.h	Mon May 19 18:23:21 2014 +0000
+++ b/N5110.h	Mon May 19 18:45:48 2014 +0000
@@ -193,6 +193,15 @@
     *   TODO: Randomise the seed - maybe using the noise on the AnalogIn pins.
     */
     void randomiseBuffer();
+    
+    /** Plot Array
+    *
+    *   This function plots a one-dimensional array on the display. The values in the array
+    *   correspond to the y values of the plot and these are plotted along the x-axis (one
+    *   value per pixel along the x-axis of the display. This means only the first 84 values are 
+    *   plotted. y values in the array should be normalised in the range 0.0 to 1.0. 
+    */
+    void plotArray(float array[]);
 
 private:
     void initSPI();