Display text on LCD displays (even on multiple ones). Allow to create windows (frames) on display, and to combine them (split, add, duplicate, scroll). See http://mbed.org/users/hlipka/notebook/lcdwindow/ for more information.

Dependents:   Mbell

Files at this revision

API Documentation at this revision

Comitter:
hlipka
Date:
Tue Nov 16 20:49:18 2010 +0000
Parent:
0:ae5037e3d6e0
Child:
2:5ac5bab7daaf
Commit message:
minor revision: made use of \const\ in the API

Changed in this revision

dogm_spi.cpp Show annotated file Show diff for this revision Revisions of this file
dogm_spi.h Show annotated file Show diff for this revision Revisions of this file
hd44780_8bit.cpp Show annotated file Show diff for this revision Revisions of this file
hd44780_8bit.h Show annotated file Show diff for this revision Revisions of this file
ks0108_8bit.cpp Show annotated file Show diff for this revision Revisions of this file
ks0108_8bit.h Show annotated file Show diff for this revision Revisions of this file
lcd_spi.cpp Show annotated file Show diff for this revision Revisions of this file
lcd_spi.h Show annotated file Show diff for this revision Revisions of this file
multiwindow.cpp Show annotated file Show diff for this revision Revisions of this file
multiwindow.h Show annotated file Show diff for this revision Revisions of this file
subwindow.cpp Show annotated file Show diff for this revision Revisions of this file
subwindow.h Show annotated file Show diff for this revision Revisions of this file
teewindow.cpp Show annotated file Show diff for this revision Revisions of this file
teewindow.h Show annotated file Show diff for this revision Revisions of this file
terminal.cpp Show annotated file Show diff for this revision Revisions of this file
terminal.h Show annotated file Show diff for this revision Revisions of this file
window.h Show annotated file Show diff for this revision Revisions of this file
--- a/dogm_spi.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/dogm_spi.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -47,7 +47,7 @@
     }
 }
 
-void DogmLCDSPI::writeText(unsigned int line, unsigned int pos, char text[])
+void DogmLCDSPI::writeText(const unsigned int line, const unsigned int pos, const char text[])
 {
     int address=(line)*0x40+(pos);
     sendCmd((char)address|0x80);
--- a/dogm_spi.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/dogm_spi.h	Tue Nov 16 20:49:18 2010 +0000
@@ -46,7 +46,7 @@
         */
         DogmLCDSPI(unsigned int width, unsigned int height, SPI *spi, PinName enable, PinName rs); 
         virtual void init();
-        virtual void writeText(unsigned int line, unsigned int pos, char text[]);
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[]);
         virtual void clear();
 };
 
--- a/hd44780_8bit.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/hd44780_8bit.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -28,7 +28,7 @@
 #include "wait_api.h"
 
 
