2 x fields displayed on same MAX7219?

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Post Reply
Message
Author
zogster
Posts: 6
Joined: Sun Dec 11, 2022 10:08 pm

2 x fields displayed on same MAX7219?

#1 Post by zogster »

Is there a way to make an 8-character 7-segment MAX7219 module show two different values simultaneously, ie. by having one value displayed on characters 1-3, and the other on 6-8 while leaving 4 and 5 blank?

As in: 123xx678

(The idea is building a couple of displays that use masking to have a single MAX7219 double up, as in two windows onto a single 8-character display, and use only the 8-character displays rather than a bunch of different modules)

thanks in advance for any help

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: 2 x fields displayed on same MAX7219?

#2 Post by SimPassion »

zogster wrote: Wed Feb 01, 2023 5:32 pm Is there a way to make an 8-character 7-segment MAX7219 module show two different values simultaneously, ie. by having one value displayed on characters 1-3, and the other on 6-8 while leaving 4 and 5 blank?

As in: 123xx678

(The idea is building a couple of displays that use masking to have a single MAX7219 double up, as in two windows onto a single 8-character display, and use only the 8-character displays rather than a bunch of different modules)

thanks in advance for any help
No issue for this, we have to construct the whole string to be displayed, using different variable and 'string.format' statement, then set the whole string to the display at once, this is what I'm performing in the Z_2D_XP MCP

see in this function :

Code: Select all

function hw_chr_display0()		-- CRS A & SPD
	str_chr_display0 = gbl_mcp_digits:sub(1,3)		-- 3 leds digits
	-- SPEED or MACH
	if gbl_speed_mode == 1 then
		-- 6 digits		-- 4 chars --> 3 leds digits			= 3 leds digits + 3 previous leds digits	= 6 leds digits
		str_chr_display0 = str_chr_display0..gbl_mcp_digits:sub(4,7)
	else
		-- 6 didgits	-- 2 blanks + 1 digit + 2 leds digits	= 5 leds digits + 3 previous leds digits	= 8 leds digits
		str_chr_display0 = str_chr_display0.." "..gbl_mcp_digits:sub(8,11)
	end
end

function hw_chr_display1()		-- HDG & ALT
	str_chr_display1 = gbl_mcp_digits:sub(12,19)		-- 8 leds digits
end

function hw_chr_display2()		-- VSI & CRS B
	str_chr_display2 = gbl_mcp_digits:sub(20,27)		-- 8 leds digits
end

function hw_chr_display3()		-- CRS B
	str_chr_display3 = gbl_mcp_digits:sub(25,27)		-- 8 leds digits
end

Next the MAX7219 set :

Code: Select all

	hw_chr_display_set_text(display_chr_id, 0, 0, str_chr_display0)
from here :

Code: Select all

--==================================================
--		SET Hardware 7-Segment Displays LEDs
--==================================================

function hw_chr_display()	--	MAX7219 mode from AM internal handling is able to displays these digits : "AbcdEFHLP0123456789 .-_"

	--					CRS1		MACH		SPD/ALERT	IAS		HEADING			ALTITUDE		VERT/SPEED		CRS2
	--					  3		  4		  (1*)		 3		   3			5			5			  3		:	 (*SPD/ALERT is common digit) | gbl_mcp_digits:len() = 26 chars
	--	START	=			  1		  4		   8		 9		   12			15		 	20			  25
	--	END	=			  3		  7		   8		 11		   14		 	19			24	 		  27

-- SAMPLE
-----------
	--	OVERSPEED		043		.42		   8		271		  258		  23000		   +1400		043
	--	UNDERSPEED		043		.42		   A		271		  258		  23000		   +1400		043


	-- prtdbg("I:",gbl_mcp_capt_crs)
	-- prtdbg("I:",gbl_mcp_mach)
	-- prtdbg("I:",gbl_mcp_speed_status)
	-- prtdbg("I:",gbl_mcp_speed)
	-- prtdbg("I:",gbl_mcp_hdg)
	-- prtdbg("I:",gbl_mcp_alt)
	-- prtdbg("I:",gbl_mcp_vvi,"dbg06",true)
	-- prtdbg("I:",gbl_mcp_fo_crs)

	c_1 = tonumber(gbl_mcp_capt_crs)
	c_2 = tonumber(gbl_mcp_mach)
	c_3 = string.byte(gbl_mcp_speed_status)
	c_4 = tonumber(gbl_mcp_speed)
	c_5 = tonumber(gbl_mcp_hdg)
	c_6 = tonumber(gbl_mcp_alt)
	c_7 = gbl_mcp_vvi
	c_8 = tonumber(gbl_mcp_fo_crs)

	gbl_mcp_digits = string.format("%03d%01.2f%c%03d%03d%5d%s%03d",
									c_1,
									c_2,
									c_3,
									c_4,
									c_5,
									c_6,
									c_7,
									c_8
									)
	-- gbl_mcp_digits = gbl_mcp_capt_crs..gbl_mcp_mach..gbl_mcp_speed_status..gbl_mcp_speed..gbl_mcp_hdg..gbl_mcp_alt..gbl_mcp_vvi..gbl_mcp_fo_crs

	-- prtdbg("DISP ALL LEDs: ",string.format("%2d",gbl_mcp_digits:len()).."["..gbl_mcp_digits.."]","dbg01",true)

	hw_chr_display0()
	hw_chr_display1()
	hw_chr_display2()
	hw_chr_display3()
	-- hw_chr_display4()

	-- prtdbg("DISP LEDs #0: ",str_chr_display0,"dbg02",true)
	-- prtdbg("DISP LEDs #1: ",str_chr_display1,"dbg03",true)
	-- prtdbg("DISP LEDs #2: ",str_chr_display2,"dbg04",true)
	-- prtdbg("DISP LEDs #3: ",str_chr_display3,"dbg05",true)

