COM1 and STANDBY COM1 : 7 Segment Display

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: russ, Ralph

Post Reply
Message
Author
CmteLucasGodoy
Posts: 3
Joined: Wed Jan 18, 2023 1:35 pm

COM1 and STANDBY COM1 : 7 Segment Display

#1 Post by CmteLucasGodoy »

Hello Sim Innovations Team,

I have one question regarding the use of 7 digits segment display.

If I select one frequency with "5" in the end, like "119.405" ,and, after that, I select the frequency "118.400", The SIM Var is, unfortunately changed to "118.4" and not to "118.400". the tostring() converts the output to "118.4" (not completing the zeros missing) and the 7 segment Display displays: "118.405" (with the 05 "not updated from the last selected sequence").

Is there any solution that you already use for this problem?

Thank you in advance,
Lucas Godoy

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

Re: COM1 and STANDBY COM1 : 7 Segment Display

#2 Post by Ralph »

Please see our wiki:
https://siminnovations.com/wiki/index.p ... _now_works!

So in your case for example string.format("%07.03f", frequency)

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

Re: COM1 and STANDBY COM1 : 7 Segment Display

#3 Post by Keith Baxter »

Hi,

Firstly, what 7 seg display are you using and how is it wired?

For a max7219 8 digit display you would have to format the string something like this. But that depends on the display and shift register.

string.format("% 9.03f",(com1act/1000))
The string format forces % 9 digits which includes the decimal. the .03f forces 3 decimal places.

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: 7921
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: COM1 and STANDBY COM1 : 7 Segment Display

#4 Post by Ralph »

Depends indeed on which module you use. But you can also just add a few spaces, depending on where you want the frequency.
Example for a 8 character display and two spaces 'in front': string.format(" %07.03f", frequency)

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

Re: COM1 and STANDBY COM1 : 7 Segment Display

#5 Post by Keith Baxter »

Ralph wrote: Mon Mar 13, 2023 4:28 pm So in your case for example string.format("%07.03f", frequency)
Hi,

We have to be careful with string.format() when it comes to 7seg displays.
The code you quoted assumes a LEFT address.

What happens if the value is 23.005 instead of 123.005
23.005 would return 023.005 + two white spaces addressed to the left most digit.

What you will find when running this simple code is the difference as to what the 0 and white-space. The string.format("%07.03f"forces a left align and will leave white-spaces after the three decimals, whereas string.format("% 7.03f") forces a right align but only to the 6th digit.
To force a right align on a 8 digit max7219 you must use string.format("% 9.03f")

Code: Select all

value = 123.005
com2_val = string.format("%07.03f", value)
print(com2_val )

value4 = 23.005
com2_val4 = string.format("%07.03f", value4)
print(com2_val4)

value2 = 123.005
com2_val2 = string.format("% 7.03f", value2)
print(com2_val2 )

value3 = 123.005
com2_val3 = string.format("% 9.03f", value2)
print(com2_val3 )

value5 = 23.005
com2_val5 = string.format("%09.03f", value5)
print(com2_val5)
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: 7921
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: COM1 and STANDBY COM1 : 7 Segment Display

#6 Post by Ralph »

You can either align left or right, depending on where you put the spaces, I don't really see the problem there.

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

Re: COM1 and STANDBY COM1 : 7 Segment Display

#7 Post by Keith Baxter »

Ralph wrote: Mon Mar 13, 2023 8:35 pm You can either align left or right, depending on where you put the spaces, I don't really see the problem there.
Hi,

The problem is understanding the formatting and how the max7219 (common one) will display the characters on the display.

I have beaten this dead horse so much that my whip is in bits and I cannot even make tasty pies out of what is left of the meat. :roll: it seams no-one is grasping what I am saying.

I will do a illustration tomorrow and post here.

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: 7921
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: COM1 and STANDBY COM1 : 7 Segment Display

#8 Post by Ralph »

I know what you mean. But 99.99% is using that 8 segment MAX7219 thing, so there's not much to worry about.

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

Re: COM1 and STANDBY COM1 : 7 Segment Display

#9 Post by Keith Baxter »

Hi,

I am working on a instrument that will give insight as to what formatting has on a MAX7219 (common) display.

There will be a variety of format criteria and different string options.

More on this later. Just a teaser of what is to come. Not the difference between these two string.format() 's and what is displayed. ;)
ice_screenshot_20230314-171729.png
ice_screenshot_20230314-171831.png

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 

CmteLucasGodoy
Posts: 3
Joined: Wed Jan 18, 2023 1:35 pm

Re: COM1 and STANDBY COM1 : 7 Segment Display

#10 Post by CmteLucasGodoy »

I would like to thank you all for the replies. It really helped me a lot with my issue.

Best Regards,
Lucas Godoy

Post Reply