MAX7219 component

A forum where Flowcode v7 user created components can be shared, discussed and reviewed.

Moderator: Benj

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

MAX7219 component

Postby mnf » Thu Sep 14, 2017 10:12 pm

So, inspired by the instructions on component creation - thought I would have a go.

My first thought was to work with an i2c LCD display based on the PCF8574A - but this was a bit daunting. So had a go at getting a MAX7219 based 8 character LED to work - with the ultimate aim of creating a component that can work with the MAX7219, MAX7221 and both 4/8 digit or 8x8 LED grid, singly or chained. (Maybe a touch ambitious?)

So waded in (and failed) using CAL_SPI and so started using SPI Master and soon got the display up and running - code attached.

max7219.fcfx
(23.2 KiB) Downloaded 283 times


- still a way to go to reach 'component' status, but at least the LED is working! (this connected to an Arduino on digital 5, 6 and 7 (data, CS and CLK respectively)

Still some questions:

1) Creating an image for the component - how to create an LED display (like the 8 digit component). Preferably with a variable number of digits to allow for different configurations (and allow for LED Matrix etc). Better yet - how to 'borrow' an existing image.
2) The CAL SPI component's slave transmit (and probably receive) are not implemented - so give a compiler error. They probably should have a stub definition that gives a more meaningful warning? (Not implemented on AVR?)
3) The code currently hard codes CS as pin 6 digital (v. bad) - what is the correct ('Flowcodian') way to make this a variable pin. I tried setting a Object variable to PORTx.y but didn't get further.. Using C would be an option. Note that the MAX7219 doesn't need this to be pulled low before a write but MAX7221 does (?) - I only have a 7219 to test.
4) How to get working with CAL SPI and make / hide relevant pins. There doesn't seem to be much documentation for these CAL low level interfaces.

As an aside: The pop up boxes for 'unconnected pin', 'save file', ' start programming' (etc.) and the need to close the compiler dialog are annoying (to put it mildly) - it would be very nice if they went away in v8 (or maybe just have a 'compiler' dialog that is always open - which could also display messages such as 'flowcode has been compiled to C' without the fancy 'fade' dialog (and the corresponding need to close it!))

So - next steps..
Move to using an array to allow multiple chained MAX72xx chips.
Allow the user to choose the MAX721xx decode mode.
The Arduino library keeps a 64 byte buffer of the current LED state - would this be useful (as default or an option) for when RAM usage isn't critical.
Allow Hex output and letters as per Arduino lib (really just need to add values to the LUT)

Thanks for any suggestions etc (or info on a current library that does similar) - before the final push to make this something more useful!

Martin
These users thanked the author mnf for the post (total 3):
Steve (Mon Sep 18, 2017 11:19 am) • Benj (Wed Jan 03, 2018 4:34 pm) • medelec35 (Mon Nov 12, 2018 10:05 am)
Rating: 15%
 

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 92 times
Been thanked: 182 times
Contact:

Re: MAX7219 component

Postby johnsondav » Fri Sep 15, 2017 4:01 pm

Hi Martin

I have downloaded your max7219 component you have been working on. These are the points I would suggest need your consideration:
- what will be shown on the dashboard for the final components design/appearance
- functional control of data flow for final component

1. Flowcode shows ALL connections to the projects MCU to any connected external components, not the connections within the external component itself other than the SPI port or any other communication port used.
Therefore, I would expect the SPI port connections would be the only connections available for connecting to the projects MCU when your component is added to the users project. The external component is another devices which has all the necessary connections to it, to make the LED matrix display work. What this means is, there would be no way of showing how the max7219 is connected to the LED matrix display for each character on a users project using the finished component. Your finished component will be using the communication port connections to control its functionality i.e. its SPI port. This leaves the frustrating aspect of simulation of the LED matrix! You may be able to get round this by using one of the available simulation components as shown below, not perfect, but could be used to show what has been sent to the LED matrix SPI display. These are configured/coded using the simulation icons in FC7. By the way, these simulation icons could have been called by another name as they are used to input code which is not downloaded to the MCU.

Panel Console Viewer.jpg
Panel Console Viewer.jpg (95.7 KiB) Viewed 10201 times


2. When adding some functionality to the comm. port for data flow, I would have a look at the work done by Ben for the 'LCD Tutorial project' page 8. This shows how to control different types of data using a variable as you have described.

