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:
2:65df20ffef51
Parent:
0:0a6619901f2e
Child:
3:03c7cb24222d
diff -r cce4622d70f6 -r 65df20ffef51 medvdv5110.h
--- a/medvdv5110.h	Tue Sep 25 16:03:34 2012 +0000
+++ b/medvdv5110.h	Fri Dec 07 21:41:54 2012 +0000
@@ -4,8 +4,13 @@
 // Alexander Medvedev
 //
  
-#define DEFAULT_CONTRAST 60
- 
+// depends of voltage and other factors 
+#define DEFAULT_CONTRAST 50 
+
+//   
+// Proportional font with 8px height 
+// 
+
 typedef struct {
 
     char first_code;
@@ -15,53 +20,70 @@
     
 } lcd5110font;
 
+// Contrast value depends of voltage and other factors 
+#define DEFAULT_CONTRAST 50 
+
+//
+// Nokia 5110 LCD Interface Class
+//
+
 class lcd5110 {
 
+    // SPI and other pin's
     SPI* spi;
     DigitalOut* rst;
     DigitalOut* sce;
     DigitalOut* dc;
-    
+
+    // Current font    
     lcd5110font font;
     
+    // Contrast value for next reset    
     char contrast;
 
+    // Invert and bold flags 
     bool invert;
     bool bold;
     
+    // current write position    
     int X, Y;
         
+    // Generic SPI writer       
     void write(char byte, bool cmd = false);
             
     public:
     
+    // Supply LCD connected pin's here for your design   
     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 Reset();                           // Reset LCD, configure defaults and contrast
+    void Clear(char pattern = 0);           // Clear - fill all by 8bit line 'pattern'
+    void PowerOff();                        // LCD power off
+
+    void Contrast(char contrast = DEFAULT_CONTRAST );    // Change contrast
     
-    void Invert(bool invert = true);
-    void Bold(bool bold = true);
+    void Invert(bool invert = true);        // Switch inverting of chars
+    void Bold(bool bold = true);            // Switch bold mode (repeat each char row twice)
         
-    void XY(int x = 0, int y = 0);
+    void XY(int x = 0, int y = 0);          // Change write position X in pixels [0..83], Y in rows [0..5]
     
-    void Write(char byte);
-    void Write(char byte, int count);
-    void Write(char* data, int size);
-    void Write2(char* data, int size);
+    // Row write
+    void Write(char byte);                  // One 8bit row
+    void Write(char byte, int count);       // One 8bit row * 'count' times
+    void Write(char* data, int size);       // 'size' 8bit rows
+    void Write2(char* data, int size);      // Bold: 'size' 8bit rows * 2   
     
-    void Character(char chr);
-    int CharacterWidth(char chr);
+    // Character drawing
+    void Character(char chr);               // Draw one font character with invert and bold opt-s
+    int CharacterWidth(char chr);           // Calculate one character width with bold opt-n
 
-    void String(char* str);
-    int StringWidth(char* str);
+    // String drawing
+    void String(char* str);                 // Draw string proportionally
+    int StringWidth(char* str);             // Calculate string width in px 
     
-    void Row(int Y, char* str = "");  
+    void Row(int Y, char* str = "");        // Clear one text row and draw string on it
 
-    ~lcd5110();
+    ~lcd5110();                             // destruct pin's
     
 };