a modified version of N5110 library to be used with freescale boards

Fork of N5110 by francesco fantoni

Revision:
7:77bd2c73fe41
Parent:
6:adb79338d40f
Child:
8:2993b19ba7dd
diff -r adb79338d40f -r 77bd2c73fe41 N5110.h
--- a/N5110.h	Mon Jan 27 18:41:45 2014 +0000
+++ b/N5110.h	Thu May 22 21:50:41 2014 +0200
@@ -32,7 +32,18 @@
 #define CMD_VOP_6V06           0xB2
 #define CMD_VOP_7V38           0xC8
 
+// LCD Characteristics
+#define LCD_FREQ 2000000
+#define LCD_SPI_MODE 0x01
+#define LCD_SPI_BITS 0x08
+#define LCD_X_MAX 84
+#define LCD_Y_MAX 48
+
+// MATH CONSTANTS
+//# define PI           3.14159265358979323846  /* pi */
+
 #include "mbed.h"
+#include <math.h>
 
 /** 
 @brief Simple library for interfacing with Nokia 5110 LCD display (https://www.sparkfun.com/products/10168) using the hardware SPI on the mbed.
@@ -142,6 +153,8 @@
     */
     void printString(const char * str,int x,int y);
     
+    void printNegString(const char * str,int x,int y);
+
     /** Print Character
     *
     *   Sends a character to the display.  Will be printed at the current address.
@@ -150,6 +163,8 @@
     */
     void printChar(char c);
     
+    void printNegChar(char c);
+
     /** Set a Pixel
     *
     *   This function sets a pixel in the display. A call to refresh() must be made
@@ -166,6 +181,21 @@
     *   @param  x - the x co-ordinate of the pixel (0 to 83)
     *   @param  y - the y co-ordinate of the pixel (0 to 47) 
     */
