Page 5 of 5

Re: Martin Fisher great component Max7219_v2 a question Solved.

Posted: Wed Mar 26, 2025 10:18 am
by Viktor74
Yes, I can, here's a simple example where I'm trying to make the caption move on an interrupt.

Re: Martin Fisher great component Max7219_v2 a question Solved.

Posted: Wed Mar 26, 2025 3:20 pm
by Viktor74
Hi Martin,
I have a tablet like this for the Ukrainian Cyrillic alphabet, partially selecting only Ukrainian letters from the Cyrillic alphabet and pulling them out of the general table in pieces. You can leave out the sign symbols and only add letters, if possible. Thank you very much.

Viktor

Re: Martin Fisher great component Max7219_v2 a question Solved.

Posted: Wed Mar 26, 2025 4:41 pm
by mnfisher
Hi Viktor,

In your interrupt example - no that won't work - but it's interesting that it 'works' (ie displays the string) okay.

So - the code you have displays the whole string (starting from display 0) - then scrolls it by two pixels - and repeats (every interrupt the same). Note - that doing something like this in an interrupt handler is a slightly 'grey area' - ISRs need to be as short (read fast) as possible - and 'blocking' the MCU for prolonged periods might cause issues elsewhere... So for example - a 16 Max7219 display (the maximum currently allowed) - might lock the MCU whereas a single display might not.. It might also affect things 'subtly' - timers incorrect etc.
What you need to do - is scroll the display left and then draw in a new column of data at the right of the display (and this changes depending on how many scrolls have taken place. This is what the ScrollStr macros do - but they display the full string before returning.
DispTextLine - does what's needed but for a row rather than a column - and it would certainly possible to do a DispTextCol to handle this...

The Macros (posted some times ago - and probably lost in the mists)

ClearDisplays() - Does what it says on the tin..
Demo - Call with .n = 0..10 to a demo a function.
DispTextLine - draws a row (1 pixel high) of a line of text to the display - used for Slew
DIsplayDigit - for the MAx7219 numeric displays (and not sure this actually works - although it used to)
DisplayStr - Outputs a string (or part of) to the display
FadeIn - fades in a string
InitialiseLED - Initialises - default is off afterwards (I'd probably change this to Initialise(on) - and pass the desired state - though this might break things for folk)
Invert - Swaps on/off for all pixels .n times
Pen - Displays a character to one display (probably redundant)
PenRot - Displays a character with rotation
Plot - plot x, y point
PlotRotate - plot x, y allowing for display rotation
Scroll - scroll a string onto display - returns when full string has been displayed.
ScrollStr3 - scrolls a string for a display where the individual displays were rotated by 90degrees
SetIntensity - sets the brightness
Shutdown - power off (or on)
Slew - Slides a string onto the display a pixel row at a times...

Properties:

Channel - SPI Channel
Prescale - clock scaler. The displays I have work AOK at 4MHz (FOsc/4 on Arduino) - but may vary depending on connection quality etc
CLK, MOSI, MISO, CS - SPI Pins (Miso isn't used - but I couldn't find a way to have it 'unconnected' and use SPI)
Devices - number of Max7219 connected (1..16 - though this could be increased - each display uses 8 bytes)
SwapX, SwapY - some displays (I have never encountered one) apparently have the orientation of x and/or y reversed.
Rotated - if the display is rotated by 90degrees

Martin

Re: Martin Fisher great component Max7219_v2 a question Solved.

Posted: Wed Mar 26, 2025 4:53 pm
by mnfisher
With the Cyrillic characters - the easiest approach is to just increase the size of the lookup table - then just pass the relevant values in the string. This should work as is - at the expense of flash space.

I can't now remember which orientation the character's data needs to be in (top->bottom or vice versa) - but if you want to do 'one' with an obvious 'right way' up - I'll experiment.
If I get time - I'll try DrawTextCol too....

Martin

Re: Martin Fisher great component Max7219_v2 a question Solved.

Posted: Thu Mar 27, 2025 10:03 pm
by mnfisher
I did a DispTextCol (thought it could also be used for a neat 'wipe' display).
And as a test - an interrupt scroll...

Here it just displays the alphabet (and repeats) across 4 displays. It uses 'pos' as the current column of the text ('text') to be displayed - as the string is 26 characters this ranges from 0..207 (26 * 8 - 1)

I used timer1 - and set an interrupt rate of ~30Hz (60Hz is too fast for my eyes at least). The code is simple as possible - init the display, set the interrupt handler then do nothing...
The interrupt scrolls the display - draws in the new column at the right of the display and updates pos... Note that scroll refreshes the display data - but plot (and DispTextCol) does not - otherwise the refresh would occur twice each interrupt. It would take a lot more work to do this without this shortcut....

The effect - a nice smooth scroll....

Martin

Re: Martin Fisher great component Max7219_v2 a question Solved.

Posted: Fri Mar 28, 2025 9:22 am
by mnfisher
Note - I don't advocate using an interrupt like this... It offers up new and subtle ways for your program to stop working / break - but here, where the program is doing nothing except 'sleep' - all should be well!

Martin

Re: Martin Fisher great component Max7219_v2 a question Solved.

Posted: Wed Apr 02, 2025 7:49 am
by Viktor74
Hi Martin
Everything works perfectly as I needed it to, thank you very much.