Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: freetronicsLCDShield_HelloWorld prototipo prototipo Juego
Diff: freetronicsLCDShield.cpp
- Revision:
- 1:ddcefddda4a7
- Parent:
- 0:01f3d38f8b6d
- Child:
- 4:3a0c74cef8e8
diff -r 01f3d38f8b6d -r ddcefddda4a7 freetronicsLCDShield.cpp
--- 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
Freetronics LCD Shield