Developer instructions to compile new tft.ubl library

Issue #220 resolved
Philip Tallents created an issue

Hi John,

I’ve developed a robot with the ESP32 that I want to teach to kids using your MicroBlocks software and would like to update the tft.ubl file to work with an ST7789 LCD on custom ESP32 pins. Is this possible, or would I need to send you the pinout information to include it in your software?

Cheers,

Phil

Comments (7)

  1. Bernat Romagosa

    Hi, Phillip.

    The .ubl library is calling the TFT primitives in the virtual machine, so those are the ones that would need to be tailored to your robot.

    Luckily, the ST7789 display is already being used by one of our supported boards, so it should be fairly easy for you to include your particular configuration. Take a look at the tftPrims.cpp file under the vm folder.

    Alternatively, you could test installing the VM for the M5Stick-C Plus into your board. This is an ESP32 board that uses the same TFT display as you, so you may luck out and everything may work out of the box.

  2. Philip Tallents reporter

    Thanks Bernat,

    I've tried the M5 plus but will again.

    I think I need to change the pins, but nothing was working last time.

    I'll check the tftPrims.cpp file

    Regards, Phil

  3. Philip Tallents reporter

    Thanks, the tftPrims.cpp is what I had been trying. I tried again with the M5-Stick C plus pins, SDA on 13, SCL on 14, RES on 18, DC on 23. It didn’t work. These displays don’t have a CS pin though and use a 240x240 display.

    Also, it seems like there are only 5 or 6 GPIO pins available using this M5-Stick C plus firmware.

    Unfortunately, it’s hardly useful at all for my robot.

    Is there a way to change the accessibility of the gpio pins in another cpp file, and these ST7789 pins (or even another driver) to compile them into the firmware? I’ve done this already with an ST7789_mpy driver for use with the micropython firmware on this board and this works great. I’ve installed VS Code and PIO but I still don’t understand how to compile the projects, or even what language.

  4. John Maloney repo owner

    Unfortunately, I don’t think the M5-Stick C+ VM will work because that board has a custom power control chip that controls the LED backlight and I’m guessing your robot doesn’t use that chip.

    You could modify tftPrims.cpp to add an #ifdef for your robot with the pins you are using. The existing ST7789 could serve as a starting point. You could then build a distribute a custom MicroBlocks VM for your robot. Doing that requires some C++ coding but since you’ve done a ST7789_mpy driver you probably have the necessary skills.

    To build with PlatformIO, you just type something like:

    pio run -e m5stack -t upload

    in the terminal. You would add an entry for your robot to the platformio.ini file so the command would be something like:

    pio run -e PhillipsRobot -t upload

    Backing up a step or two, I’d actually start by writing a test program using the Arduino framework with the Adafruit graphics libraries. Once you have that working, it will be easier to figure out how to incorporate it into the MicroBlocks virtual machine.

  5. Log in to comment