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.
Fork of TextOLED by
Diff: TextOLED.cpp
- Revision:
- 2:45788bd06d4c
- Parent:
- 1:df8722660f48
--- a/TextOLED.cpp Tue Jul 31 04:39:41 2012 +0000
+++ b/TextOLED.cpp Wed Nov 28 03:32:30 2012 +0000
@@ -31,27 +31,31 @@
PinName d6, PinName d7, LCDType type) : _rs(rs),
_e(e), _d(d4, d5, d6, d7),
_type(type) {
+ int i;
+ _rs = 0; // command mode
_e = 1;
- _rs = 0; // command mode
wait_ms(100); // Wait 15ms to ensure powered up
+ for (i = 0; i < 5; i ++) {
+ write4bit(0);
+ }
+/*
write4bit(0x3); // 8-bit mode
- write4bit(0x0); // 8-bit mode
+ write4bit(0x3); // 8-bit mode
+ write4bit(0x0);
+*/
write4bit(0x2); // 4-bit mode
- writeCommand(0x13); // DCDC off
- wait_ms(100);
-
writeCommand(0x28); // Function set 001 BW N F - -
writeCommand(0x0C); // 0000 1 D C B
writeCommand(0x06); // Entry mode : 0000 01 I/D S
- cls();
- writeCommand(0x02); // Home
writeCommand(0x10); // Cursor and Display Shift 0001 S/C R/L 0 0
writeCommand(0x17); // DCDC on
- wait_ms(100);
+ wait_ms(10);
+ writeCommand(0x02); // Home
+ cls();
}
void TextOLED::character(int column, int row, int c) {
@@ -97,36 +101,35 @@
}
void TextOLED::write4bit(int value) {
+ _e = 1;
_d = value;
wait_us(1);
_e = 0;
- wait_us(1);
- _e = 1;
wait_ms(10);
}
void TextOLED::writeByte(int value) {
- _d = value >> 4;
+ _e = 1;
+ _d = (value >> 4) & 0x0f;
wait_us(1);
_e = 0;
wait_us(1);
_e = 1;
- wait_us(1);
- _d = value >> 0;
+ _d = value & 0x0f;
wait_us(1);
_e = 0;
- wait_us(1);
- _e = 1;
wait_us(50);
}
void TextOLED::writeCommand(int command) {
_rs = 0;
+ wait_us(1);
writeByte(command);
}
void TextOLED::writeData(int data) {
_rs = 1;
+ wait_us(1);
writeByte(data);
}
