Forked to make it possible to include this lib in a multi target setting

Fork of SLCD by Erik -

Files at this revision

API Documentation at this revision

Comitter:
star297
Date:
Mon Jan 27 21:57:38 2014 +0000
Parent:
1:1579bcd31410
Child:
4:ec7b3c9b2aeb
Commit message:
Confirmed colon/dot functions, tidy code & test. Contrast found not be very effective.

Changed in this revision

FRDM-s401.h Show annotated file Show diff for this revision Revisions of this file
LCDconfig.h Show annotated file Show diff for this revision Revisions of this file
SLCD.cpp Show annotated file Show diff for this revision Revisions of this file
SLCD.h Show annotated file Show diff for this revision Revisions of this file
--- a/FRDM-s401.h	Mon Jan 20 21:08:32 2014 +0000
+++ b/FRDM-s401.h	Mon Jan 27 21:57:38 2014 +0000
@@ -1,12 +1,10 @@
-#ifndef __FRDM_S401_H_
-#define __FRDM_S401_H_
 /*^^^^^^^^^^^^^^^^      LCD HARDWARE CONECTION ^^^^^^^^^^^^^^^^^^^^^^^^*/
 #define  _LCDFRONTPLANES   (8)            // # of frontPlanes
 #define  _LCDBACKPLANES    (4)            // # of backplanes
 
 /*
    LCD logical organization definition
-    This section indicate how the LCD is distributed  how many characteres of (7-seg, 14,seg, 16 seg, or colums in case of Dot Matrix) does it contain
+   This section indicates how the LCD is distributed  how many characteres of (7-seg, 14,seg, 16 seg, or colums in case of Dot Matrix) does it contain
    First character is forced only one can be written
 
 */
@@ -21,7 +19,7 @@
 
 #define _CHARNUM     (4)  //number of chars that can be written
 #define _CHAR_SIZE   (2)  // Used only when Dot Matrix is used
-#define _LCDTYPE     (2)  //indicate how many LCD_WF are required to write a single Character / or Column in case of DOT matrix LCD
+#define _LCDTYPE     (2)  //indicate how many LCD_WF are required to write a single Character
 
 /*
   Following definitions indicate how characters are associated to waveform
@@ -30,46 +28,33 @@
 #if HARDWARE_CONFIG == 0
 
 // LCD PIN1 to LCDWF0  Rev B
-#define   CHAR1a    37 // LCD Pin 5
-#define   CHAR1b    17 // LCD Pin 6
-#define   CHAR2a    7 // LCD Pin 7
-#define   CHAR2b    8 // LCD Pin 8
-#define   CHAR3a    53 // LCD Pin 9
-#define   CHAR3b    38 // LCD Pin 10
-#define   CHAR4a    10 // LCD Pin 11
-#define   CHAR4b    11 // LCD Pin 12
-#define   CHARCOM0    40 // LCD Pin 1
-#define   CHARCOM1    52 // LCD Pin 2
-#define   CHARCOM2    19 // LCD Pin 3
-#define   CHARCOM3    18 // LCD Pin 4
-
-/*Special Symbols */
-#define SPECIAL_SYMBOL_COUNT   4
-
-#define   _LCD_DP1_ON()      SymbolON(17,0)
-#define   _LCD_DP2_ON()      SymbolON(8,0)
-#define   _LCD_DP3_ON()      SymbolON(38,0)
-#define   _LCD_COL_ON()      SymbolON(11,0)
-
-#define   _LCD_DP1_OFF()      SymbolOFF(17,0)
-#define   _LCD_DP2_OFF()      SymbolOFF(8,0)
-#define   _LCD_DP3_OFF()      SymbolOFF(38,0)
-#define   _LCD_COL_OFF()      SymbolOFF(11,0)
+#define   CHAR1a    37      // LCD Pin 5
+#define   CHAR1b    17      // LCD Pin 6
+#define   CHAR2a    7       // LCD Pin 7
+#define   CHAR2b    8       // LCD Pin 8
+#define   CHAR3a    53      // LCD Pin 9
+#define   CHAR3b    38      // LCD Pin 10
+#define   CHAR4a    10      // LCD Pin 11
+#define   CHAR4b    11      // LCD Pin 12
+#define   CHARCOM0    40    // LCD Pin 1
+#define   CHARCOM1    52    // LCD Pin 2
+#define   CHARCOM2    19    // LCD Pin 3
+#define   CHARCOM3    18    // LCD Pin 4
 
 // LCD PIN1 to LCDWF2   for FRDM-KL46Z
 #elif HARDWARE_CONFIG == 1