--	print("DISP#1: "..string.format("%2d",str_chr_display0:len()).."["..str_chr_display0.."]   ".."DISP#2: "..string.format("%2d",str_chr_display1:len()).."["..str_chr_display1.."]")

	-- [ id | #module if chained (starting from 0) | #line starting from 0 (if more than one line available on module) | Value to be displayed ]
	hw_chr_display_set_text(display_chr_id, 0, 0, str_chr_display0)
	hw_chr_display_set_text(display_chr_id, 1, 0, str_chr_display1)
	hw_chr_display_set_text(display_chr_id, 2, 0, str_chr_display2)
	hw_chr_display_set_text(display_chr_id, 3, 0, str_chr_display3)
	-- hw_chr_display_set_text(display_chr_id, 4, 0, str_chr_display4)
end

function hw_chr_display0()		-- CRS A & SPD
	str_chr_display0 = gbl_mcp_digits:sub(1,3)		-- 3 leds digits
	-- SPEED or MACH
	if gbl_speed_mode == 1 then
		-- 6 digits		-- 4 chars --> 3 leds digits			= 3 leds digits + 3 previous leds digits	= 6 leds digits
		str_chr_display0 = str_chr_display0..gbl_mcp_digits:sub(4,7)
	else
		-- 6 didgits	-- 2 blanks + 1 digit + 2 leds digits	= 5 leds digits + 3 previous leds digits	= 8 leds digits
		str_chr_display0 = str_chr_display0.." "..gbl_mcp_digits:sub(8,11)
	end
end

function hw_chr_display1()		-- HDG & ALT
	str_chr_display1 = gbl_mcp_digits:sub(12,19)		-- 8 leds digits
end

function hw_chr_display2()		-- VSI & CRS B
	str_chr_display2 = gbl_mcp_digits:sub(20,27)		-- 8 leds digits
end

function hw_chr_display3()		-- CRS B
	str_chr_display3 = gbl_mcp_digits:sub(25,27)		-- 8 leds digits
end

zogster
Posts: 6
Joined: Sun Dec 11, 2022 10:08 pm

Re: 2 x fields displayed on same MAX7219?

#3 Post by zogster »

Thanks dude

My programming skills are a little basic, but I think that gives me the info I need… I'm sure with a little patience, cut-and-paste, and general fiddling around I'll get this working

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: 2 x fields displayed on same MAX7219?

#4 Post by Ralph »

Try this:

Code: Select all

val1 = "123"
val2 = "456"

print(val1 .. "  " .. val2)

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: 2 x fields displayed on same MAX7219?

#5 Post by Keith Baxter »

Ralph wrote: Wed Feb 01, 2023 7:26 pm Try this:

Code: Select all

val1 = "123"
val2 = "456"

print(val1 .. "  " .. val2)
Hmmm...

Not so easy. It will depend on the format and led configuration. A MAX7219 can have anything from 1 to 8 7seg led's.
I will leave that arg.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Ralph
Posts: 7878
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: 2 x fields displayed on same MAX7219?

#6 Post by Ralph »

The OP claimed to have 8.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: 2 x fields displayed on same MAX7219?

#7 Post by Keith Baxter »

Ralph wrote: Wed Feb 01, 2023 9:00 pm The OP claimed to have 8.
Yes he did. But

Each field ("STRING") would have to be properly formatted if they are concatenated.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

zogster
Posts: 6
Joined: Sun Dec 11, 2022 10:08 pm

Re: 2 x fields displayed on same MAX7219?

#8 Post by zogster »

Yes, I am planning on doing this using ONLY generic MAX7219 modules, specifically: https://www.aliexpress.com/item/1005004 ... _edm_other

Won't have time to try this until tomorrow or Friday, but will report back

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: 2 x fields displayed on same MAX7219?

#9 Post by SimPassion »

zogster wrote: Wed Feb 01, 2023 9:51 pm Yes, I am planning on doing this using ONLY generic MAX7219 modules, specifically: https://www.aliexpress.com/item/1005004 ... _edm_other

Won't have time to try this until tomorrow or Friday, but will report back
Great ! Don't miss to add the required capacitor, most of these modules don't bring on delivery ... !!! ;-)

zogster
Posts: 6
Joined: Sun Dec 11, 2022 10:08 pm

Re: 2 x fields displayed on same MAX7219?

#10 Post by zogster »

Quick update: I started adapting this code… made some progress but before I got things working I realised that I had a couple of 3-character displays I could used instead, which would be easier. So I went that way instead, though I might revisit this approach later.

Post Reply