+
+    void drawHline(int x, int y, int l);
+
+    void drawVline(int x, int y, int l);
+
+    void drawRectangle(int x, int y, int w, int h);
+
+    void drawGrid(int stepx, int stepy);
+
+    void drawLine(int x0, int y0, int x1, int y1);
+
+    void drawLineAngle(int x0, int y0, int l, float angle);
+
+    void drawCircle(int x, int y, int radius, int divisions);
+
     void clearPixel(int x, int y);
     
     /** Get a Pixel
@@ -195,7 +225,7 @@
     void randomiseBuffer();
 
 private:
-    void initSPI();
+
     void turnOn();
     void reset();
     void clearRAM();
@@ -205,6 +235,8 @@
 
 public:
     unsigned char buffer[84][6];  // screen buffer - the 6 is for the banks - each one is 8 bits;
+    int W;
+    int H;
 
 private:  // private variables
     SPI*    spi;
@@ -315,4 +347,103 @@
     0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
 };
 
-#endif
\ No newline at end of file
+const unsigned char font6x7[576] = {
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char space
+		0x00, 0x2E, 0x00, 0x00, 0x00, 0x00,      // Code for char !
+		0x06, 0x00, 0x06, 0x00, 0x00, 0x00,      // Code for char "
+		0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00,      // Code for char #
+		0x2E, 0x2A, 0x3E, 0x2A, 0x3A, 0x00,      // Code for char $
+		0x26, 0x16, 0x08, 0x34, 0x32, 0x00,      // Code for char %
+		0x36, 0x2A, 0x2A, 0x36, 0x10, 0x28,      // Code for char &
+		0x06, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char '
+		0x1C, 0x22, 0x00, 0x00, 0x00, 0x00,      // Code for char (
+		0x22, 0x1C, 0x00, 0x00, 0x00, 0x00,      // Code for char )
+		0x0A, 0x04, 0x0A, 0x00, 0x00, 0x00,      // Code for char *
+		0x08, 0x08, 0x3E, 0x08, 0x08, 0x00,      // Code for char +
+		0x30, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char ,
+		0x08, 0x08, 0x08, 0x08, 0x08, 0x00,      // Code for char -
+		0x20, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char .
+		0x20, 0x10, 0x08, 0x04, 0x02, 0x00,      // Code for char /
+		0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00,      // Code for char 0
+		0x22, 0x3E, 0x20, 0x00, 0x00, 0x00,      // Code for char 1
+		0x3A, 0x2A, 0x2A, 0x2A, 0x2E, 0x00,      // Code for char 2
+		0x2A, 0x2A, 0x2A, 0x2A, 0x3E, 0x00,      // Code for char 3
+		0x18, 0x14, 0x12, 0x3E, 0x10, 0x00,      // Code for char 4
+		0x2E, 0x2A, 0x2A, 0x2A, 0x3A, 0x00,      // Code for char 5
+		0x3E, 0x2A, 0x2A, 0x2A, 0x3A, 0x00,      // Code for char 6
+		0x02, 0x22, 0x12, 0x0A, 0x06, 0x00,      // Code for char 7
+		0x3E, 0x2A, 0x2A, 0x2A, 0x3E, 0x00,      // Code for char 8
+		0x2E, 0x2A, 0x2A, 0x2A, 0x3E, 0x00,      // Code for char 9
+		0x14, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char :
+		0x34, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char ;
+		0x08, 0x14, 0x22, 0x00, 0x00, 0x00,      // Code for char <
+		0x14, 0x14, 0x14, 0x14, 0x14, 0x00,      // Code for char =
+		0x22, 0x14, 0x08, 0x00, 0x00, 0x00,      // Code for char >
+		0x02, 0x02, 0x2A, 0x0A, 0x0E, 0x00,      // Code for char ?
+		0x3E, 0x22, 0x3A, 0x2A, 0x3E, 0x00,      // Code for char @
+		0x3E, 0x0A, 0x0A, 0x0A, 0x3E, 0x00,      // Code for char A
+		0x3E, 0x2A, 0x2A, 0x2A, 0x1C, 0x00,      // Code for char B
+		0x3E, 0x22, 0x22, 0x22, 0x22, 0x00,      // Code for char C
+		0x3E, 0x22, 0x22, 0x22, 0x1C, 0x00,      // Code for char D
+		0x3E, 0x2A, 0x2A, 0x2A, 0x2A, 0x00,      // Code for char E
+		0x3E, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,      // Code for char F
+		0x3E, 0x22, 0x2A, 0x2A, 0x3A, 0x00,      // Code for char G
+		0x3E, 0x08, 0x08, 0x08, 0x3E, 0x00,      // Code for char H
+		0x22, 0x3E, 0x22, 0x00, 0x00, 0x00,      // Code for char I
+		0x10, 0x20, 0x22, 0x22, 0x1E, 0x00,      // Code for char J
+		0x3E, 0x08, 0x08, 0x14, 0x22, 0x00,      // Code for char K
+		0x3E, 0x20, 0x20, 0x20, 0x20, 0x00,      // Code for char L
+		0x3E, 0x04, 0x08, 0x04, 0x3E, 0x00,      // Code for char M
+		0x3E, 0x04, 0x08, 0x10, 0x3E, 0x00,      // Code for char N
+		0x3E, 0x22, 0x22, 0x22, 0x3E, 0x00,      // Code for char O
+		0x3E, 0x0A, 0x0A, 0x0A, 0x0E, 0x00,      // Code for char P
+		0x3E, 0x22, 0x22, 0x32, 0x3E, 0x00,      // Code for char Q
+		0x3E, 0x0A, 0x0A, 0x3A, 0x2E, 0x00,      // Code for char R
+		0x2E, 0x2A, 0x2A, 0x2A, 0x3A, 0x00,      // Code for char S
+		0x02, 0x02, 0x3E, 0x02, 0x02, 0x00,      // Code for char T
+		0x3E, 0x20, 0x20, 0x20, 0x3E, 0x00,      // Code for char U
+		0x0E, 0x10, 0x20, 0x10, 0x0E, 0x00,      // Code for char V
+		0x1E, 0x20, 0x1E, 0x20, 0x1E, 0x00,      // Code for char W
+		0x22, 0x14, 0x08, 0x14, 0x22, 0x00,      // Code for char X
+		0x06, 0x08, 0x30, 0x08, 0x06, 0x00,      // Code for char Y
+		0x22, 0x32, 0x2A, 0x26, 0x22, 0x00,      // Code for char Z
+		0x3E, 0x22, 0x00, 0x00, 0x00, 0x00,      // Code for char [
+		0x02, 0x04, 0x08, 0x10, 0x20, 0x00,      // Code for char BackSlash
+		0x22, 0x3E, 0x00, 0x00, 0x00, 0x00,      // Code for char ]
+		0x04, 0x02, 0x04, 0x00, 0x00, 0x00,      // Code for char ^
+		0x20, 0x20, 0x20, 0x20, 0x20, 0x00,      // Code for char _
+		0x02, 0x04, 0x00, 0x00, 0x00, 0x00,      // Code for char `
+		0x3E, 0x0A, 0x0A, 0x0A, 0x3E, 0x00,      // Code for char a
+		0x3E, 0x2A, 0x2A, 0x2A, 0x1C, 0x00,      // Code for char b
+		0x3E, 0x22, 0x22, 0x22, 0x22, 0x00,      // Code for char c
+		0x3E, 0x22, 0x22, 0x22, 0x1C, 0x00,      // Code for char d
+		0x3E, 0x2A, 0x2A, 0x2A, 0x2A, 0x00,      // Code for char e
+		0x3E, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,      // Code for char f
+		0x3E, 0x22, 0x2A, 0x2A, 0x3A, 0x00,      // Code for char g
+		0x3E, 0x08, 0x08, 0x08, 0x3E, 0x00,      // Code for char h
+		0x22, 0x3E, 0x22, 0x00, 0x00, 0x00,      // Code for char i
+		0x10, 0x20, 0x22, 0x22, 0x1E, 0x00,      // Code for char j
+		0x3E, 0x08, 0x08, 0x14, 0x22, 0x00,      // Code for char k
+		0x3E, 0x20, 0x20, 0x20, 0x20, 0x00,      // Code for char l
+		0x3E, 0x04, 0x08, 0x04, 0x3E, 0x00,      // Code for char m
+		0x3E, 0x04, 0x08, 0x10, 0x3E, 0x00,      // Code for char n
+		0x3E, 0x22, 0x22, 0x22, 0x3E, 0x00,      // Code for char o
+		0x3E, 0x0A, 0x0A, 0x0A, 0x0E, 0x00,      // Code for char p
+		0x3E, 0x22, 0x22, 0x32, 0x3E, 0x00,      // Code for char q
+		0x3E, 0x0A, 0x0A, 0x3A, 0x2E, 0x00,      // Code for char r
+		0x2E, 0x2A, 0x2A, 0x2A, 0x3A, 0x00,      // Code for char s
+		0x02, 0x02, 0x3E, 0x02, 0x02, 0x00,      // Code for char t
+		0x3E, 0x20, 0x20, 0x20, 0x3E, 0x00,      // Code for char u
+		0x0E, 0x10, 0x20, 0x10, 0x0E, 0x00,      // Code for char v
+		0x1E, 0x20, 0x1E, 0x20, 0x1E, 0x00,      // Code for char w
+		0x22, 0x14, 0x08, 0x14, 0x22, 0x00,      // Code for char x
+		0x06, 0x08, 0x30, 0x08, 0x06, 0x00,      // Code for char y
+		0x22, 0x32, 0x2A, 0x26, 0x22, 0x00,      // Code for char z
+		0x08, 0x36, 0x22, 0x00, 0x00, 0x00,      // Code for char {
+		0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,      // Code for char |
+		0x22, 0x36, 0x08, 0x00, 0x00, 0x00,      // Code for char }
+		0x04, 0x02, 0x04, 0x02, 0x00, 0x00,      // Code for char ~
+		0x3F, 0x21, 0x3F, 0x00, 0x00, 0x00       // Code for char
+};
+
+#endif