-#define   CHAR1a    37 // LCD Pin 5
-#define   CHAR1b    17 // LCD Pin 6
-#define   CHAR2a    7 // LCD Pin 7
-#define   CHAR2b    8 // LCD Pin 8
-#define   CHAR3a    12 // LCD Pin 9
-#define   CHAR3b    26 // LCD Pin 10
-#define   CHAR4a    10 // LCD Pin 11
-#define   CHAR4b    11 // LCD Pin 12
-#define   CHARCOM0    51 // LCD Pin 1
-#define   CHARCOM1    52 // LCD Pin 2
-#define   CHARCOM2    19 // LCD Pin 3
-#define   CHARCOM3    16 // LCD Pin 4
+#define   CHAR1a    37      // LCD Pin 5
+#define   CHAR1b    17      // LCD Pin 6
+#define   CHAR2a    7       // LCD Pin 7
+#define   CHAR2b    8       // LCD Pin 8
+#define   CHAR3a    12      // LCD Pin 9
+#define   CHAR3b    26      // LCD Pin 10
+#define   CHAR4a    10      // LCD Pin 11
+#define   CHAR4b    11      // LCD Pin 12
+#define   CHARCOM0    51    // LCD Pin 1
+#define   CHARCOM1    52    // LCD Pin 2
+#define   CHARCOM2    19    // LCD Pin 3
+#define   CHARCOM3    16    // LCD Pin 4
 
 #endif
 
@@ -106,9 +91,6 @@
 #define FAULTD_BP_LO  110
 #define FAULTD_TIME   6
 
-extern const uint8_t  WF_ORDERING_TABLE[];              //   Logical Front plane N to LCD_WFx
-//extern const char  ASCII_TO_WF_CODIFICATION_TABLE[]; //   ASCII to 7x5 Dot Matrix
-
-#endif /* __FRDM_S401_H_ */
+extern const uint8_t  WF_ORDERING_TABLE[];   //   Logical Front plane N to LCD_WFx
 
 
--- a/LCDconfig.h	Mon Jan 20 21:08:32 2014 +0000
+++ b/LCDconfig.h	Mon Jan 27 21:57:38 2014 +0000
@@ -1,21 +1,18 @@
-#ifndef __LCDConfig_H_
-#define __LCDConfig_H_
-
-#include "FRDM-s401.h"  //  4x7 segdisplay
+#include "FRDM-s401.h"                //  4x7 segdisplay
 
 
 #if 1  // VREF to VLL1
 /* Following configuration is used for LCD default initialization  */
-#define _LCDRVEN          (1)  //
-#define _LCDRVTRIM        (8)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
-#define _LCDCPSEL         (1)          //  charge pump select 0 or 1 
-#define _LCDLOADADJUST    (3)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
-#define _LCDALTDIV        (0)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDRVEN          (1)         //
+#define _LCDRVTRIM        (8)         // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDCPSEL         (1)         //  charge pump select 0 or 1 
+#define _LCDLOADADJUST    (3)         // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDALTDIV        (0)         // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
 #define _LCDALRCLKSOURCE  (0)         // 0 -- External clock       1 --  Alternate clock
 
 #define _LCDCLKPSL        (0)         //  Clock divider to generate the LCD Waveforms 
 #define _LCDSUPPLY        (1) 
-#define _LCDHREF          (0)          // 0 or 1 
+#define _LCDHREF          (0)         // 0 or 1 
 #define _LCDCLKSOURCE     (1)         // 0 -- External clock       1 --  Alternate clock
 #define _LCDLCK           (1)         //Any number between 0 and 7 
 #define _LCDBLINKRATE     (3)         //Any number between 0 and 7 
@@ -25,16 +22,16 @@
 /* Following configuration is used for LCD default initialization  */
 #define _LCDCLKSOURCE     (1)         // 0 -- External clock       1 --  Alternate clock
 #define _LCDALRCLKSOURCE  (0)         // 0 -- External clock       1 --  Alternate clock
-#define _LCDCLKPSL        (0)         //  Clock divider to generate the LCD Waveforms 
+#define _LCDCLKPSL        (0)         // Clock divider to generate the LCD Waveforms 
 #define _LCDSUPPLY        (0) 
