d2r2 / go-max7219

Golang library to interact with LED driver MAX7219 via SPI-bus from Raspberry PI.
MIT License
14 stars 12 forks source link

orientation #1

Open DaBlitzStein opened 6 years ago

DaBlitzStein commented 6 years ago

Hello, I'm used a group of matrix connected in other orientation. How can change the orientation of the matrix?

Thank you in advance.

d2r2 commented 6 years ago

Hi,

To flip or mirror letters in the led matrix, I guess simplest way is to play with function GetLetterPatterns() from fonts.go file, which returns bits patterns for fonts adopted to 8x8 led matrix. Some wrapper function should be created, which will mirror or flip bits if required.

I can add this functionality, if you'l like. It's not difficult.

Denis

DaBlitzStein commented 6 years ago

Thank you for the answer. I mean the order of the device hardware.

https://www.amazon.es/kwmobile-m%C3%B3dulo-matriz-Raspberry-Arduino/dp/B06XJ9ZX17/ref=sr_1_1?ie=UTF8&qid=1512187142&sr=8-1&keywords=led+raspberry

Connected like this, instead top input and bottom output of the block, left input, right output.

I hope i explained this corretly.

Thank you in advance!

d2r2 commented 6 years ago

Perhaps I understand you and you would like to rotate output at an angle of 90 degree...

Do you have device mentioned from amazon on your hand? I'm asking, because perhaps you don't need to rotate output at all, since I have a little outmoded version, which is not possible to stack the way new device let.

DaBlitzStein commented 6 years ago

Sorry for the delay answering.

yes, i have the hardware in hand.

what do you need?

d2r2 commented 6 years ago

OK, so my proposal - could you send me a picture or video, how symbols looks like (if you provide video it will be more clear for me how symbols are sliding, but few pictures made with small delay, I hope, will be OK)? I guess this will be enough for me to modify software in right direction. You can mail me here.

egnerfl commented 5 years ago

Any update on this?

d2r2 commented 5 years ago

Hi @egnerfl. I hope I will find a time in next 3 weeks to improve functionality in this direction. As I found, it is not a simple task, because on hardware level there is no way to rotate leds sliding, but require writing of extra software layer, which do this job and translate calls to hardware.

egnerfl commented 5 years ago

ok, I will see if I find some time as well :)

d2r2 commented 5 years ago

@egnerfl, max7219 chip is based on "shift register" functionality and can shift led lights only in one direction (no way how to change this in other 3 possible direction on hardware level). So, in past times when we had only 8x8 separate led blocks, it was easy physically rotate it on the table. So we put it like in picture, with wire connection from bottom to top in between.

But those days are over, and we have today led block 32x8 (which inside connect 8x8 leds side by side, and this video demostrate what we have today). So I do not see other decision, but only to write extra software layer, which will keep in memory 32x8 bit map and translate more complicated calls to hardware level to provide custom rotating functionality.

You can try and get back with any results for further discussion :+1: :)

adrianh-za commented 5 years ago

Hi

I have forked and enhanced the library to allow for setting the rotation of the 4-in-1 LED modules in a matrix, and scrolling of the text with the rotation applied.

https://github.com/adrianh-za/go-max7219

d2r2 commented 5 years ago

Hi @adrianh-za! I will take a look and reply in this week end. Thank you for waiting, Denis

adrianh-za commented 5 years ago

Hi @d2r2

That will be great.

The main changes are all in the matrix.go file. Its basically a software layer to handle the 4-in-1 LED modules orientation (as per this issue). The other changes to files are merely my examples to make use of the enhanced library.

I look forward to your comments :)

d2r2 commented 5 years ago

Hi @adrianh-za,

This is nice, that somebody finally put their hands to the code and made it possible to output text with popular 1x4 matrix block correctly. I will spend some time later to integrate you changes via pull request, since I have downloaded you version and have tried you samples - everything fine with output text to 1x4 matrix block! :+1:

But regardless of whether I find the time or not to integrate your changes back to my lib, I would love to share my thoughts on what ideal architectural changes I would expect from my primitive lib: 1) Topology configuration. 1x4 matrix block this is good! But in real life someone might want to combine few 1x4 matrix block in one row. Even someone want to build configuration with few rows, for instance, if you join a lot of 1x4 blocks, you will get finally 8x12 matrix screen. So "topology configuration layer" should provide configuration, how each row connected with each other. Additionally "topology configuration" should allow to connect rows in different way. 2) Once you has possibility to build and configure matrix with "topology configuration layer", you have in the end screen which include more than 1 row. In this case you probably want to scale your font to whole screen height. Either you want to have possibility to work with the screen as with dot-canvas, to draw dots on the screen by XY coordinates. Either you can use the ability to change the brightness of LEDs to output primitive picture in black and white with undertones.

So taking all these ideas and experience you already have, you can build new lib with all these architectural advantages, which allow you to build custom HxW size screen with API which let end user transparently output text or graphics.

I would probably do it all if I had enough free time - maybe you could do it better.

adrianh-za commented 5 years ago

Hi @d2r2

Thanks for feedback.

You can setup a longer single row matrix configuration with 1 or more 4-in-1 modules. I tested with 2 x 4-in-1 modules (IE: 8 x 1) and it scrolled perfect. I merely set the cascaded argument to 8 when calling NewMatrix()

func NewMatrix(cascaded int, rotate Rotation) *Matrix {
    this := &Matrix{}
    this.Device = NewDevice(cascaded)
    this.Rotation = rotate
    return this
}

As for the Topology configuration, that would be an awesome enhancement. It is definitely something that needs a good think abou,t and some playing around with the LED modules and library. Its probably less about the hardware, and more about maths to make it work. Hopefully I will have a look closer to end of year when I have some free time.

Currently I am writing a small library for the SSD1306 OLED module. Again I am using your go-i2c library for the I2C comms. Your Go I2C library for the RPi works very well 👍

Chat soon Adrian

d2r2 commented 5 years ago

@adrianh-za, "topology configuration" nonetheless more about hardware, because as I mentioned, if you have 2 rows of led matrix block, you can join it physically by wires as minimum in two way:

1) 1st row →
           ↓
   2nd row ←
2) 1st row ⤦
         ⤦
      ⤦
   ⤦
   2nd row

So, topology layer hide from end user API how your physically join your 8x8 LED-matrices with each other on hardware level, but only leaves the opportunity to work with LED-screen with HxW characteristics.

I'm not going to spend a time in next few months on it, but if I suddenly want I will let you know. So, it will be good to get news from you, once you will find a time for this in the following months!

Kind Regards, Denis