Many questions about 7 segment display modules

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

Moderators: russ, Ralph

Message
Author
Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Many questions about 7 segment display modules

#61 Post by Kaellis991 »

Keith Baxter wrote: Fri Mar 24, 2023 5:24 pm Kirk,

I just thought of something try this.

Code: Select all

sim_value = "123.05"

--Reverse the string
sim_value = string.reverse(sim_value)

--format the string
sim_value =  string.format("% 9.4f",sim_value/10)

-- Create a new Max7219 based character display
display_chr_id = hw_chr_display_add("NAV1 frequency", "MAX7219", 1)

-- Set text to the manipulated sim string value
hw_chr_display_set_text(display_chr_id, 0, 0, sim_value)
Keith
This is what that code produces...
592DB8B0-36FC-49FF-80A9-C4B336E3C898.jpeg

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

Re: Many questions about 7 segment display modules

#62 Post by Keith Baxter »

Awesom it moved the decimal one place to the right. Lets move it to the left.

OK lets change line 8 to.

string.format("% 9.4f",sim_value*10)

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 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Many questions about 7 segment display modules

#63 Post by Kaellis991 »

It looks like the only change you made was from .....sim_value/10 to ....sim_value*10
And that as in line 7...

With that we get this
0183A43C-B26D-4674-B56B-3994226907C8.jpeg

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

Re: Many questions about 7 segment display modules

#64 Post by Keith Baxter »

Great at least we have the decimal in the correct place.

Now we nee to move the display to the left two places.

try changing <"% 9.2f"> and play around with .?f and see which way the digits move.

So go <"% 9.3f"> <"% 9.2f"> < "% 9.5f">

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 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Many questions about 7 segment display modules

#65 Post by Kaellis991 »

I changed <% 9.4f> to <% 9.2f> and now the decimal is in the correct location
FDF0C742-884D-457B-A97D-C6B926632770.jpeg

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Many questions about 7 segment display modules

#66 Post by Kaellis991 »

Then change the sim_value variable to 137.25
A9435EA7-9E3F-4F8F-BD44-3FC023DD1758.jpeg

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

Re: Many questions about 7 segment display modules

#67 Post by Keith Baxter »

Kaellis991 wrote: Fri Mar 24, 2023 5:53 pm I changed <% 9.4f> to <% 9.2f> and now the decimal is in the correct location

FDF0C742-884D-457B-A97D-C6B926632770.jpeg
Awesome I now know how to sort out the NAV radio for you.
dec point.jpg
A big coding "hack" , but at least we got there.

The ADF is not going to be that easy because frequencies go from 100.0 to 1799.5 .
That might meen you will have to live with leading 0's (0100.0)

Keith
Last edited by Keith Baxter on Sat Mar 25, 2023 3:02 pm, edited 1 time in total.
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
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Many questions about 7 segment display modules

#68 Post by Keith Baxter »

Change the format to <% 9.1f> and the value to 100.0

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 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Many questions about 7 segment display modules

#69 Post by Kaellis991 »

Keith Baxter wrote: Fri Mar 24, 2023 5:59 pm
Kaellis991 wrote: Fri Mar 24, 2023 5:53 pm I changed <% 9.4f> to <% 9.2f> and now the decimal is in the correct location

FDF0C742-884D-457B-A97D-C6B926632770.jpeg
Awesome I now know how to sort out the NAV radio for you.

A big coding "hack" , but at least we got there.

The ADF is not going to be that easy because frequencies go from 100.0 to 1799.5 .
That might meen you will have to live with leading 0's (0100.0)

Keith
Keith,

I am not needing an ADF radio, just the COM and NAV

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

Re: Many questions about 7 segment display modules

#70 Post by Keith Baxter »

How many digits do you have on tour com radio?

Try the last code change anyway for me please. In case someone else need it.

Thanks
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 

Post Reply