-#define _LCDLOADADJUST    (3)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
-#define _LCDALTDIV        (0)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
-#define _LCDRVTRIM        (0)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
-#define _LCDHREF          (0)          // 0 or 1 
-#define _LCDCPSEL         (1)          // 0 or 1 
-#define _LCDRVEN          (0)  //
-#define _LCDBLINKRATE     (3)         //Any number between 0 and 7 
-#define _LCDLCK           (0)         //Any number between 0 and 7 
+#define _LCDLOADADJUST    (3)         // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDALTDIV        (0)         // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDRVTRIM        (0)         // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDHREF          (0)         // 0 or 1 
+#define _LCDCPSEL         (1)         // 0 or 1 
+#define _LCDRVEN          (0)         //
+#define _LCDBLINKRATE     (3)         // Any number between 0 and 7 
+#define _LCDLCK           (0)         // Any number between 0 and 7 
 
 #endif
 
@@ -43,43 +40,42 @@
 
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Control Register 0  ~|~|~|~|~|~|~|~|~|~|~|~|~*/
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
-#define _LCDINTENABLE         (1)    
+#define _LCDINTENABLE          (1)    
 
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Control Register 1  ~|~|~|~|~|~|~|~|~|~|~|~|~|*/
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
-#define _LCDFRAMEINTERRUPT     (0)        //0 Disable Frame Frequency Interrupt
-                                                                       //1 Enable an LCD interrupt that coincides with the LCD frame frequency
-#define _LCDFULLCPLDIRIVE      (0)        // 0 GPIO shared with the LCD. Inputs levels and internal pullup reference to VDD
-                                                                      // 1 If VSUPPLY=11and RVEN=0. Inputs levels and internal pullup reference to VLL3
-#define _LCDWAITMODE           (0)       // 0 Allows the LCD driver and charge pump to continue running during wait mode
-                                                                     //  1 Disable the LCD when the MCU goes into wait mode
+#define _LCDFRAMEINTERRUPT     (0)     //0 Disable Frame Frequency Interrupt
+                                            //1 Enable an LCD interrupt that coincides with the LCD frame frequency
+#define _LCDFULLCPLDIRIVE      (0)     // 0 GPIO shared with the LCD. Inputs levels and internal pullup reference to VDD
+                                            // 1 If VSUPPLY=11and RVEN=0. Inputs levels and internal pullup reference to VLL3
+#define _LCDWAITMODE           (0)     // 0 Allows the LCD driver and charge pump to continue running during wait mode
+                                            //  1 Disable the LCD when the MCU goes into wait mode
 #define _LCDSTOPMODE           (0)     // 0 Allows the LCD driver and charge pump to continue running during stop2 or stop3
-
-                                                                     //  1 Disable the LCD when and charge pump when the MCU goes into stop2 or stop3                                                               
+                                            //  1 Disable the LCD when and charge pump when the MCU goes into stop2 or stop3                                                               
 
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Voltage Supply Register  ~|~|~|~|~|~|~|~|~|~|~|~*/
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
-#define _LCDHIGHREF             (0)      //0 Divide input VIREG=1.0v
-                                                                    //1 Do not divide the input VIREG=1.67v
-#define _LCDBBYPASS             (0)      //Determines whether the internal LCD op amp buffer is bypassed
-                                                                      //0 Buffered mode
-                                                                      //1 Unbuffered mode
+#define _LCDHIGHREF             (0)    //0 Divide input VIREG=1.0v
+                                            //1 Do not divide the input VIREG=1.67v
+#define _LCDBBYPASS             (0)    //Determines whether the internal LCD op amp buffer is bypassed
+                                            //0 Buffered mode
+                                            //1 Unbuffered mode
                             
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Regulated Voltage Control |~|~|~|~|~|~|~|~|~|~*/
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
-#define _LCDCONTRAST                    (1)       //Contrast by software   0 -- Disable    1-- Enable
-#define _LVLCONTRAST                    (0)       //Any number between 0  and 15, if the number is bigger the glass get darker
+#define _LCDCONTRAST            (1)       //Contrast by software   0 -- Disable    1-- Enable
+#define _LVLCONTRAST            (0)       //Any number between 0  and 15, if the number is bigger the glass gets darker
 
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Blink Control Register ~|~|~|~|~|~|~|~|~|~|~|~*/
 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
