luma.led_matrix icon indicating copy to clipboard operation
luma.led_matrix copied to clipboard

Support for Scroll pHAT HD

Open thijstriemstra opened this issue 8 years ago • 8 comments

  • 17x7 matrix
  • Uses the IS31FL3731 LED matrix driver chip
  • pinout: https://pinout.xyz/pinout/scroll_phat_hd

See https://shop.pimoroni.com/collections/raspberry-pi/products/scroll-phat-hd

scroll_phat_hd_2_of_4_1024x1024

thijstriemstra avatar Mar 28 '17 23:03 thijstriemstra

I'll be able to get my hands on one later this week and test it.

thijstriemstra avatar Mar 28 '17 23:03 thijstriemstra

Looks like it is an i2c device, so should be easy to drive

rm-hull avatar Mar 29 '17 06:03 rm-hull

Finally got one on my desk, will test this now. @rm-hull where do I start, how do I test this?

thijstriemstra avatar Jun 12 '17 20:06 thijstriemstra

ping @rm-hull

thijstriemstra avatar Jul 03 '17 12:07 thijstriemstra

First things first, connect it up, and do i2cdetect -y 1 and see what address(es) it responds with.

Looking at the datasheet and adafruit arduino code, I'd be inclined to hack a little script first to understand it a bit more before diving into writing the display driver. The hack script should:

  • sets up the i2c using smbus2 (use https://github.com/rm-hull/luma.core/blob/master/contrib/tca9548a_scan.py as inspiration)
  • initializes the device into picture mode - see https://github.com/adafruit/Adafruit_IS31FL3731/blob/master/Adafruit_IS31FL3731.cpp#L25-L33 and https://github.com/adafruit/Adafruit_IS31FL3731/blob/master/Adafruit_IS31FL3731.cpp#L140
  • then add some code that does something like:
for x in range(17):
    for y in range(7):
        bus.write_byte(y, x, 0xFF)
        time.sleep(1)

and see what happens - if that worked (in some sense), you should see the LEDs progressively lighting up one by one - and that should give us a clue how to map the display (it will either be a raster scan or snake scan - similar to the WS2812 neopixel mapping on the unicorn HAT - https://github.com/rm-hull/luma.led_matrix/blob/master/luma/led_matrix/device.py#L281-L292)

Once we understand how to address it, writing a luma.led_matrix driver will be pretty simple, and we should be able to convert RGB colored images into greyscale so that the pixels have different brightness levels.

Quite happy to try organising a remote coding session (hangouts / slack / remote desktop / screenhero) ?

rm-hull avatar Jul 03 '17 16:07 rm-hull

Is there some status update on this? I have that hardware and there is a library from @pimoroni . Do you want a (a) pure independent implementation, (b) it is OK to call their library, (c) it is OK to adapt their code and reuse it (they use MIT license) while removing all the unnecessary part (font, ...)?

dglaude avatar Jan 04 '18 18:01 dglaude

I most emphatically promote borrowing and re-purposing our code!

If you need any help getting Scroll pHAT HD up and running, I'd be happy to test/review your code and answer any questions you might have.

I'd also love to see support for the Unicorn HAT HD, which uses SPI.

The Scroll pHAT HD pixels aren't addressed in any way that would make sense to standardise, but you can convert X/Y coordinates into an X index into the pixel memory using the _pixel_addr method on this class:

class ScrollPhatHD(Matrix):
    width = 17
    height = 7

    def _pixel_addr(self, x, y):
        if x > 8:
            x = x - 8
            y = 6 - (y + 8)
        else:
            x = 8 - x

        return x * 16 + y

https://github.com/pimoroni/scroll-phat-hd/blob/1637fce37f9d8c353ef8d658792164e1e1ea02a2/library/scrollphathd/is31fl3731.py#L647-L658

Gadgetoid avatar Aug 24 '18 08:08 Gadgetoid

I'd also love to see support for the Unicorn HAT HD, which uses SPI.

@Gadgetoid - see #188 - wip, but is working

rm-hull avatar May 25 '19 00:05 rm-hull