Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    using c++ libs with micropython

    Scheduled Pinned Locked Moved MicroPython
    13 Posts 3 Posters 657 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      tttadam
      last edited by

      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?

      O robert-hhR 2 Replies Last reply Reply Quote 0
      • O Offline
        oligauc @tttadam
        last edited by

        @tttadam Yes, you can include C++ libraries in the pycom repositories. You need to make a component in the pycom-esp-idf repository and then expose the functions / methods through the pycom-micropython-sigfox repo so that you can program your device in Python.

        Please see the example here

        1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @tttadam
          last edited by

          @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.

          T robert-hhR 2 Replies Last reply Reply Quote 0
          • T Offline
            tttadam @robert-hh
            last edited by

            @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 result

            So if you could recommend me librarys it would be much appreciate :)

            1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @robert-hh
              last edited by

              @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_ms

              and 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()

              T 1 Reply Last reply Reply Quote 0
              • T Offline
                tttadam @robert-hh
                last edited by

                @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?

                T 1 Reply Last reply Reply Quote 0
                • T Offline
                  tttadam @tttadam
                  last edited by

                  @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.)

                  T 1 Reply Last reply Reply Quote 0
                  • T Offline
                    tttadam @tttadam
                    last edited by

                    @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....

                    robert-hhR 1 Reply Last reply Reply Quote 0
                    • T Offline
                      tttadam
                      last edited by

                      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

                      robert-hhR 1 Reply Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @tttadam
                        last edited by

                        @tttadam Good. I saw you messages, but was busy, and it looked like you would make your way.

                        1 Reply Last reply Reply Quote 0
                        • robert-hhR Offline
                          robert-hh @tttadam
                          last edited by robert-hh

                          @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)

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            tttadam
                            last edited by

                            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.

                            robert-hhR 1 Reply Last reply Reply Quote 0
                            • robert-hhR Offline
                              robert-hh @tttadam
                              last edited by

                              @tttadam Very good.

                              1 Reply Last reply Reply Quote 0

                              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
                              • 1 / 1
                              • First post
                                Last post

                              Pycom on Twitter

                              Pycom