-#define _LCDBLINKCONTROL         (0)   //0 Disable blink mode
-                                                                       //1 Enable blink mode
-#define _LCDALTMODE              (0)   //0 Normal display 
-                                                                      //1 Alternate display for 4 backplanes or less the LCD backplane sequencer changes to otuput an alternate display
-#define _LCDBLANKDISP           (0)  //0 Do not blank display
-                                                                      //1 Blank display if you put it in 0 the text before blank is manteined     
-#define _LCDBLINKMODE           (0)  //0 Display blank during the blink period 
-                                                                     //1 Display alternate displat during blink period (Ignored if duty is 5 or greater)
+#define _LCDBLINKCONTROL        (1)     //0 Disable blink mode
+                                            //1 Enable blink mode
+#define _LCDALTMODE             (0)     //0 Normal display 
+                                            //1 Alternate display for 4 backplanes or less the LCD backplane sequencer changes to otuput an alternate display
+#define _LCDBLANKDISP           (0)     //0 Do not blank display
+                                            //1 Blank display if you put it in 0 the text before blank is manteined     
+#define _LCDBLINKMODE           (0)     //0 Display blank during the blink period 
+                                            //1 Display alternate displat during blink period (Ignored if duty is 5 or greater)
 
 
 //Calculated values
@@ -87,9 +83,7 @@
 #define _LCDDUTY       (_LCDBACKPLANES-1)         //Any number between 0 and 7 
 #define  LCD_WF_BASE    LCD->WF8B[0]
 
-// General definitions used by the LCD library
-#define  SymbolON(LCDn,bit)     *((uint8 *)&LCD_WF_BASE + LCDn)  |=  (1<<(bit))         
-#define  SymbolOFF(LCDn,bit)    *((uint8 *)&LCD_WF_BASE + LCDn)  &= ~(1<<(bit))         
+// General definitions used by the LCD library         
 #define  LCD_WF(x)              *((uint8 *)&LCD_WF_BASE + x) 
 
 /*LCD Fault Detections Consts*/
@@ -185,5 +179,5 @@
 #define    mBIT62      1073741824
 #define    mBIT63      2147483648
 
-#endif /* __LCDConfig_H_ */
 
