Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IS31FL3741 Framebuffer Driver #5584

Merged
merged 17 commits into from
Nov 24, 2021
Merged

IS31FL3741 Framebuffer Driver #5584

merged 17 commits into from
Nov 24, 2021

Conversation

gamblor21
Copy link
Member

Similar to the RGBMatrix (and also borrowing from I2CDisplay) this is a native driver for the IS31FL3741 chipset. I am releasing this is draft for others to take a look at but still requires some cleanup and I have some questions about the best way to implement some options. I have only tested this on the Adafruit Eyeglasses as they are the only IS31 board I have.

The main question I still have outstanding is how to pass in mapping from the display to actual LEDs. The glasses matrix is currently in the code but I am thinking having it as a parameter to pass in may make more sense and support future uses.

Right now this is only set to compile in the LED glasses driver board.

import is31fl3741
import displayio
import framebufferio
import board
import busio

displayio.release_displays()

i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000)
is31 = is31fl3741.is31fl3741(width=54, height=15, i2c=i2c, scale=True, gamma=True)
display = framebufferio.FramebufferDisplay(is31, auto_refresh=True)

bitmap = displayio.Bitmap(display.width, display.height, 2)
palette = displayio.Palette(2)
palette[0] = 0x000000
palette[1] = 0x990099
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)

#draw a line at the bottom of the display
for y in range (12,15):
    for x in range(54):
        bitmap[x,y] = 1

group = displayio.Group()
group.append(tile_grid)
display.show(group)

@gamblor21
Copy link
Member Author

One open question to anyone who has a thought: Any idea how to allow someone to take advantage of the glasses' rings. You could use the python library to otherwise address them or maybe another helper python library that is aware of the displayio display (and which pixels overlap) would be beneficial?

bool auto_gamma;
} is31fl3741_is31fl3741_obj_t;

static const uint16_t glassesmatrix_ledmap[18 * 5 * 3] = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at ideas on how to pass this data into the display driver

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing in a byte buffer is how I'd do it. I'd assume we'd provide libraries that do the init. So, most folks wouldn't need to worry about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You now pass in an array. Make it easy as the values are uint16 so no worries about byte ordering.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this please since it is passed in now.

shared-bindings/is31fl3741/__init__.c Outdated Show resolved Hide resolved
shared-module/displayio/Palette.c Show resolved Hide resolved
shared-module/is31fl3741/is31fl3741.c Outdated Show resolved Hide resolved
@PaintYourDragon
Copy link

Trying this out. Is the scrolly font available?

@gamblor21
Copy link
Member Author

Trying this out. Is the scrolly font available?
tfont.zip

This was converted from your Arduino font (possibly badly) but seems to work. Let me know if the zip attachment of it worked if not I'll upload it elsewhere.

@gamblor21
Copy link
Member Author

Trying this out. Is the scrolly font available?

This is a quick copy of the test code I used (its messy)

import is31fl3741
import displayio
import framebufferio
import board
import busio
import time
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
from rainbowio import colorwheel

displayio.release_displays()

i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000)
is31 = is31fl3741.is31fl3741(width=54, height=15, i2c=i2c, scale=True, gamma=True)
display = framebufferio.FramebufferDisplay(is31, auto_refresh=True)

is31.brightness = 1.0

text = "HELLO FROM CIRCUITPYTHON ON NATIVE DISPLAYIO"
font = bitmap_font.load_font("tfont.bdf")
color = 0xBB00BB
text_area = label.Label(font, text=text, color=color)
x = 54
text_area.x = x
text_area.y = 8

group = displayio.Group()
group.append(text_area)
display.show(group)

width = text_area.bounding_box[2]
idx = 0
while True:
    #text_area.color = colorwheel(idx)
    idx += 1
    x = x - 1
    text_area.x = x
    if x == -width:
        x = 54
    time.sleep(0.01)

@gamblor21
Copy link
Member Author

Hmm rebasing to try to fix possible conflicts I seemed to have added a lot to this PR... I'll see if I can figure out how to fix that or may have to ask (or just re-PR it I think it is ready to come out of draft)

@gamblor21
Copy link
Member Author

supporting.zip

LED mapping python file and font file to help with anyone who wants to test.

Code above should work but the new initializer for the glasses is:

from map import glassesmatrix_ledmap
is31 = is31fl3741.IS31FL3741(width=54, height=15, i2c=i2c, scale=True, gamma=True, mapping=glassesmatrix_ledmap)

@gamblor21 gamblor21 marked this pull request as ready for review November 21, 2021 20:32
@gamblor21
Copy link
Member Author

Note: I will try to add in something for the ring lights but figured it was better to put this PR in now and expand on it. Will also have to decide how/where a helper library to initialize and include the mapping for glasses (and other boards?) exists.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more things. Thanks for working on this!

ports/nrf/boards/microbit_v2/mpconfigboard.mk Show resolved Hide resolved
shared-bindings/is31fl3741/is31fl3741.c Outdated Show resolved Hide resolved
shared-bindings/is31fl3741/is31fl3741.c Outdated Show resolved Hide resolved
bool auto_gamma;
} is31fl3741_is31fl3741_obj_t;

static const uint16_t glassesmatrix_ledmap[18 * 5 * 3] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this please since it is passed in now.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates! This is cool!

@tannewt tannewt merged commit b09c777 into adafruit:main Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants