using c++ libs with micropython
-
Hello there! :)
I have an 1602 rbg lcd from dfrobot (DFR0464) . This lcd only has c++ arduino library avaible, no micropython, or at least a i didn't find it yet. It shows up at I2C bus like three separate device: [62, 96, 112]
Can I use somehow c++ libs with micropython? -
-
@tttadam It should be less complicated to combine a normal LCD1602 driver for the text and a PCA9633 driver for the background. For both, you find examples on the net. The address 96 and 112 would be the PCA9633 RGB led driver, 62 the LCD.
-
@robert-hh Thanks for the tip, but I was unable to make any progress :(
I use this library for the LCD, this one worked fine with one of those i2c backpacks and an lcd.
This times runs without an error, but the display doesn't show anything, just all the pixels in the first row are on.
regarding the rgb led I found this library. This is written in python. but I tried out the writeto_mem() methods in command line, it also did nothing.
Also did a tons of googleing, with out any resultSo if you could recommend me librarys it would be much appreciate :)
-
@robert-hh There is a driver here: https://github.com/dhylands/python_lcd
called pyb_i2c_grove_rgb_lcd.py. It seems to be for the right PCD, but the wrong board. But you have only to replace the calls to replace
from pyb import I2C, delay
with:
from machine import I2C
from utime import sleep_msand you have to replace calls to delay() with calls to sleep_ms(), and adapt the I2C api calls, which more or less replace:
i2c.mem_write(data, addr, memaddr, *, timeout=5000, addr_size=8)
into
i2c.writeto_mem(addr, memaddr, buf, *, addrsize=8)
Which just means, that the arguments are rotated.i2c.mem_write()
-
@robert-hh i am not sure how the arguments are rotated, I am getting an I2C bus error for this line (basically at the beginning :D, at line 75 )
"""Writes a command to the LCD."" self.i2c.writeto_mem(self.bl_i2c_addr, self.LCD_DDRAM, cmd)I am using it the wrong way?
-
@tttadam okay, I have some results! :)
I am able to init the display, but for lcd.putstr("hello") only got "@@@@@" signs on the LCD. (Still it's something)
lcd.clear() works
lcd.blink_cursor_on() works
lcd.blink_cursor_off() works, but leave an "" on the lcd, lcd.clear can't remove it, if I write on the display anything (right now anything is "@" signs) the "" will be the last caracter
lcd.backlight_rgb() or any backlight related command does nothing :( and it kills the lcd. (so after I use lcd.backlight() the caracters dissapear and the device doesn't react any of my commands until I reinit it.) -
@tttadam I found the issue. So I was using .writeto_mem in wrong parameter order.
Now works. exept the backlight. still no show any color.... -
okay I made some more progress.
I can make only one part work, lcd or backlight...
I am not sure what would be the solution for that...it depends how I init the lcd lcd = I2cLcd(i2c, XX, 2, 16, YY)
xx yy
62 96 - rgb ok / lcd fail
62 113 - init fail
96 62 - rgb fail /lcd ok
96 113 - init fail
113 62 - rgb fail / lcd ok
113 96 - rgb ok /lcd fail -
@tttadam Good. I saw you messages, but was busy, and it looked like you would make your way.
-
@tttadam As far as I understand the driver, XX is for the LCD and YY for the backlight. You may check if in the process of rotating the parameters you assigned them wrong. The only places where the LCD is addressed is in the methods hal_write_command() and hal_write_data() with self.i2c_addr. All other calls should contain self.bl_i2c_address. (bl like backlight).
So it should be (i2c, 62, 2, 16, 96) -
I figured it out eventually :)
I think the library was not working correct.
The hal_write_data and hal_write_command somehow got the blacklight I2C adress not the display it self.
that caused the issue. now works like charm.
I will post the code to other topic for this display. -
@tttadam Very good.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login