+
--- a/SLCD.cpp	Mon Jan 20 21:08:32 2014 +0000
+++ b/SLCD.cpp	Mon Jan 27 21:57:38 2014 +0000
@@ -63,7 +63,7 @@
 ( SEGD+ SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = J,   offset=104
 (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = K,   offset=108
 ( SEGD+ SEGE+ SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = L,   offset=112
-(!SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = M,   offset=116
+(!SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = M,   offset=116
 (!SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = N,   offset=120
 ( SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = O,   offset=124
 (!SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+ SEGB+ SEGA) ,//Char = P,   offset=128
@@ -87,33 +87,23 @@
 
 SLCD::SLCD() {
     init();
-    bLCD_CharPosition = 0;    
-}
-
-int SLCD::_putc(int c) {
-    LCD_Write_Char(c);
-    return 0;
+    CharPosition = 0;    
 }
 
 void SLCD::init(){
     SIM->SCGC5 |= SIM_SCGC5_SLCD_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;
      
-     // configure pins for LCD operation    
+    // configure pins for LCD operation    
   PORTC->PCR[20] = 0x00000000;     //VLL2
   PORTC->PCR[21] = 0x00000000;     //VLL1
   PORTC->PCR[22] = 0x00000000;     //VCAP2
-  PORTC->PCR[23] = 0x00000000;     //VCAP1
-
-     
-     
-     // Enable IRCLK 
+  PORTC->PCR[23] = 0x00000000;     //VCAP1     
+    // Enable IRCLK 
      MCG->C1  = MCG_C1_IRCLKEN_MASK | MCG_C1_IREFSTEN_MASK;
-     MCG->C2 &= ~MCG_C2_IRCS_MASK ;  //0 32KHZ internal reference clock; 1= 4MHz irc
-     
+     MCG->C2 &= ~MCG_C2_IRCS_MASK ;  //0 32KHZ internal reference clock; 1= 4MHz irc     
      LCD->GCR = 0x0;
-     LCD->AR  = 0x0;
-     
-// LCD configurartion according to */     
+     LCD->AR  = 0x0;     
+    // LCD configurartion     
       LCD->GCR =   ( LCD_GCR_RVEN_MASK*_LCDRVEN  
                    | LCD_GCR_RVTRIM(_LCDRVTRIM)         //0-15
                    | LCD_GCR_CPSEL_MASK*_LCDCPSEL 
@@ -126,28 +116,18 @@
                    |!LCD_GCR_LCDEN_MASK                 //WILL BE ENABLE ON SUBSEQUENT STEP
                    | LCD_GCR_SOURCE_MASK*_LCDCLKSOURCE
                    | LCD_GCR_ALTSOURCE_MASK*_LCDALRCLKSOURCE  
-                   | LCD_GCR_LCLK(_LCDLCK)   //0-7
+                   | LCD_GCR_LCLK(_LCDLCK)    //0-7
                    | LCD_GCR_DUTY(_LCDDUTY)   //0-7
                  );    
-     
-      EnablePins();         // Enable LCD pins and Configure BackPlanes
-      LCD->GCR |= LCD_GCR_LCDEN_MASK;
-}
-
-void SLCD::EnablePins (void)
-  {
    uint8_t i;
    uint32_t *p_pen;
    uint8_t pen_offset;   // 0 or 1   
    uint8_t pen_bit;      // 0 to 31
-
    LCD->PEN[0] = 0x0;
    LCD->PEN[1] = 0x0;
    LCD->BPEN[0] = 0x0;
-   LCD->BPEN[1] = 0x0;
-   
+   LCD->BPEN[1] = 0x0;   
    p_pen = (uint32_t *)&LCD->PEN[0];
-
     for (i=0;i<_LCDUSEDPINS;i++) 
     {
       pen_offset = WF_ORDERING_TABLE[i]/32;
@@ -158,11 +138,16 @@
         p_pen[pen_offset+2] |= 1 << pen_bit;  // Enable  BPEN 
         LCD->WF8B[(uint8_t)WF_ORDERING_TABLE[i]] = 1 << (i - _LCDFRONTPLANES);   // fill with 0x01, 0x02, etc 
       } 
-    }
-  }
+    }    
+      LCD->GCR |= LCD_GCR_LCDEN_MASK;
+}
 
+int SLCD::_putc(int c) {
+    Write_Char(c);
+    return 0;
+}
 
-void SLCD::LCD_Write_Char (char lbValue) {
+void SLCD::Write_Char (char lbValue) {
   uint8_t char_val;
   uint8_t temp;
   uint8_t *lbpLCDWF;
@@ -170,9 +155,8 @@
   uint16_t arrayOffset;
   uint8_t position;
   
-  if (bLCD_CharPosition >= _CHARNUM)
-    bLCD_CharPosition = 0;
-  
+  if (CharPosition >= _CHARNUM)
+    CharPosition = 0;  
   lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
   /* only ascii character if value not writeable write as @ */
   if (lbValue>='a' && lbValue<='z') {
@@ -186,7 +170,7 @@
   // ensure bLCD position is in valid limit
   lbCounter = 0;  //number of writings to complete one char
   while (lbCounter<_CHAR_SIZE) {
-    position = (bLCD_CharPosition) *_LCDTYPE + lbCounter; 
+    position = (CharPosition) *_LCDTYPE + lbCounter; 
     temp=0;
     if (lbCounter==1) {
       temp = lbpLCDWF[WF_ORDERING_TABLE[position]] & 0x01;//bit 0 has the special symbol information
@@ -195,33 +179,22 @@
     lbpLCDWF[WF_ORDERING_TABLE[position]] = char_val | temp;
     //  if (char_val==0) lbCounter = _CHAR_SIZE; //end of this character
     lbCounter++;
-  }
-  
-  bLCD_CharPosition++;
+  }  
+  CharPosition++;
 }
 
-/*  Fill Backplanes with normal mask for  0x01, 0x02,  according to BP_ORDERING_TABLE;*/
-void SLCD::SetBackplanes(void)
+void SLCD::Home (void)
  {
-   uint8_t i;
-   for (i=0;i<_LCDBACKPLANES;i++)
-   {
-       LCD->WF8B[(uint8_t)WF_ORDERING_TABLE[i+_LCDFRONTPLANES]] = 0x01<<i;
-   }  
-  }
-  
-void SLCD::LCD_Home (void)
- {
-      bLCD_CharPosition =  0;
+      CharPosition =  0;
  }
 
-void SLCD::LCD_Contrast (uint8_t lbContrast)
-{
+void SLCD::Contrast (uint8_t lbContrast)
+{ 
        lbContrast &= 0x0F;              //Forced to the only values accepted 
        LCD->GCR |= LCD_GCR_RVTRIM(lbContrast);
 }
  
-void SLCD::LCD_All_Segments_ON (void)
+void SLCD::All_Segments (int mode)
 {
  uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;              
  uint8_t lbCounter=0;
@@ -230,77 +203,41 @@
     lbpLCDWF = (uint8_t *)&LCD->WF8B[0];      
         while (lbCounter < lbTotalBytes)
           {
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[lbCounter++]]=_ALLON;
+              if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[lbCounter++]]=_ALLON;}
+                else {lbpLCDWF[WF_ORDERING_TABLE[lbCounter++]]=0;}
           }         
 }
 
-void SLCD::LCD_All_Segments_OFF (void)
-{              
- uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;              
- uint8_t lbCounter=0;
- uint8_t *lbpLCDWF;
- 
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
-        while (lbCounter < lbTotalBytes)
-          {
-              lbpLCDWF[WF_ORDERING_TABLE[lbCounter++]]=0;
-          }
-}
-
-void SLCD::DP1_ON (void)
+void SLCD::DP1 (int mode)
 {
   uint8_t *lbpLCDWF; 
     lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]=1;                 
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]&=~1;}                
 }
-
-void SLCD::DP1_OFF (void)
-{
-  uint8_t *lbpLCDWF; 
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]=14;                 
-}
-
-void SLCD::DP2_ON (void)
+ 
+void SLCD::DP2 (int mode)
 {
   uint8_t *lbpLCDWF; 
     lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]=1;                 
