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

drivers: add driver for IS31FL3731 matrix LED driver #370

Merged

Conversation

antonfisher
Copy link
Contributor

This PR adds a driver for IS31FL3731 matrix LED driver.
Datasheet: https://www.lumissil.com/assets/pdf/core/IS31FL3731_DS.pdf
The first version is basic, but functional.

What's implemented:

  • picture mode ("auto frame play mode" and "audio frame play mode" are not supported in this version of the driver)
  • drawing by XY coordinates or raw pixel's index on LED layout
  • frames (0-7) and switching between them.

Supported boards:

Boards can be added in the future versions:

Tests:

  • fmt-check pass
  • unit-test pass
  • smoke-test pass for the driver:
    image
    Except the AVR part fails because I do not have avr-gcc installed.

Example code works like this:
led-driver-0
led-driver-1

@antonfisher antonfisher changed the base branch from release to dev January 30, 2022 07:45
@antonfisher antonfisher force-pushed the feature-is31fl3731-led-matrix-driver branch from fbde6dc to 50ecb0c Compare January 30, 2022 07:46
board: boardRaw,
}

err = d.configure()
Copy link
Contributor

Choose a reason for hiding this comment

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

In other drivers, we don't touch devices in New() methods. Configure() method must be called separately, usually with configuration parameters.
This means configure() must be changed to public (->Configure())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to Configure() 👍


// NewAdafruitCharlieWing15x7 creates a new driver with Adafruit 15x7
// CharliePlex LED Matrix FeatherWing (CharlieWing) layout
func NewAdafruitCharlieWing15x7(bus drivers.I2C, address uint8) (d Device, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seem to be very specific, I'd extract all code related to CharlieWing to its own file, like is31fl3731_acw15x7.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved all CharlieWing code to a separate file (struct) 👍

)

// I2CAddress -- address of led matrix
var I2CAddress uint8 = 0x74
Copy link
Contributor

Choose a reason for hiding this comment

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

How random is this address? Can it be moved to the driver itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For standalone is31fl3731 the addresses can be:

  • 0x74 (AD pin connected to GND)
  • 0x75 (AD pin connected to SCL)
  • 0x76 (AD pin connected to SDA)
  • 0x77 (AD pin connected to VCC)

For Adafruit Charlie Wing 15x7 its either 0x74 or 0x77. I guess I can make four constants, but it's up to the particular board to define address. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say have them 4 constants in the driver "registers.go" as per praxis and seen in other drivers.
Preferably with comments (exactly as you did here in comment).
And let user of the driver choose which address to use.

Copy link
Contributor

Choose a reason for hiding this comment

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

Disclaimer, I'm not a maintainer, but submitted several drivers already to this repo and sort of know the drill.
I like your PR and just want to help it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, thanks for the help! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added address constants 👍

@deadprogram
Copy link
Member

Thank you @antonfisher for working on this, and thanks @ysoldak for proving all of the feedback/reviews.

I am going to squash/merge now.

@deadprogram deadprogram merged commit 9a98d1b into tinygo-org:dev Mar 9, 2022
deadprogram pushed a commit that referenced this pull request Dec 23, 2022
IS31FL3731: add driver for IS31FL3731 matrix LED driver
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