To sum up, your component would be a great help, enabling any project to use just a few of the MCU connections to control/output a larger LED Matrix display to be used. If you need any help with the cal_spi, I would be pleased to help you.

Regards
Dave
These users thanked the author johnsondav for the post (total 3):
mnf (Fri Sep 15, 2017 7:07 pm) • Benj (Wed Jan 03, 2018 4:35 pm) • medelec35 (Mon Nov 12, 2018 10:05 am)
Rating: 15%
 

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Sat Sep 16, 2017 9:01 am

Hi Dave,

Thanks for the tips. I haven't thought a great deal about the image yet (other than notes above) - one idea I had was to use a text panel and display the expected digits as a string. I haven't used the simulation feature very much - other than as a debugger, looking at variables etc (and never the 2d/3d panel) . I'd like a go with oscilloscope feature (couldn't run to simulation pack :-( ) I'm not sure how well it would represent 'real life' action on the MCU?

Next task is to change to an array based solution to allow chained displays.

Some more questions:

With the cal spi - how should I remove the MISO pin - ie there is no input but marking the MISO pin as unconnected gives a compiler error (I did tick the option to allow this in preferences) - I haven't found a way round this other than connecting to an unused pin (which I'd rather avoid) or the same pin as MOSI (which doesn't feel right either)

I have wondered about going the bit-bang route (it's a fairly simple protocol) - but still haven't worked out how to make output pins a variable?
I can do $PORTB.5 = 1 but not quite there!
I've just discovered the 'panel - add variable' feature - so after adding a 'digital pin' - how do I use this value to set the pin high/low?

Is there a (user) way to create components in C? - with low level stuff like this there is almost a one to one correspondence between flowcode steps and lines of code - and this feature would surely make converting existing libraries much easier (I might be much more familiar with C & C++)

The LUT required is currently global - I assume this will become hidden when I export as a component?



Martin

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 92 times
Been thanked: 182 times
Contact:

Re: MAX7219 component

Postby johnsondav » Sat Sep 16, 2017 12:50 pm

Hi Martin

I hope I can shed some light on your concerns.

1. The simulation icon when used to build an exported component is an important step. You are seeing what I first thought when I started building components. This is what your component looks like so far when exported. I have set your component to 'Inherit' macros from the base cal_spi component. It'll illustrate what I mean.
Panel_SPI component.jpg
Panel_SPI component.jpg (40.67 KiB) Viewed 10177 times

Everything is hidden and wrapped up in the exported component in a GUI image; connection pins; functional logic - everything.

So what you see when finished is very different when looking at your component project before it is exported.

2. The connections will only be present if the simulation icon is used to bring those connections up from the base cal_spi component into your component. You will have the option for FC7 to either 'bit-bang' for you or use the 'Channel' hardware. All decided by those simulation icon's which are used to do the coding. Its rather like the 'C' coding you mention.

3. The only connect your component has at this very early stage is - port D.7 - nothing else. This is because there is no EV_Property macro present for your component to bring those connections from the CAL abstraction layer into your component.

I would suggest you include the EV_Macro to your project (it will probably be exactly the same as the one shown in the tutorial) and remove the master SPI component. Replace this with the 'Flasher' RX/TX panel simulation image and you will see what I mean. hopefully.

I have included the EV_Property (just completed it after posting) macro with project for you to consider. Also, I have linked the CS pin to where you need to control data flow within the send macro, again for you to consider. Now, when you click anywhere within the panel (not onto a component) you will see which connections are available when the component is exported. Now, from the channel selection, you will have the option to use 'Software' or bit-bang rather than hardware.

max7219.fcfx
(28.38 KiB) Downloaded 197 times


Hope this helps

Regards
Dave
These users thanked the author johnsondav for the post (total 2):
Steve (Mon Sep 18, 2017 10:52 am) • medelec35 (Wed Sep 20, 2017 5:56 pm)
Rating: 10%
 

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Sun Sep 17, 2017 4:53 pm

Thanks - yes I'd approached the problem from the other end - get the software to work and then 'export'.... re-read the docs (I'd read the flowcode docs on the startup page of FC7) - yours seems rather more detailed! I'll have another play tonight/tomorrow and hopefully progress a little further.


A silly question (probably) - in step 4 - would selecting expose on cal_uart's Channel - which shows it in panel's properties - mimic step 4, 5 & 6?

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Wed Sep 20, 2017 4:17 pm

Version 2! (or 0.002)

Almost working with the CAL_SPI component - the LED display's a repeatable stream of characters. They are just not the right ones :-( Clear sets all the digits to 0 except digit 7 - which is blank.. I've arranged to borrow an oscilloscope/logic analyser so will take a peek at what is happening at a 'pin' level when it arrives. (I'm optimistic - but have never used one before - and assume it will let me do this)

As an aside - Flowcode has become rather flakey whilst editing this - some long pauses where the properties windows outline goes to a thicker black line and things grind to a halt for ~20-30 secs Then usually recovers and compiles ok (and occasionally just closes). I'm running a fairly high spec pc (i7, 24GB) and saving to an SSD so not sure where the bottleneck is occurring. Will experiment with saving to a RAM disk - and see if this improves things?

CAL_spi still requires MISO to be set to a pin to allow compilation. Will also experiment using a bit bang approach when I have more time..

max7219 (1).fcfx
(25.2 KiB) Downloaded 161 times
These users thanked the author mnf for the post:
medelec35 (Mon Nov 12, 2018 10:06 am)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Wed Sep 20, 2017 4:35 pm

Powering off (the Arduino) worked - it's now displaying the right numbers in the right places. Hurrah!
These users thanked the author mnf for the post:
Benj (Wed Sep 20, 2017 5:28 pm)
Rating: 5%
 

johnsondav
Posts: 186
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 92 times
Been thanked: 182 times
Contact:

Re: MAX7219 component

Postby johnsondav » Wed Sep 20, 2017 7:45 pm

Hi Martin

Looking good. I have tried to compile a project using the component generated by your component project. It compiles ok to a PIC18F4550.

Looking at the component configuration, there are some details that require some entries (probably explains the strange behaviour). Have a look at the macros tab in the component configuration:
MAX7819_SPIA.jpg
MAX7819_SPIA.jpg (184.97 KiB) Viewed 10076 times

All of the macros are set to - 'Hidden'. These need to be setup to which ones need to be made available.

Also, consider setting the component placement under the - 'Setup - Advanced TAB'. This will help load your component to the correct location when placed into a project. This is what I get when settings are configured to 'Auto Centre and Lock aspect ratio':
MAX7819_SPIB.jpg
MAX7819_SPIB.jpg (83.48 KiB) Viewed 10076 times


I am looking at that the 'Main' macro. Q. Should these macros be called at all from here - Setintensity; Clear and Shutdown. If I was putting this component into a project when exported, I would probably expect the user to 'CALL' these functions as and when required? Just a thought, as I am wondering if the display digit loop would be run at all when one of the other macro's are called by the user. I am not familiar with this device so I am not sure what's happening.

Regards
Dave

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Wed Sep 20, 2017 9:02 pm

Hi Dave,

Yes - main is just a demo at present - I'm still in the get the thing to work stage......

So now:

max7219 multi.fcfx
(28.75 KiB) Downloaded 171 times


Allows multiple Max7219 chips linked.

So after much fiddling (eventually I swapped my LED boards around - seemed one faulty and not passing signals through) - got two linked boards working.

Still many questions:

The max7219 datasheet implies that CS should be pulled low before and then set high after every 16 bits of transfer. Doing this however, both displays show the same data. Pulling it low before transferring a block of data (up to 16 bytes) - and back to high works ok.

My setup now works correctly for display connected to arduino (device = 0) and correctly for digits 0..6 of device =1. Digit 7 displays a different digit to that sent - although single stepping through the code shows correct value send (in simulation)

I only have the two Max7219 boards to play with (one matrix and one 8 digit) - if anyone has more and could test - then please do.

The datasheet also states that data is transferred on rising edge of clock - but needs to be set to trailing edge for the cal_spi component for it to work?

Martin
Next is a buffer to allow individual 'pixels' to be written to the matrix display - then possibly such tricks as 'rotate' and 'scroll' - is there a way to allocate memory dynamically in Flowcode or do I just go with a 64 byte array?

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Sun Sep 24, 2017 11:05 am

Tested with a 4 x matrix display (actually 3.75 matrix - it got badly squished in the post) - works well. The set I received had left and right swapped on each matrix - so I added a 'direction' property to the panel properties. I added a font - 'space' to 'Z' although X,Y, and Z are corrupt. It is licensed as public domain and also has lower case letters which could be added (see 1). The demonstration now displays this.

More questions:

1) Should the font be pulled to a separate component? It takes up a fair bit of memory and if it's not needed? Can I make the LED component access another component easily. (Multiple fonts also becomes possibility)

2) Currently the component only allows a linear configuration - but it would be good to allow others (eg 16 x 32)

