Library to drive DogM16x text displays
Diff: DogM16x.c
- Revision:
- 1:7557380ce11e
- Parent:
- 0:c8d5f35830ce
- Child:
- 2:5c2b562c9875
diff -r c8d5f35830ce -r 7557380ce11e DogM16x.c --- a/DogM16x.c Wed Jan 12 21:26:18 2011 +0000 +++ b/DogM16x.c Wed Jan 12 21:50:39 2011 +0000 @@ -5,10 +5,14 @@ _reset = 1; _rw = 0; _enable = 0; + _type = type; - DEBUGOUT("DogM162: Start init"); + _xpos = 0; + _ypos = 0; + + DEBUGOUT("DogM16x: Start init"); Init(); - DEBUGOUT("DogM162: End init"); + DEBUGOUT("DogM16x: End init"); } @@ -17,7 +21,7 @@ void DogM16x::Init() { if (_type == DogM16x_DogM161) { - DEBUGOUT("Not implemented yet"); + DEBUGOUT("DogM16x: Not implemented yet"); return; } else { _rw = 0; @@ -84,6 +88,8 @@ void DogM16x::Clear() { WriteCommandByte(0x01); wait_ms(50); + _xpos = 0; + _ypos = 0; } /** Set Position to (x,line) @@ -95,7 +101,7 @@ int distance_per_line = 0; if (_type == DogM16x_DogM161) { - DEBUGOUT("Not implemented yet"); + DEBUGOUT("DogM16x: Not implemented yet"); return; } if (_type == DogM16x_DogM162) { @@ -106,6 +112,9 @@ } WriteCommandByte(0x80 + line*distance_per_line + x); + + _xpos = x; + _ypos = line; } /** Write a character at the current position @@ -113,9 +122,10 @@ * @param character character */ void DogM16x::WriteCharacter(char character) { - - WriteDataByte(character); - + if(_xpos < 16) { + WriteDataByte(character); + _xpos++; + } } /** Write a character at position (x,line) @@ -137,10 +147,11 @@ _rs = 1; - while (string[0] != 0x00) { + while ((string[0] != 0x00)&&(_xpos < 16)) { wait_us(30); SetData(string[0]); string++; + _xpos++; } }