Not sure if CircuitPython module can be used with MicroPython for my CharliePlex and Huzzah

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
TitaniumCoder477
Posts: 2
Joined: Sat Jun 11, 2022 1:29 pm

Not sure if CircuitPython module can be used with MicroPython for my CharliePlex and Huzzah

Post by TitaniumCoder477 » Sat Jun 11, 2022 1:34 pm

I bought a Adafruit 15x7 CharliePlex FeatherWing to use with my Adafruit Feather HUZZAH ESP8266, but I may have made a mistake. I did not realize that documentation talks about using CircuitPython, not MicroPython. Are the former's modules compatible and I just need to know how to install them in MicroPython?

Docs:
https://learn.adafruit.com/adafruit-15x ... cuitpython
https://github.com/adafruit/Adafruit_Ci ... IS31FL3731

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Not sure if CircuitPython module can be used with MicroPython for my CharliePlex and Huzzah

Post by scruss » Sat Jun 11, 2022 10:08 pm

They're not generally compatible. It takes a bit of time and learning to port from one to the other.

There is a pure MicroPython IS31FL3731 driver hidden inside the Elecfreaks Pico:ed MicroPython library: pico_ed/Pico_ed.py at master · elecfreaks/pico_ed - but it needs a bit of work to make stand-alone.

******************** oh hey! ********************
I just remembered that Adafruit used to be all about MicroPython before they went off and rage-forked the project, and I found this: adafruit/micropython-adafruit-is31fl3731: Micropython driver for charlieplexed PWM LEDs. I don't know if it still works, but I've got a charlieplexed featherwing somewhere so might be able to try it

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Not sure if CircuitPython module can be used with MicroPython for my CharliePlex and Huzzah

Post by scruss » Mon Jun 13, 2022 2:50 pm

Yes: can confirm that it works:

Code: Select all

# Charliewing / Thing+ RP2040 / MicroPython 1.18 - scruss, 2022-06
# Library:
#  https://github.com/adafruit/micropython-adafruit-is31fl3731

import is31fl3731
from machine import I2C
from time import sleep_ms
from random import seed, randint

i2c = I2C(1)  # RP2040 specific: scl=7, sda=6
display = is31fl3731.CharlieWing(i2c)

seed(None)
while True:
    for y in range(7):
        for x in range(15):
            # color can be 0..255, but LEDs get hot if too bright
            display.pixel(x, y, color=8*randint(0, 15))
    sleep_ms(9)  # update display roughly once per second
Since you are using an ESP8266 Feather, the example from the docs should probably work straight off:

Code: Select all

import is31fl3731
from machine import I2C, Pin
i2c = I2C(Pin(5), Pin(4))
display = is31fl3731.CharlieWing(i2c)
display.fill(127)

TitaniumCoder477
Posts: 2
Joined: Sat Jun 11, 2022 1:29 pm

Re: Not sure if CircuitPython module can be used with MicroPython for my CharliePlex and Huzzah

Post by TitaniumCoder477 » Wed Jun 15, 2022 1:58 pm

That worked!! You're awesome! I am going to have so much fun with this now. I was worried I had bought two incompatible things and had unwittingly bitten off more than I could chew.

Yeah, about that fork... I wasn't even aware of it until this week when I was trying to figure this out and stumbled across https://learn.adafruit.com/getting-star ... cuitpython. Thank you again for the help!

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Not sure if CircuitPython module can be used with MicroPython for my CharliePlex and Huzzah

Post by scruss » Wed Jun 15, 2022 2:41 pm

You're welcome!

If you want to display text, you might find micropython-adafruit-bitmap-font useful too. One thing I found is that, even though bitmapfont.py can go in your board's /lib folder, the font5x8.bin must be in the same folder as the script calling it. If you get a ENOENT error, that's likely the problem

Post Reply