3) Scrolling works - though different configurations would need to be supported - anyone any ideas / requests.

4) I'll add a character 'shift' in routine to allow scrolling text - again any ideas what would be good? Current thought is to have an 8 byte buffer passed by the user? Alternatively simply passing a 'column' variable and pulling out the bit pattern may well be fast enough?

5) There is a large demo routine which uses lots of global variables - I had these in main and cut and pasted but couldn't be bothered to change them to locals. I see the demo being moved to a separate sketch soon.

6) Scroll left, right etc are badly named - it depends on the display orientation - any suggestions for better naming ideas?

Martin

max7219 multi.fcfx
(52.8 KiB) Downloaded 142 times

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Sun Sep 24, 2017 8:47 pm

This is it - the final version - at least until the replacement part arrives from Amazon.

So this now has Text scrolling, flashing and the full character set. So assuming feature creep doesn't get the better of me I'll start thinking about making it into a component (or two).

max7219 multi.fcfx
(62.33 KiB) Downloaded 139 times


Note that this has a couple of 'bugs' (now documented so features!) - The scrollstr macro has an extra shift at the end which means the display winds up one pixel off...

The character set includes the 31 control characters at the start - which I should have deleted to save space - the scrollStr macro was using the absolute character value - so worked correctly. Pen was using char - 32 - so was returning the wrong character - this doesn't really show as a problem in the demo apart from the delay at the end of the 4 x character set display. This led to the slight pause as the 31 blank characters displayed.


