Very cool OLED 16x2 character display compatible with the Arduino LiquidCrystal library (8-bit. To make it work with 4-bit, a small modification is required to the LiquidCrystal library initialization code)
To make it work with 4-bit, a small modification is required to the LiquidCrystal library initialization code)
Since there's no reference to this modification on your web page and there is no obvious link to a data sheet does this mean that we have to order one of the devices in order to find out the nature of this modification?
"Plugh" worked pretty well, although I'm still in a maze of twisty little passages.
You can make the following mod to the "begin" function in LiquidCrystal.cpp (libraries folder) . . .
void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
if (lines > 1) {
_displayfunction |= LCD_2LINE;
}
_numlines = lines;
_currline = 0;
// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
_displayfunction |= LCD_5x10DOTS;
}
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
// according to datasheet, we need at least 40ms after power rises above 2.7V
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
delayMicroseconds(50000);
// Now we pull both RS and R/W low to begin commands
digitalWrite(_rs_pin, LOW);
digitalWrite(_enable_pin, LOW);
if (_rw_pin != 255) {
digitalWrite(_rw_pin, LOW);
}
//put the LCD into 4 bit or 8 bit mode
if (! (_displayfunction & LCD_8BITMODE)) {
// this is according to the hitachi HD44780 datasheet
// figure 24, pg 46
// FOR OLED INIT - Runs before regular init - does not affect non-OLED
write4bits(0x00);
delayMicroseconds(4500); // wait min 4.1ms
write4bits(0x00);
delayMicroseconds(4500); // wait min 4.1ms
write4bits(0x00);
delayMicroseconds(4500); // wait min 4.1ms
write4bits(0x00);
delayMicroseconds(4500); // wait min 4.1ms
write4bits(0x00);
delayMicroseconds(4500); // wait min 4.1ms
// FOR OLED INIT - must comment out the 3 0x03 commands . . .
// we start in 8bit mode, try to set 4 bit mode
//write4bits(0x03);
//delayMicroseconds(4500); // wait min 4.1ms
// second try
//write4bits(0x03);
//delayMicroseconds(4500); // wait min 4.1ms
// third go!
//write4bits(0x03);
//delayMicroseconds(150);
// finally, set to 4-bit interface
write4bits(0x02);
} else {
// this is according to the hitachi HD44780 datasheet
// page 45 figure 23
// Send function set command sequence
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(4500); // wait more than 4.1ms
// second try
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(150);
// third go
command(LCD_FUNCTIONSET | _displayfunction);
}
// finally, set # lines, font size, etc.
command(LCD_FUNCTIONSET | _displayfunction);
// turn the display on with no cursor or blinking default
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
display();
// clear it off
clear();
// Initialize to default text direction (for romance languages)
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
command(LCD_ENTRYMODESET | _displaymode);
}
Basically you send 5 (0x00) commands before the standard init and comment out the 3 (0x03) commands.
It needs work however. I see the following issues . . .
reset doesn't always work correctly
sometimes the line numbers get mixed up
the "createChar" function is not working and stops the display from working
I got the above info from NKC, and also a data sheet (attached). The data sheet also has a description of 4 bit init, but I've had no luck with it.
It's a gorgeous display. Highly visable, no contrast or backlight needed, low power.
I hope someone can get the kinks out.
(I was hoping to make an alternate init for this in the sketch and keep the LiquidCrystal lib in tact, but I had no luck with that approach.)
It looks like that data sheet was written by a committee, some things in there twice and others missing. I love the flowchart entry: "Wait for power stabilization ??ms". I can't believe that the data sheet for a device that incorporates OLEDs shows timing diagrams for the interface with 8080 and 6800 processors but not with current microcontrollers. It seems that they may be ashamed to publish that data sheet on their website.
I see that they still have this statement:
Therefore, the Busy Flag should be checked to make certain that BF = "0" before sending another instruction from the MPU. If not, the time between the first instruction
and the next instruction is longer than the time it takes to execute the instruction itself.
This means that if you don't read the busy flag then you have to provide time delays, but they do not provide the instruction execution times (all except one are shown as 0) that you need to do this.
I hope someone can get the kinks out.
I wouldn't mind trying to figure out how to use the module but at this point I wouldn't purchase one in order to be a beta tester. If NKC sends me a sample I'd be glad to take a stab at it.
I was never able to get all the possible points in Adventure, always shy by just one point. I think the missing point could have been picked up if I could just figure out how to do everything else efficiently enough so I did not have to buy batteries for my flashlight.
Hi,
I know this is a pretty old thread but I'm currently dealing with exactly the same display (and the same problems):
It needs work however. I see the following issues . . .
reset doesn't always work correctly
sometimes the line numbers get mixed up
the "createChar" function is not working and stops the display from working
Does anybody have a solution for it? I don't have problems with the createChar-function, it works fine for me. But I have problems with the line numbers mixing up and generally corrupt symbols after a warm restart.