Fork of LCD-Window which works with Enhanced TextLCD from Wim
Fork of LcdWindow by
Diff: ks0108_8bit.cpp
- Revision:
- 1:65f72ed914fa
- Parent:
- 0:ae5037e3d6e0
- Child:
- 2:5ac5bab7daaf
--- 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);
