Is there any TextLCD library working on mbed-os6 in MBED Studio?

Hi,
I freshly installed Mbed Studio and want to test some 1602 LCD trough I2C. As I found for this is TextLCD library. Downloaded several version of libraries with program examples. I still not found any of working examples/libraries which can be compiled without a lot of errors. It look like all examples and all libraries are for maybe mbed-os 2 or something else old. I’m getting errors like this:
Unknown type name ‘Serial’ - The serial API is not available any more in the MbedOS6, outdated example
Use of undeclared identifier ‘udc_1’- not found what it is
wait_ms, wait - must be changed to ThisThread::sleep_for
And a lot of others errors
BTW in online MBED Compiler testing of the same libraries, code examples I receiving different faults like …[-Wc++11-narrowing]…
Can someone point me to one realty working TextLCD library with really working code example for I2C 1602 LCD?
Or better to get back in os2?

Hello,

I tried it on the Nucleo-F303K8 with the MbedOS 6.5.0 - bare metal
I already wrote about it in this post.
For an I2C expander you need to set correct one in TextLCD_Config.h. The content about it starting at line 66.

Example:

#include "mbed.h"
#include "TextLCD.h"

DigitalOut led(LED1);
I2C i2cBus(I2C_SDA, I2C_SCL);
TextLCD_I2C lcd(&i2cBus, PCF8574A_SA7, TextLCD::LCD16x2); // PCF8574A_SA7 is gpio expander i2c address from a macro what is defined in TextLCD_Config.h

int main(){
    printf("LCD Hello\n");
    lcd.cls();
    lcd.setBacklight(TextLCD::LightOn);
    lcd.printf("LCD Hello\n");

    while(1) {
        thread_sleep_for(500);
        led = !led;
    }
}

BR, Jan

1 Like

Thank you for reply.
The library mentioned in your post and code example look great, they compiled without errors.
Now I’m stuck with new problem - I can not Run this code from Mbed Studio to the board (NXP LPC1768). It stops compiling, I see message “Erasing…” and just nothing. Buttons greyed out (Run in progress). This last til I disconnecting board.
In log it stops on [2020-11-21T20:18:44.209] [INFO] root/mbs-deploy - Waiting for a debug probe matching unique ID ‘101084953B4C32AAFB2875535CFC9E32E249’ to be connected…
The problem I think is related to Studio itself, installation but I do not know exactly where to ask or I maybe I need to create new thread?
BTW I tried several code examples on online compiler and everything work great on my board

I use only ST boards but I had similar problem few days ago, I think. I solved that with restart of my PC.
If the problem will persist then create new thread under the MbedStudio section.

BR, Jan

I will try this, thanks

BR, Romas

I rejoiced too early… Restart of PC and MBED serial drivers reinstall not solved all Mbed Studio problems, so switched to Online Compiler. There is no faults in project, code downloads to my board and after reset of board there is nothing on I2C. Led blinks. I2C LCD tested with Arduino -it work great. Config set to #define LCM1602 1. I changed I2C pins to p28 and p27, as needed for my LPC1768. Checked with scope on these and other pins- nothing. LEDs blink fine. Where I miss something

It look like compilation result is lunar time dependent for me. Yesterday after reopening compiler disappeared LCDText library from project and somehow everything compiled without any errors.
Today re added the library, I2C communication started to work, found what it is “PCF8574A_SA7” and changed

`TextLCD_I2C lcd(&i2cBus, PCF8574A_SA7, TextLCD::LCD16x2);`

to
TextLCD_I2C lcd(&i2cBus, PCF8574_SA7, TextLCD::LCD16x2);

Now finally my LCD work fine.
Thank for help

Hello,

I’m sorry, I had little time on the weekend.

Ye you probably have a different model of the GPIO expander so you need diffrent address, that is normal. Anyway I gladly helped.

Mbed Studio has some issues but I use it very often and It is better than the Online compiler for me.
Sometimes it is necessary to reboot the computer, reopen application or remove and re-add the Mbed library or seldom recreate the project. But is is free, functional directly after installation without another setting. Its developers still working on its improvement.
Of course I understand, this state is not ideal for all.

However, these problems are not in the context of the name of your topic. That was the reason why I wrote to you about creation of a new topic if the problems persists.

BR, Jan