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

#71 Post by Kaellis991 »

Keith,

Both radios only need the 3+2 digit format.

I can post the code that I changed if you can refresh my memory on the formatting to place for pasting the code in this thread.

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

Re: Many questions about 7 segment display modules

#72 Post by Kaellis991 »

I see it now.....here's what I am running right now....

Code: Select all

sim_value = "137.25"

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

--format the string
sim_value =  string.format("% 9.2f",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)

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

Re: Many questions about 7 segment display modules

#73 Post by Keith Baxter »

Kaellis991 wrote: Fri Mar 24, 2023 6:19 pm Keith,

Both radios only need the 3+2 digit format.

I can post the code that I changed if you can refresh my memory on the formatting to place for pasting the code in this thread.
No worries. So you just need the NAV radio?

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

#74 Post by Kaellis991 »

Ultimately I will have both a COM and a NAV radio.

But both designed exactly the same.

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

Re: Many questions about 7 segment display modules

#75 Post by Kaellis991 »

Keith,

I have that code you created for the 6 digit display.

Is that something you can modify to incorporate what you just figured out for these 5 digit displays?

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

Re: Many questions about 7 segment display modules

#76 Post by Keith Baxter »

Kaellis991 wrote: Fri Mar 24, 2023 6:43 pm Keith,

I have that code you created for the 6 digit display.

Is that something you can modify to incorporate what you just figured out for these 5 digit displays?
Kirk,

Let me do the NAV first then I will do the COM for you.

Give me a day or so for the NAV.

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

#77 Post by Kaellis991 »

Keith

Will this previous code you did help any or do you have it already?

Code: Select all

-- Simple code to display the active com2 frequency Xplane

--Create a var clear any values that may be on the display
com2_val = "        "
nav2_val = "        "
--A a MAX7219 hw_chr_display
raddeux_actv = hw_chr_display_add("com2 ACTV frequency",  "MAX7219", 2)
--Subscribe to dataref and add function
xpl_dataref_subscribe("sim/cockpit2/radios/actuators/com2_frequency_hz_833", "INT",
                      "sim/cockpit/radios/nav2_freq_hz", "INT",function(new_com2_val,new_nav2_val )
--Replace com2_val value with the dataref new_com2_val and format
   com2_val = string.format("% 9.04f", new_com2_val / 1000)
--Send the com2_val to the display
   hw_chr_display_set_text(raddeux_actv, 0, 0, com2_val)

 --Replace nav2_val value with the dataref new_nav2_val and format
   nav2_val = string.format("% 9.04f", new_nav2_val/100)
--Send the nav2_val to the display
   hw_chr_display_set_text(raddeux_actv, 1, 0, nav2_val)
end)

--Add dials to set frequencies
hw_dial_add("com2 Coarse","TYPE_2_DETENT_PER_PULSE", function(dir)
    if dir == -1then xpl_command("sim/radios/actv_com2_coarse_down") end
    if dir ==  1then xpl_command("sim/radios/actv_com2_coarse_up") end
end)
hw_dial_add("com2 fine","TYPE_2_DETENT_PER_PULSE", function(dir)
    if dir == -1then xpl_command("sim/radios/actv_com2_fine_down") end
    if dir ==  1then xpl_command("sim/radios/actv_com2_fine_up") end
end)

hw_dial_add("nav2 Coarse","TYPE_2_DETENT_PER_PULSE", function(dir)
    if dir == -1then xpl_command("sim/radios/actv_nav2_coarse_down") end
    if dir ==  1then xpl_command("sim/radios/actv_nav2_coarse_up") end
end)
hw_dial_add("nav2 fine","TYPE_2_DETENT_PER_PULSE", function(dir)
    if dir == -1then xpl_command("sim/radios/actv_nav2_fine_down") end
    if dir ==  1then xpl_command("sim/radios/actv_nav2_fine_up") end
end)

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

Re: Many questions about 7 segment display modules

#78 Post by Kaellis991 »

Keith,

Thanks again for your help...

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

Re: Many questions about 7 segment display modules

#79 Post by Keith Baxter »

Hi,

Here is the NAV radio. Please test and let me know if it is OK.
Kirk - NAV Radio.siff
(3.41 KiB) Downloaded 155 times
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
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Many questions about 7 segment display modules

#80 Post by jph »

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
Nice job Kirk,
;)
Joe. CISSP, MSc.

Post Reply