9 years, 2 months ago.

Text OLED Display and TextLCD Library

I'm trying to get a two line OLED Display working with a KL25Z, I have a similar LCD display working correctly.

I'm trying to tell the TextLCD library to use the WS0010 controller chip but I can't figure out what I'm doing wrong.

Me code is:

// Hello World! for the TextLCD
#include "mbed.h"
#include "TextLCD.h"
      
TextLCD lcd(D0,D1,D2,D3,D4,D5, TextLCD::LCD16x2, TextLCD::WS0010 ); // 4bit bus: rs, e, d4-d7

int main() {

    lcd.printf("Hello World!\n");
}

To which I get the error message:

Error: No instance of constructor "TextLCD::TextLCD" matches the argument list in "main.cpp", Line: 5, Col: 14

1 Answer

9 years, 2 months ago.

You are using the Bus interface constructor. In this case the parameter list includes default parameters for the backlight and for the second enable line.

TextLCD lcd(p15, p16, p17, p18, p19, p20);  // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780

When you want to select a different controller than the default HD44780 and you explicitly select the LCDType then you also need to provide the dummy parameters for BL and E2. This is needed because C/C++ does not allow skipping of default parameters unless they are at the end of the parameter list. Try this:

// Hello World! for the TextLCD
#include "mbed.h"
#include "TextLCD.h"
      
TextLCD lcd (D0, D1, D2, D3, D4, D5, TextLCD::LCD16x2, NC, NC, TextLCD::WS0010 ); // 4bit bus: RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=WS0010
 
int main() {
 
    lcd.printf("Hello World!\n");
}

BTW, I didnt check for the KL25Z but many arduino like boards dont use D0 and D1. The pins are use for the serial debug port to the host PC.

Accepted Answer