-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
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
[1.1.x] Tweaks and additions for MAX7219 #11033
[1.1.x] Tweaks and additions for MAX7219 #11033
Conversation
0a49d70
to
8fa9c10
Compare
89413d9
to
e03f5ee
Compare
I'm guessing you now have a Max7219 LED matrix connected to your printer. Aren't they cool? |
Yes! I soldered one together last night and now have it connected to a bare Megatronics 3.1 for experimentation. It's a handy little device! Now I'm going to solder up another and daisy-chain them for even more coolness. |
Almost all of my printers have them. I have a few extra ones sitting around. If you make it a simple #define that says how many devices are in the chain... I'll connect up a 2nd one to at least two of my printers. It might be good to have a dynamic MCode that controls how many MAX7219's are active. The reason being more of them takes more cycles to clock out the bits. Some times more lights are valuable. But other times, especially if you are outputting a lot of debug info to the LED's, the extra CPU time might not be acceptable. Also... Just for kicks, I did a 'star burst' initialization test pattern. It would randomly pick a starting point and swell out (in a circle pattern) from there until it covered the entire matrix. And then it would pick a new location (at random) and start clearing the LED's in an expanding circle pattern. It does look pretty cool. |
40ed5de
to
a863a1b
Compare
I haven't quite figured that out yet. The datasheet talks about using the NOOP register to skip devices that are "cascaded" so I'll have to experiment with that to see how it works. I did add some code to draw numeric digits on an 8-digit numerical display. I'll have to get some of those units to play with too. |
c3a0ccc
to
118132e
Compare
I was just suggesting something more simple. I was thinking just ignore the extra displays from what is specified. They would end up with noise. But certainly, using the NOP command would be a good way to do it. I saw you changed the row and col parameters on the low level functions. That might not work for me. I have my display's orientated with the cable on the down side of the matrix. That is because I have them mounted in a printed corner piece that also holds some debug (and printer power and reset) switches. That keeps all the wiring hidden. It might be easy to add a #define to shift the row and col orientation by 90 degrees. (So row is still row, and col is still the column). |
When the displays are chained, in my testing the second one imply displayed the same content as the first one. (Well, sort of. The ALIVE LED displays the opposite.) The datasheet describes "cascaded" devices, which presumably would also support the single-unit 16x8 and larger matrixes.
By default (with It also seemed appropriate to modify the (as yet unused) Set/Clear Row/Column functions too, to make the API more consistent and abstract away the idea that a "row" always corresponds to a "register." Under the updated API a "row" is always a horizontal row, according to
With the units I have, under normal conditions the display is upright with the cables on the right.
|
The bottom picture is how I have mine configured. So... I would prefer the lower left corner is (X,Y) = (0,0) And the lower right is (X,Y)=(7,0) And the upper right is (X,Y)=(7,7) But... If you don't feel like doing that... I can mess with what you have currently defined to make that possible. Also, now might be a good time to agree (or come to consensus) that going forward, the lower left is (X,Y) = (0,0) And the lower right is (X,Y)=(7,0).
UPDATE: I didn't see that you already addressed this! THANKS! |
Yes. That is true on the units I have also. But it is easy to flip the orientation by just doing a (7-x) or (7-y) after doing the range checking. Does this mean we may need a #define ROTATED_180_DEGREES also? |
I seem to remember having issues with the orientations when working with them, not helped by the circuit board getting manufactured wrong having the displays rotated and in the wrong order.. or something it was long ago. Here is my library I used at the time though, looking through I had to be amused by the blit function I must have been feeling ambitious with what I was going to display, ended up just being a bar graph and a rotating diamond screen saver if I remember rightly. This is the numeric font I used as well, though I don't think you will be wanting scrolling numeric data
ps. I remembered what the blit method was for, .. the scrolling numeric values |
I've modified the code so you can set the CCW rotation between -270 … +270 in increments of 90. |
66346ba
to
ec0f83b
Compare
Wouldn't +/- 180 degrees be enough? On this line: #define MAX7219_ROTATE 0 // Rotate the display counter-clockwise (multiple of +/- 90°) I would suggest we give the user some clue how to know the proper number. For example, "if your wires are at the bottom of the Max7219 Matrix, you need -90. If the wires are at the left side, you need -180. |
For my unit, the result is:
|
I'm not sure this is universal. It will depend on how the unit is constructed. |
I think all the units commonly available are the same. They all follow the 'reference design'. And I've gotten them from 3 different sources and everything is the same. What I meant was depending on where the user's wires are located, we should be able to communicate the 'correct' rotation. It probably would be good if everybody has the status lights and such in the same location and orientation. |
I won't add this, but it's handy for testing… #if ENABLED(MAX7219_DEBUG)
inline void gcode_M7219() {
if (parser.seen('I'))
for (uint8_t r = 0; r < 8; r++) Max7219_Set_Row(r, 0);
else if (parser.seenval('R')) {
const uint8_t r = parser.value_int();
Max7219_Set_Row(r, parser.byteval('V'));
}
else if (parser.seenval('C')) {
const uint8_t c = parser.value_int();
Max7219_Set_Column(c, parser.byteval('V'));
}
else if (parser.seenval('X') || parser.seenval('Y')) {
const uint8_t x = parser.byteval('X'), y = parser.byteval('Y');
if (parser.seenval('V'))
Max7219_LED_Set(x, y, parser.boolval('V'));
else
Max7219_LED_Toggle(x, y);
}
}
#endif #if ENABLED(MAX7219_DEBUG)
case 7219: gcode_M7219(); break; // M7219: Set LEDs, columns, and rows
#endif |
Whoa! That's a good idea. An M7219 command!!! I think we should add it. But what gives with all those bread board wires? You bought the pre-assembled units shown in #11033 (comment) , right? Why would you wire that up with discrete wires? Maybe it was so you could mess around with the 7 segment displays like these: https://www.ebay.com/itm/MAX7219-8-Digital-Segment-Digital-LED-Display-Tube-For-Arduino-51-AVR-STM32/201536584320?hash=item2eec843a80:g:6lAAAOSwoudW4Ss5 |
Also... Should we change STEPPER to PLANNER on the #define's too ? (not just the comments???) - #define MAX7219_DEBUG_STEPPER_QUEUE 0 // Show the current stepper queue depth on this and the next LED matrix row
+ #define MAX7219_DEBUG_STEPPER_QUEUE 0 // Show the current planner queue depth on this and the next LED matrix row |
0358514
to
500dc12
Compare
I was ready to test the rotation stuff and see if it handles my case... But sadly, this isn't merged yet.
it is very low risk. How about we merge the new code (and hopefully the M7219 gcode also)? (as soon as Travis says OK!) |
GitHub provides links to download any branch as a ZIP file. https://github.com/thinkyhead/Marlin/archive/bf1_MAX7219.zip Anyway, will merge soon… |
Here's a short video about using the Max7219 with Marlin… |
That was cool! I laughed when I saw my #define's on the screen.... Here is the OpenScad source code for my corner switch & LED debug lights. You can cut out what ever you don't want, but the mount for the LED matrix will save you some time when you decide where you want to put it on your printer. (This one clicks on the i2020 aluminum rails in the front corner of the Folger Tech i3-2020. (And... As you can see, the connector is pointed down with the LED Matrix glued into the printed plastic piece.) If you want to add debug (or reset) switches... These drop into the big holes in the part: |
I do like the spiral init pattern.... |
Adjustments made while playing around with a MAX7219 unit….
MAX7219_DEBUG_PRINTER_ALIVE
as an opportunity to re-initialize.Counterpart to #11034