SparkFun SerLCD v2.5 controller

Files at this revision

API Documentation at this revision

Comitter:
Phlaphead
Date:
Sun Feb 13 15:16:20 2011 +0000
Commit message:
First revision

Changed in this revision

SerialLCD.cpp Show annotated file Show diff for this revision Revisions of this file
SerialLCD.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialLCD.cpp	Sun Feb 13 15:16:20 2011 +0000
@@ -0,0 +1,48 @@
+
+#include "SerialLCD.h"
+
+
+SerialLCD::SerialLCD(PinName tx, PinName rx) : 
+    Serial(tx, rx)
+{
+    baud(LCD_BAUD);
+}
+
+
+void SerialLCD::clear()
+{
+    putc(0xFE);
+    putc(0x01);
+}
+
+void SerialLCD::setBacklight(int brightness)
+{
+    putc(0x7C);
+    putc(128+brightness);
+}
+
+void SerialLCD::setPosition(int row, int col)
+{
+    int position = row == 0 ? (128 + col) : (192 + col);
+    putc(0xFE);
+    putc(position);
+}
+
+void SerialLCD::setVisible(bool visible)
+{
+    putc(0xFE);
+    putc(visible ? 0x0C : 0x08);
+}
+
+void SerialLCD::scrollLeft()
+{
+    putc(0xFE);
+    putc(0x18);
+}
+
+void SerialLCD::scrollRight()
+{
+    putc(0xFE);
+    putc(0x1C);
+}
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialLCD.h	Sun Feb 13 15:16:20 2011 +0000
@@ -0,0 +1,57 @@
+#ifndef SerialLCD_h
+#define SerialLCD_h
+
+#include "mbed.h"
+
+#define LCD_WIDTH 16
+#define LCD_BAUD 9600
+
+/**
+ * SparkFun SerLCD v2.5 Controller
+ */
+class SerialLCD : public Serial
+{
+  public:
+  
+    /**
+     * Constructor.
+     * @param tx Connected to rx pin of LCD
+     * @param rx Not connected but needs to be specified for serial interface.
+     */
+    SerialLCD(PinName tx, PinName rx);
+    
+    /**
+     * Clear the LCD.
+     */
+    void clear();
+    
+    /**
+     * Set backlight brightness;
+     */
+    void setBacklight(int brightness);
+    
+    /**
+     * Set cursor position.
+     */
+    void setPosition(int row, int col);
+    
+    /**
+     * Make LCD text visible or invisible.
+     */
+    void setVisible(bool visible);
+    
+    /**
+     * Start scrolling to the left.
+     */
+    void scrollLeft();
+    
+    /**
+     * Start scrolling to the right.
+     */
+    void scrollRight();
+    
+    
+};
+
+
+#endif