A question - as mentioned before the cal spi component requires a MISO pin to be connected to allow compilation (Master_tx_byte transmits and then receives - although the Max72xx doesn't reply any data). Slave_tx_byte isn't implemented and leads to a compilation failure. Is there a fix for this (Leigh/Ben) ??

Another minor bug - adding a string parameter as to a macro and unticking the 'create local copy' correctly passes the string by reference rather than by value. However in the macro details the string still shows as str[20] - and deleting the [20] doesn't work. The C generated is correct

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Fri Sep 29, 2017 10:57 pm

One last update.

Tested and working with an 8 matrix setup (ie 64 x 8 pixel). The scrolling text looks particularly good (if I say so myself).

Rewrote and some tidying to allow more data to be transferred at a time (ie 8 bytes rather than 1 byte and 7 noops) and treating the display as a single entity - so now SetIntensity (for example) sets the entire display rather than for a single matrix.

I found that connecting two displays (32 x 8 each) by 'poking' the in pins into the out holes works well - but using wires gives some display corruption. So either a timing issue - or more likely a 'noise' issue. I've seen mention of connecting a capacitor - any suggestions welcome...

Any other suggestions for ideas (eg character to pixel address rather than to device address)?

Have had very little time to play with this week - and the 8 digit display now needs some work.

max7219 multi 2.fcfx
(65.2 KiB) Downloaded 128 times


I've also tested this with 12 x matrix displays - the buffers needed resizing accordingly and I tweaked the NumDevices define in properties to allow more displays. All the demo routines run correctly (albeit slower - I modified the scrolling string demo to have a delay of 0ms). I noticed on ebay a 16 matrix (4 x 4) display - and I suspect this would work ok too - although see previous comments about allowing different configurations of display.
It may be better to allocate the buffers using 'new' in InitialiseLED to avoid using RAM unnecessarily (defining a buffer as buffer[NumDevices*8] doesn't work). This would have implications on simulating the display?
There is some disagreement over how many displays can be chained (8 (3 bit address))- but power and noise issues apart - the displays seem to pass on 'overflow' data to allow any length of chain
Last edited by mnf on Sun Oct 01, 2017 5:58 pm, edited 1 time in total.
These users thanked the author mnf for the post:
jgu1 (Sat Sep 30, 2017 5:04 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Sat Sep 30, 2017 6:00 pm

Oh dear - another day, another bug...

Finally experimented with exporting this as a component. This could be imported, but refused to compile with 3 macros undefined (the 3 I attempted to call from a test 'main')

Some fiddling to try to fix this and I got to:

There are errors in the settings that will prevent the component being exported.

The interface macro DisplayDigit points to an incorrect simulation macro


This is generated on selecting Component Configuration - so I can't actually edit this!

Any suggestions?

Martin

User avatar
LeighM
Matrix Staff
Posts: 2009
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 480 times
Been thanked: 688 times
Contact:

Re: MAX7219 component

Postby LeighM » Mon Oct 02, 2017 8:45 am

Hi,
Please see this post regarding a work around fix ...
viewtopic.php?f=63&t=19318
These users thanked the author LeighM for the post:
mnf (Mon Oct 02, 2017 9:40 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Mon Oct 02, 2017 10:00 pm

Thanks Leigh,

I was able to get this exported and 'almost' working as a component.

Problems:

1) EV_PROPERTY copies settings from panel properties to the cal_spi component properties - except for PR_SCALE (Prsescale). When running as a component the display is very slow (Fosc/128 ??) - single stepping looks ok when going through EV_PROPERTY (Note I added CopyTo and CopyFrom macros to make the process easier - though my original stepped approach didn't work either) - but it doesn't copy across - it givers an empty box in the CAL_SPI properties.

2) The Max7219 properties set in the test program don't seem to be correct = the demo program just uses 3 x matrix displays (instead of the 4 selected), and this needs to be set to 5 to use 4 devices?

3) What is the difference between a Downloadable and an Embedded macro?

4) How do I get the 'console' to display - I had a play with one of the injector demo videos in the wiki - but couldn't get the HID injector to work (got a file displaying to an LCD component in simulation) - but noticed that I can't get the console to display (yes I tried View - Console
and resetting layout to default - but remains stubbornly unticked and unseen)

Still it's progress !!

Note that there still isn't really any 'simulation' to this component - I see the idea - add some simulation macros but not really sure how to proceed with that.

max7219 multi 2.fcfx
(72.88 KiB) Downloaded 123 times


test.fcfx
(8.16 KiB) Downloaded 123 times

User avatar
LeighM
Matrix Staff
Posts: 2009
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 480 times
Been thanked: 688 times
Contact:

Re: MAX7219 component

Postby LeighM » Tue Oct 03, 2017 12:18 pm

Property copying is notoriously difficult.
So I suggest that you remove the Ev_Property code and "Expose" the SPI CAL properties directly into your component instead.
To do this, simple click on the SPI property (such as the Prescaler) and then select "Expose".
The (SPI) property will now be visible on the component property list.

A Downloadable macro is a Flowcode macro that generates code that is compiled into the target.
An Embedded macro is a Flowcode macro that does not have any code itself, but is simply used as a wrapper to a C code function that exists elsewhere, such as in an "included" C file, or C code in the Project Options -> Supplementary Code

Not sure if I understand the question correctly, but you can create a window in the console by using the console functions of the "Simulation" icon...
console.jpg
console.jpg (44.18 KiB) Viewed 9836 times
These users thanked the author LeighM for the post:
jgu1 (Sun Dec 17, 2017 8:59 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Wed Oct 04, 2017 3:39 pm

Thanks Leigh,

Changed to exporting the CAL_SPI properties.
Still a couple more questions:

1) Cal_Spi still expects MISO to be connected (In the base component MISO is connected to Port D0 - will this cause problems for different targets?). Using Slave TX doesn't compile (and Master TX expects a reply). Is there a way around this. So with '2' fixed the component seems to work AOK. Has anyone out there tried it. Any suggestions / questions? Note that as it stands it supports up to 8 matrix displays (if I get an answer to '3' - this could be more, I've tested it with 12 and it works ok). There is very little error checking in the code - how much should there be? Extra checks would add time & size. There isn't any simulation part to this at present - open to suggestions?