-}
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]&=~1;}               
+} 
 
-void SLCD::DP2_OFF (void)
-{
-  uint8_t *lbpLCDWF; 
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]=14;                 
-}
-
-void SLCD::DP3_ON (void)
-{
-  uint8_t *lbpLCDWF; 
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]=1;                 
-}
-
-void SLCD::DP3_OFF (void)
+void SLCD::DP3 (int mode)
 {
   uint8_t *lbpLCDWF; 
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]=14;                 
+    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]&=~1;}
 }
-
-void SLCD::COLON_ON (void)
+ 
+void SLCD::Colon (int mode)
 {
   uint8_t *lbpLCDWF; 
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];      
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]=1;                 
+    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];     
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]&=~1;}                 
 }
+ 
 
-void SLCD::COLON_OFF (void)
-{
-  
-  uint8_t *lbpLCDWF; 
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
-              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]=14;                 
-}
-
--- a/SLCD.h	Mon Jan 20 21:08:32 2014 +0000
+++ b/SLCD.h	Mon Jan 27 21:57:38 2014 +0000
@@ -1,36 +1,44 @@
-#ifndef SLCD_H
-#define SLCD_H
-
 #include "mbed.h"
 
 
+/*  ------ sample usage------
+
+    #include "mbed.h"
+    #include "SLCD.h"
+    
+    SLCD slcd;
+    
+    main()
+    {
+        slcd.printf("1234");    // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display
+        slcd.putc("A");         // prints a single character 
+        slcd.Write_Char('A');   // prints a single character
+        slcd.All_Segments(y);   // y=1 for ALL segments on, 0 for ALL segments off  
+        slcd.DPx(y);            // x=DP1 to DP3, y=1 for on 0 for off
+        slcd.Colon(y);          // y=1 for on, 0 for off
+        slcd.CharPosition=x;    // x=0 to 3, 0 is start position
+        slcd.Home();            // sets next charater to posistion 0 (start)
+        slcd.Contrast (x);      // set contrast x=0 - 15, 0 lightest, 15 darkest    
+    }   
+*/
+
 class SLCD : public Stream {
     public:
     SLCD();
     
     void init();
-    void EnablePins();    
-    void LCD_Write_Char(char lbValue);
-    void SetBackplanes(void); // reconfigure COM to default values
-    void LCD_Home (void);
-    void LCD_Contrast (uint8_t lbContrast);
-    void LCD_All_Segments_ON (void);    
-    void LCD_All_Segments_OFF (void);
-    void DP1_ON (void);
-    void DP1_OFF (void);
-    void DP2_ON (void);
-    void DP2_OFF (void);
-    void DP3_ON (void);
-    void DP3_OFF (void);
-    void COLON_ON (void);
-    void COLON_OFF (void);
-    
-    uint8_t lcd_alternate_mode;
-    uint8_t bLCD_CharPosition;
+    void Write_Char(char lbValue);
+    void Home (void);
+    void Contrast (uint8_t lbContrast);
+    void All_Segments (int);     
+    void DP1 (int);
+    void DP2 (int);
+    void DP3 (int);
+    void Colon (int);     
+    uint8_t CharPosition;
          
     virtual int _putc(int c);
     virtual int _getc() {
         return 0;
     }  
 };
-#endif
\ No newline at end of file