light text library for 5110 nokia lcd * easy to modify * proportional font, bold / inverse modes * easy to add / change fonts * fixed rows for fast update

Library finished! :-) If you use 5110 and need fast menus - try this library. No overhead - small and robust, optimized for this display type only, fast update. Nice looking font. Power management. Displays from 5110 and 3110 are cheap as dirt :-)

Revision:
0:0a6619901f2e
Child:
2:65df20ffef51
diff -r 000000000000 -r 0a6619901f2e medvdv5110.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/medvdv5110.h	Sat Jul 14 17:52:11 2012 +0000
@@ -0,0 +1,67 @@
+//
+// 5110 LCD Driver
+// (c) 2012 medvdv.com  
+// Alexander Medvedev
+//
+ 
+#define DEFAULT_CONTRAST 60
+ 
+typedef struct {
+
+    char first_code;
+    char glyphs_total;   
+    const char* widths;
+    const char** glyphs;    
+    
+} lcd5110font;
+
+class lcd5110 {
+
+    SPI* spi;
+    DigitalOut* rst;
+    DigitalOut* sce;
+    DigitalOut* dc;
+    
+    lcd5110font font;
+    
+    char contrast;
+
+    bool invert;
+    bool bold;
+    
+    int X, Y;
+        
+    void write(char byte, bool cmd = false);
+            
+    public:
+    
+    lcd5110(PinName mosi= p11, PinName sclk = p13, PinName dc = p10, PinName sce = p8, PinName rst = p9);
+
+    void Init();
+    void Reset();
+    void Clear(char pattern = 0);
+    void Contrast(char contrast = DEFAULT_CONTRAST );
+    void PowerOff();
+    
+    void Invert(bool invert = true);
+    void Bold(bool bold = true);
+        
+    void XY(int x = 0, int y = 0);
+    
+    void Write(char byte);
+    void Write(char byte, int count);
+    void Write(char* data, int size);
+    void Write2(char* data, int size);
+    
+    void Character(char chr);
+    int CharacterWidth(char chr);
+
+    void String(char* str);
+    int StringWidth(char* str);
+    
+    void Row(int Y, char* str = "");  
+
+    ~lcd5110();
+    
+}; 
+