2) When compiled as is everything works well. When used as a component the Number of devices (NumDevices) needs to be set to the number of devices + 1 (ie using 4 only displays on 3 matrix displays - whereas 5 works for 4) - the C generated looks sensible - so I'm at a bit of a loss to explain why this is? I tried changing to an unsigned int instead of a fixed list with a generated define - but no joy. - Fixed this I needed to set SwapX for my display (I guess I just assumed the value would be the same as in the base component - and didn't actually check :-) )

3) What is the correct method to dynamically allocated the two memory buffers used. Do I just use a C block and new - is so what variable definitions do I need for buffer and display to keep everything sweet?

4) Console - in video for HID Injector demo - there is a console displayed showing HID input UART output etc - http://www.matrixtsl.com/wikiv7/index.p ... _Interface)_(Comms) - in the demo video nothing seems to be added to get this. I'll play some more....

Max7219Matrix.fcpx
(5.28 KiB) Downloaded 147 times
These users thanked the author mnf for the post:
jgu1 (Sun Dec 17, 2017 8:59 pm)
Rating: 5%
 

jgu1
Posts: 1170
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1095 times
Been thanked: 291 times
Contact:

Re: MAX7219 component

Postby jgu1 » Sun Dec 17, 2017 8:58 pm

Hi mnf!

