-
Notifications
You must be signed in to change notification settings - Fork 36
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
Request: Flip 8x8 matrix #44
Comments
Yes, you can use the Adafruit GFX api using the TM16xxMatrixGFX class, which gives you more control over manipulating the display. The standard GFX setRotation() method allows rotation of 90/180/270 degrees:
To adjust for mirrored connections (which I've done on my own PCB), the setMirror() method was added:
|
Thank you for your answer.
With this code I get:
And with this code I get: When rotate=0 the second display seems to be at the bottom of the first, not at right, and when I set rotate=1 the order is right but both displays are rotated 90 degrees. I tried to change width and height but it did not help. |
Oh boy... you've got some interesting wiring going on your PCB.
It's kind of hard do describe, but based on your images I think I can assume that you have one TM1640 chip connected to both displays, but you switched rows and columns. The second image shows a configuration where at least all four pixels are shown. I think left top is (0,0) and right bottom is (15,7) where you would like left-bottom to be (0,0) and right-top to be (15,7). Perhaps you can check that? (BTW. The width and height parameters should match the actual layout). Can you tell me how the displays are connected to the chip? In your second image I think I see this layout:
Both setRotation and setMirror work on the entire set of pixels in the offscreen GFX bitmap, a buffer allocated by the constructor of the TM16xxMatrixGFX class. For your particular setup, it may be needed to remap the pixel-location. |
Ok, when I use TM1640Anode class, the 1st row of the second display lights at the same time with 7th row of the first display. No more rows of second display is on. |
Allright, thanks for uploading additional info and the schematic. Apparently things are a bit more complicated than I hoped. Not having your module makes it a bit hard to help you, but I'll try my best with what I've got. (Unfortunately I don't have the means to provide full support, but I'll try to help as far as my spare time permits.) FYI: I used TM1640Anode mainly to connect 15-segment alphanumeric LED-displays to the TM1640. The TM1640Anode class provides segment mapping. Using the setSegmentMap() method a 16-byte array can be used to list which GRD line should be mapped to which position. If setSegmentMap() is not called, no mapping is performed, but the setSegments() function will still duplicate G1 to G2 (ie. GRD8 to GRD9) to emulate the G segment of a 7-segment display. I'm not sure if dual common anode matrices are supported by TM16xxMatrixGFX. At the moment the TM16xxMatrixGFX class only calls setSegments() and not setSegments16(), which explains why that 7th row also lights up the first row of the second display. |
I tried TM16xxMatrix16 class, here is the result:
So I am on the right way. For example, I think I need to modify setColumn function to split the uPixels and apply, but I don't know how. |
Good to read you're getting there. Although perhaps with a bit more effort than anticipated, I'm sure that eventually you will reach your goal! I will try to help you make a working setPixel() function for your module, but this may require multiple steps involving your cooperation. For clear definition and understanding: when you say columns you mean the vertical bars of both displays on your module and rows would mean horizontal rows along both displays? So your first test with matrix.setColumn(i, 65535); lights up a column of 8 leds on each display. For i=0 it lights the left-most columns of each display and for i=7 the right most columns. The parameter uPixels in fact controls the rows of two columns of your module and the parameter nCol specifies which two columns. It kind of means that if the right display would be positioned below the left display, the module would perhaps work as intended, having all column-pixels in a single column. Unfortunately your columns are split in two, so a correction in software is needed. Your second test with matrix.setColumn(0, 65280); proves your assumption that you need to split things up. Since I don't have a test environment, I need you to participate in an exercise of trial-and-error. Let's continue to use TM1640Anode and TM16xxMatrix for this. For fun here is a first (silly and untested) attempt to get 16 columns of 8:
Note that the code above is just a test, it should/could do something, but doesn't properly address individual pixels. I need a bit more time to think of suitable approaches. To be continued... |
Yes, columns are vertical bars and rows are horizontal.
WhatsApp.Video.2024-01-18.at.01.35.42.mp4 |
Cool! Although not working okay it's still nice to see those blinkenlights! To get a moving bar you can do this:
Now to get a semi-operational setPixel() you can try this:
The problem with the implementation above is that the pixels are not independent. Setting a pixel in one column impacts all other pixels in the shared columns of left and right matrix. To resolve such issues, TM16xxMatrix16 uses the bitmap buffer. |
Thank you so much! |
One quick question in between: in the second Adafruit GFX example where you had four pixels showing, were you using TM1640 or TM1640Anode in combination with TM16xxMatrixGFX? If it was TM1640 some other solution may work too. |
I was using TM1640. |
FYI: I think I have a solution for using TM1640/TM16xxMatrixGFX. I've made an extended class that inherits from TM16xxMatrixGFX and adds a method to fix your issue. I'm currently testing that code with my regular TM1640 dual matrix (since I still miss your module). I will post something soon... |
Thanks. |
Hello again, As for usage:
The code is not very sophisticated, but it gave me promising results. Because this is highly experimental I've implemented a few different fixing options. Values 1,2 and 3 involve rotation, values 4-6 don't. My best guess for your module is value 1. On my common cathode dual matrix that value gives the reverse effect from what I understand your module does. I've chosen to extend TM16xxMatrixGFX so you can enjoy the richness of the GFX api and easily use print and draw figures. Hopefully this extended class provides a fix. Unfortunately I don't have common anode displays or a module that is wired like yours, so I can't make any promises. Good luck! |
And everything works perfect! Thank you so much... |
Excellent! Thank you for providing feedback, for your swift replies and for trying things out. It took me a bit of time to understand the details of your issue. I'm glad to read that now you have a working solution. If other people report similar issues, I can now suggest them to try this. Perhaps I'll integrate this feature in a future version, although that may require some more development. Have fun using the TM16xx library for your module! |
Hello, I am using two 8x8 dot matrix displays with TM1640. Due to my PCB design 8x8 matrices are flipped 90 degress counter clockwise.
Can I do something with code to correct the orientation? Thanks.
The text was updated successfully, but these errors were encountered: