fork of original freetronics library
Fork of Freetronics_16x2_LCD by
Diff: freetronicsLCDShield.cpp
- Revision:
- 1:ddcefddda4a7
- Parent:
- 0:01f3d38f8b6d
- Child:
- 4:b4b2435f4a7f
--- a/freetronicsLCDShield.cpp Tue Oct 08 08:46:39 2013 +0000 +++ b/freetronicsLCDShield.cpp Sun Oct 27 07:07:53 2013 +0000 @@ -1,3 +1,25 @@ +/* mbed freetronicsLCDShield Library, written by Koen J.F. Kempeneers + * koen.kempeneers@damiaaninstituut.be + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #include "mbed.h" #include "freetronicsLCDShield.h" @@ -54,11 +76,17 @@ writeCommand(0x0C + tmp); } -void freetronicsLCDShield::shift (bool left) { - int tmp = 0; - - if (left) tmp = 0x04; - writeCommand(0x18 + tmp); +void freetronicsLCDShield::shift(bool direction) { + if(direction == LEFT) shiftLeft(); + else shiftRight(); +} + +void freetronicsLCDShield::shiftLeft(void) { + writeCommand(0x18 + 0x04); +} + +void freetronicsLCDShield::shiftRight(void) { + writeCommand(0x18); } void freetronicsLCDShield::cls(void) { @@ -73,6 +101,16 @@ wait(0.00164f); } +void freetronicsLCDShield::writeCGRAM (char address, const char *ptr, char nbytes) { + // Write the address only once, it is autoincremented + writeCommand(0x40 | address); + + // Write the data + for(int i = 0; i < nbytes; i++) { + writeData(*ptr++); + } +} + // Low level output functions void freetronicsLCDShield::writeByte (int byte) { // Split the byte in high and low nibble, write high nibble first