I have first seen your component now. Look forvard t test it. :D

Br Jorgen

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Mon Dec 18, 2017 3:32 pm

Let us know how you get on or if you need any help with it.

Martin

jgu1
Posts: 1170
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1095 times
Been thanked: 291 times
Contact:

Re: MAX7219 component

Postby jgu1 » Sat Dec 30, 2017 9:38 pm

Hi Martin!

Now I have 4 of these display´s. : https://www.ebay.com/itm/MAX7219-8x8-LE ... b76as5cfLw

I managed to get it work with your testprogram, very nice :D the text scroll fine, and I have tryed to change the text. I have some question hope you can help:

1. Is it possible to change the orientation. Because the place of the chip on the PCB, it is not possible to place the display´s side by side and then scroll the text. (hope you understand what I mean.

2. Would you be so kind to give an examble how I place letter/digit in each display, please, :wink: I have tryed.

3. I can´t find anything in the help/wiki menu which describe the funktion Macro. wil you please give a short describtion of these parameter.

Hope it ok I ask..

Thank´s in advance.
Attachments
Macro.PNG
Macro.PNG (20.72 KiB) Viewed 8721 times

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Sun Dec 31, 2017 9:36 pm

Hi,

Glad that you managed to get things to work.

A few of the macros supported (at present) are:

Shutdown - arg is powerOff. I think this badly named (was taken from the Arduino library - but no excuse) - I think Power(bool on) would be clearer.
InitialiseLED call clears the display and sets the scan limit etc to sensible values and then turns off the display... The user turns on the display with Shutdown(false) to turn on the display. Data can be written with the display off - and it could be useful to turn it off (to save power) depending on application?

The properties have a swapX and swapY value - this however affects the whole display - what orientation(s) do you have. It would be possible to change this to an array with the orientation of each individual (8x8) section. Perhaps a value of 0..3 (for no rotation through to 270degrees)
I also wondered about allowing other layouts (eg 2 x 4 displays) - but time pressure meant I moved on to other things.. Post Christmas I'll have some more time (I hope)

Pen (dreadful name - and all my fault here) - allows a character to be written to any 8x8 display (device is 0 to 1-number of displays) Demo(5) uses it display the full character set.

Plot allows a single led to be set - it treats the display as a whole (ie 0..31 0..7 for a 4 x8x8 display)

Scroll scrolls the display by one 'pixel' in any direction (has a tooltip)

ScrollStr - scrolls in a string (passed as arg must have 0 termination) In theory direction should allow left or right (I only ever tested one way - my bad) - the delay just slows things down by adding a delay after each column is displayed.

Invert - flashes the display by inverting it (note that setting the number of flashes to an odd number will leave the display inverted)

SetIntensity - sets the brightness (0..15)

Hope that helps - but any questions / ideas for improvement then please don't hesitate to ask.

Martin

As an aside: I also intended to allow use of 4 character 7 segment (numeric) displays - however they are pretty poorly served (DisplayDigit). It would be pretty easy to extend things to allow scrolling and limited character output for example (eg ABCDEF etc as well as digits) if this would be useful? I just found the 8x8 grids more flexible (and fun!) I managed to get 12 8x8 displays (all I had to test) working smoothly from an Arduino which created an impressive scrolling display! (The component only supports up to 8 8x8 displays as posted)
These users thanked the author mnf for the post:
jgu1 (Sun Dec 31, 2017 11:24 pm)
Rating: 5%
 

jgu1
Posts: 1170
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1095 times
Been thanked: 291 times
Contact:

Re: MAX7219 component

Postby jgu1 » Sun Dec 31, 2017 10:57 pm

Hi Martin!

Thank you very much for explantion. Great job you have done with this component.
But I dont quit understand how to set the orientation, is it possible. When I try to change these parameter I only can make them inverted. I would like to be able to turn the digit or letter clockwice. I need to place the pcb´s like the picture. If I do that your sign is laying down.

You wrote: Perhaps a value of 0..3 (for no rotation through to 270degrees) Exactly. :D :D

I will do some more exercises.

It would really be nice if we also could be able to control the max 7219 with seven segment display to. :D

Thanks in advance an happy newyear.
Attachments
Max.PNG
Max.PNG (711 KiB) Viewed 8685 times
These users thanked the author jgu1 for the post:
Benj (Wed Jan 03, 2018 4:35 pm)
Rating: 5%
 

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Mon Jan 01, 2018 1:07 pm

Hi Jorgen,

Not sure I've quite got my head around the bit twiddling needed to do scrolls etc - but here is a simple character rotation to try.

It adds a PenRot and PlotRotation - I've only tested with a single display (I'll wire some more up later!) - just to check that this is the sort of thing that is needed.