-void HD44780LCD8bit::writeText(unsigned int line, unsigned int pos, char text[]) {
+void HD44780LCD8bit::writeText(const unsigned int line, const unsigned int pos, const char text[]) {
 //    printf("print to %d,%d {%s}\n",line,pos,text);
     int address=line*0x40+pos;
     sendCmd((unsigned char)address|0x80);
@@ -46,13 +46,13 @@
     sendCmd(1);
 }
 
-void HD44780LCD8bit::sendCmd(unsigned char cmd) {
+void HD44780LCD8bit::sendCmd(const unsigned char cmd) {
     _rs->write(0);
     wait_us(1);
     sendByte(cmd);
 }
 
-void HD44780LCD8bit::sendData(unsigned char cmd) {
+void HD44780LCD8bit::sendData(const unsigned char cmd) {
     _rs->write(1);
     wait_us(1);
     sendByte(cmd);
@@ -77,7 +77,7 @@
     }
 }
 
-void HD44780LCD8bit::sendByte(unsigned char byte) {
+void HD44780LCD8bit::sendByte(const unsigned char byte) {
     _data->write(byte);
     _enable->write(1);
     wait_us(2);
--- a/hd44780_8bit.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/hd44780_8bit.h	Tue Nov 16 20:49:18 2010 +0000
@@ -48,14 +48,14 @@
         */
         HD44780LCD8bit(unsigned int width, unsigned int height, BusOut *data, PinName enable, PinName rs); 
         virtual void init();
-        virtual void writeText(unsigned int line, unsigned int pos, char text[]);
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[]);
         virtual void clear();
 
     protected:
-        void sendCmd(unsigned char byte);
-        void sendData(unsigned char byte);
+        void sendCmd(const unsigned char byte);
+        void sendData(const unsigned char byte);
         
-        void sendByte(unsigned char byte);
+        void sendByte(const unsigned char byte);
         
         BusOut* _data;
         DigitalOut *_enable, *_rs;
--- a/ks0108_8bit.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/ks0108_8bit.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -30,7 +30,7 @@
 
 #define ENABLE 1
 
-void KS0108LCD8bit::writeText(unsigned int line, unsigned int pos, char text[]) {
+void KS0108LCD8bit::writeText(const unsigned int line, const unsigned int pos, const char text[]) {
     printf("print to %d,%d {%s}\n",line,pos,text);
     int i=0;
     while (text[i]!=0) {
@@ -60,12 +60,13 @@
     }
 }
 
-void KS0108LCD8bit::setChar(unsigned int line, unsigned int pos, char c) {
+void KS0108LCD8bit::setChar(const unsigned int line, const unsigned int pos, const char c) {
     DigitalOut* cs=NULL;
-    if (pos>7)
+    int column=pos;
+    if (column>7)
     {
         cs=_right;
-        pos-=8;
+        column-=8;
     }
     else
     {
@@ -76,7 +77,7 @@
     
     sendCmd(0xb8|line,cs); // set x page    
 
-    unsigned int y=pos*8;
+    unsigned int y=column*8;
     sendCmd(0x40|y,cs); // set start line
     
     // send character data
@@ -88,7 +89,7 @@
 }
 
 KS0108LCD8bit::KS0108LCD8bit
-(unsigned int width, unsigned int height, BusOut *data, PinName enable, PinName rs, PinName leftCS, PinName rightCS)
+(const unsigned int width, const unsigned int height, BusOut *data, const PinName enable, const PinName rs, const PinName leftCS, const PinName rightCS)
         :TextLCDBase(width, height) {
     _data=data;
     _rs=new DigitalOut(rs);
@@ -122,21 +123,21 @@
     clear();
 }
 
-void KS0108LCD8bit::sendCmd(unsigned char cmd, DigitalOut *cs) {
+void KS0108LCD8bit::sendCmd(const unsigned char cmd, DigitalOut *cs) {
     _rs->write(0);
     wait_us(1);
     sendByte(cmd, cs);
     wait_us(10);
 }
 
-void KS0108LCD8bit::sendData(unsigned char cmd, DigitalOut *cs) {
+void KS0108LCD8bit::sendData(const unsigned char cmd, DigitalOut *cs) {
     _rs->write(1);
     wait_us(1);
     sendByte(cmd, cs);
     wait_us(10);
 }
 
-void KS0108LCD8bit::sendByte(unsigned char byte, DigitalOut *cs) {
+void KS0108LCD8bit::sendByte(const unsigned char byte, DigitalOut *cs) {
     // display reads flags with rising flank of E
 //    printf("send to %d\n",cs);
     _enable->write(0);
--- a/ks0108_8bit.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/ks0108_8bit.h	Tue Nov 16 20:49:18 2010 +0000
@@ -48,20 +48,20 @@
          * @param leftCS the pin name for the left display half (1=active)
          * @param rightCS the pin name for the right display half (1=active, use NC for smaller displays)
         */
-        KS0108LCD8bit(unsigned int width, unsigned int height, BusOut *data, PinName enable, PinName rs, PinName leftCS, PinName rightCS); 
+        KS0108LCD8bit(const unsigned int width, const unsigned int height, BusOut *data, const PinName enable, const PinName rs, const PinName leftCS, const PinName rightCS); 
         virtual void init();
-        virtual void writeText(unsigned int line, unsigned int pos, char text[]);
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[]);
         virtual void clear();
 
     protected:
         void clearHalf(DigitalOut *cs);
 
-        void sendCmd(unsigned char byte, DigitalOut *cs);
-        void sendData(unsigned char byte, DigitalOut *cs);
+        void sendCmd(const unsigned char byte, DigitalOut *cs);
+        void sendData(const unsigned char byte, DigitalOut *cs);
         
-        void sendByte(unsigned char byte, DigitalOut *cs);
+        void sendByte(const unsigned char byte, DigitalOut *cs);
         
-        void setChar(unsigned int line, unsigned int pos, char c);
+        void setChar(const unsigned int line, const unsigned int pos, const char c);
         
         BusOut* _data;
         DigitalOut *_enable, *_rs, *_left, *_right;
--- a/lcd_spi.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/lcd_spi.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -40,7 +40,7 @@
     _spi->frequency(100000);
 }
 
-void SPILCDBase::sendByte(unsigned char byte)
+void SPILCDBase::sendByte(const unsigned char byte)
 {
     _enable->write(0); // enable transfer
     wait_us(1);
@@ -49,7 +49,7 @@
     _enable->write(1);
 }
 
-void SPILCDBase::sendCmd(unsigned char cmd)
+void SPILCDBase::sendCmd(const unsigned char cmd)
 {
     _rs->write(0);
     wait_us(1);
@@ -58,7 +58,7 @@
     _rs->write(1);
 }
 
-void SPILCDBase::sendData(unsigned char cmd)
+void SPILCDBase::sendData(const unsigned char cmd)
 {
     _rs->write(1);
     wait_us(1);
--- a/lcd_spi.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/lcd_spi.h	Tue Nov 16 20:49:18 2010 +0000
@@ -41,10 +41,10 @@
         SPILCDBase(unsigned int width, unsigned int height, SPI *spi, PinName enable, PinName rs); 
 
     protected:
-        void sendCmd(unsigned char byte);
-        void sendData(unsigned char byte);
+        void sendCmd(const unsigned char byte);
+        void sendData(const unsigned char byte);
         
-        void sendByte(unsigned char byte);
+        void sendByte(const unsigned char byte);
 
         SPI* _spi;
         DigitalOut  *_enable, *_rs;
--- a/multiwindow.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/multiwindow.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -33,7 +33,7 @@
     _width=_lcds[0]->getWidth();
 }
 
-void MultiWindow::writeText(unsigned int line, unsigned int pos, char text[]) {
+void MultiWindow::writeText(const unsigned int line, const unsigned int pos, const char text[]) {
     int len=_lcds.size();
     int lines=0;
     for (int i=0;i<len;i++) {
--- a/multiwindow.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/multiwindow.h	Tue Nov 16 20:49:18 2010 +0000
@@ -44,7 +44,7 @@
         /**
          * writes text to the parent window which contains the given line
         */
-        virtual void writeText(unsigned int line, unsigned int pos, char text[]);
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[]);
         virtual int getHeight(){return _height;};
         virtual int getWidth(){return _width;};
         /**
--- a/subwindow.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/subwindow.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -25,7 +25,7 @@
 
 #include "string.h"
 
-SubWindow::SubWindow(Window* lcd, unsigned int offsetX, unsigned int offsetY, unsigned int width, unsigned int height) {
+SubWindow::SubWindow(Window* lcd, const unsigned int offsetX, const unsigned int offsetY, const unsigned int width, const unsigned int height) {
     _lcd=lcd;
     _offsetX=offsetX;
     _offsetY=offsetY;
@@ -34,7 +34,7 @@
 
 }
 
-void SubWindow::writeText(unsigned int line, unsigned int pos, char* text) {
+void SubWindow::writeText(const unsigned int line, const unsigned int pos, const char* text) {
     if (line>_height)
         return;
 
--- a/subwindow.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/subwindow.h	Tue Nov 16 20:49:18 2010 +0000
@@ -41,8 +41,8 @@
          * @param width the width of the sub window
          * @param height the height of the sub window
         */
-        SubWindow(Window* lcd, unsigned int offsetX, unsigned int offsetY, unsigned int width, unsigned int height);
-        virtual void writeText(unsigned int line, unsigned int pos, char text[]);
+        SubWindow(Window* lcd, const unsigned int offsetX, const unsigned int offsetY, const unsigned int width, const unsigned int height);
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[]);
         virtual int getHeight(){return _height;};
         virtual int getWidth(){return _width;};
         /**
--- a/teewindow.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/teewindow.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -30,7 +30,7 @@
     _width=_lcds[0]->getWidth();
 }
 
-void TeeWindow::writeText(unsigned int line, unsigned int pos, char text[]) {
+void TeeWindow::writeText(const unsigned int line, const unsigned int pos, const char text[]) {
     int len=_lcds.size();
     for (int i=0;i<len;i++) {
         _lcds[i]->writeText(line,pos,text);
--- a/teewindow.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/teewindow.h	Tue Nov 16 20:49:18 2010 +0000
@@ -43,7 +43,7 @@
         /**
          * writes the text to all parent windows
         */
-        virtual void writeText(unsigned int line, unsigned int pos, char text[]);
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[]);
         virtual int getHeight(){return _height;};
         virtual int getWidth(){return _width;};
         /**
--- a/terminal.cpp	Mon Nov 15 22:37:30 2010 +0000
+++ b/terminal.cpp	Tue Nov 16 20:49:18 2010 +0000
@@ -42,7 +42,7 @@
     return text;
 }
 
-void Terminal::writeText(unsigned int line, unsigned int pos, char text[]) {
+void Terminal::writeText(const unsigned int line, const unsigned int pos, const char text[]) {
     _window->writeText(line,pos,text);
     int min=pos+strlen(text);
     if (min>_width)
@@ -52,7 +52,7 @@
     }
 }
 
-void Terminal::addText(char text[]) {
+void Terminal::addText(const char text[]) {
     delete [] _lines[0];
     for (int i=0;i<_height-1;i++) {
         _lines[i]=_lines[i+1];
--- a/terminal.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/terminal.h	Tue Nov 16 20:49:18 2010 +0000
@@ -41,12 +41,12 @@
          * works like the normal writeText method, 
          * but also stores the written text into the internal buffer (which makes it subject to scrolling)
         */
-        virtual void writeText(unsigned int line, unsigned int pos, char text[]);
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[]);
         /**
          * write the given text into the last line (at the first position)
          * @param text the text to write
         */
-        virtual void addText(char text[]);
+        virtual void addText(const char text[]);
         virtual int getHeight(){return _height;};
         virtual int getWidth(){return _width;};
         virtual void clear();
--- a/window.h	Mon Nov 15 22:37:30 2010 +0000
+++ b/window.h	Tue Nov 16 20:49:18 2010 +0000
@@ -37,7 +37,7 @@
          * @params pos the column where to write
          * @params text the text to write
         */
-        virtual void writeText(unsigned int line, unsigned int pos, char text[])=0;
+        virtual void writeText(const unsigned int line, const unsigned int pos, const char text[])=0;
         /**
          * @param returns the height of the window
         */