MAX7219 With 7-segment (+dp) display
Posted: Mon Nov 10, 2025 9:31 pm
There is probably something similar in the FC component catalogue... For a little fun - I did a MAX7219 component - I have an eight digit display - but the number of digits can be changed - although the modules can be linked I haven't allowed for that here - max number of digits is 8.
It allows digits 0..9, A,b,C,d,E,F,H,L,o,P,U,_,-, ' ' (space) and decimal point(s) - output can be displayed left or right justified (also a property - my module has digit '1' at the right and '8' at the left)
You can also adjust brightness and put the display into a sleep mode (although the current draw doesn't change much)
I've included the source - if anyone would like to add features (simulation - there is a minimum (ie none)) or centre justification (for example)
Macros:
Initialise(brightness)
DisplayString(string, justify)
DisplayInt(uint, justify) (a version allowing a signed int might be nice?)
DisplayHex(uint, justify)
DisplayFloat(fp_number, justify)
SetBrightness(0..15)
Power(on = true)
It uses SPI to communicate with the module - and needs a (dummy) MISO to compile.
On a PIC18F46K80 with 20MHz crystal - SPI in software mode at FOsc/4 worked nicely - I couldn't test hardware mode (on my homemade dev board) - I only added a few header pins.
Note that the MAX7219 has a (basic) character set built in - but I use my own lookup here to allow the extra characters (other than 0..9)
Tested with v10 and v11.
Here captured displaying 1.2345 (right justified)
Eeew - where's a keyboard sanitiser when you need one!
Martin
It allows digits 0..9, A,b,C,d,E,F,H,L,o,P,U,_,-, ' ' (space) and decimal point(s) - output can be displayed left or right justified (also a property - my module has digit '1' at the right and '8' at the left)
You can also adjust brightness and put the display into a sleep mode (although the current draw doesn't change much)
I've included the source - if anyone would like to add features (simulation - there is a minimum (ie none)) or centre justification (for example)
Macros:
Initialise(brightness)
DisplayString(string, justify)
DisplayInt(uint, justify) (a version allowing a signed int might be nice?)
DisplayHex(uint, justify)
DisplayFloat(fp_number, justify)
SetBrightness(0..15)
Power(on = true)
It uses SPI to communicate with the module - and needs a (dummy) MISO to compile.
On a PIC18F46K80 with 20MHz crystal - SPI in software mode at FOsc/4 worked nicely - I couldn't test hardware mode (on my homemade dev board) - I only added a few header pins.
Note that the MAX7219 has a (basic) character set built in - but I use my own lookup here to allow the extra characters (other than 0..9)
Tested with v10 and v11.
Here captured displaying 1.2345 (right justified)
Eeew - where's a keyboard sanitiser when you need one!
Martin