max7219 rotate.fcfx
(64.82 KiB) Downloaded 120 times


It is a lot less efficient than the Pen routine - which handled a complete byte at once - however I'm not sure this would be too much of a problem, and it also lends itself better to 'pixel' placements of characters (eg PenAt(12,2,'0'))

I've fixed the demo so that it just runs through the character set in each rotation.

That's some very neat hardware you have there - where did you get (how did you make) the baseplate?

Martin
These users thanked the author mnf for the post:
jgu1 (Mon Jan 01, 2018 2:58 pm)
Rating: 5%
 

jgu1
Posts: 1170
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1095 times
Been thanked: 291 times
Contact:

Re: MAX7219 component

Postby jgu1 » Mon Jan 01, 2018 2:17 pm

Hi Martin!

The hardware is a picture from Utube. It is only to demonstrate how I want them placed side by side, but anyway, nice :D

I tryed to run your program, but nothing happen in display, all led off. And, I am not able to look trough your program, I am not so hardcore (yet)

Is it something you will add in the component?

Thank´s for care.

Jorgen.

mnf
Valued Contributor
Valued Contributor
Posts: 695
Joined: Wed May 31, 2017 11:57 am
Has thanked: 63 times
Been thanked: 400 times
Contact:

Re: MAX7219 component

Postby mnf » Mon Jan 01, 2018 7:59 pm

Okay.

Here as a component...

Max7219MatrixRot.fcpx
(5.57 KiB) Downloaded 120 times

Note that this adds the PenRot and PlotRotate macros (naming isn't good!).

A test program:

test.fcfx
(23.55 KiB) Downloaded 144 times


This demonstrates most of the MAX7219 8x8 display functions and is hard-coded to a 4 (8x8) segment display - to change this change NumDevices in Max7219 properties and also the global constant NumDevices.

I've tested with a 4 segment display and all seems well....

The scroll routine with 0 delay is really too fast on a 4 segment display !

The final part of the demo displays the whole character set one character at a time at each rotation on the four displays (ie display 0 shows rotation 0 through to display 3 with rotation 3): Edit - changed to show each character on each display in each orientation....

The approach taken here rotates the characters as displayed - but this doesn't allow scrolling to work on rotated displays - I'd be tempted to use the current approach but then rotate the buffer into a second buffer if there is any demand (please no!)) before pumping out to the spi component..

I also never got any ideas on how to cope with the unconnected MISO pin (which the cal_spi component insists must be connected) - perhaps I should just export and let user choose their 'dummy' pin... Has anyone actually tried this on ARM or PIC?
These users thanked the author mnf for the post (total 2):
jgu1 (Tue Jan 02, 2018 7:37 pm) • Benj (Wed Jan 03, 2018 4:35 pm)
Rating: 10%