This console has two encoders for NAV1/2 and ADF frecuency and decimals.
And three buttons NAV1, NAV2 and ADF. Depending on which button I press, the encoders change the frequency of the respective system.
Button NAV1, the encoders change the freq of the NAV1 and so on.
I try with this code but I am at a standstill.
Code: Select all
function switch_state()
if hw_input_read(input_1)
function encogrande_set(direction)
if direction == 1 then
xpl_command("sim/radios/stby_nav1_coarse_down")
elseif direction == -1 then
xpl_command("sim/radios/stby_nav1_coarse_up")
end
function encochico_set(direction)
if direction == 1 then
xpl_command("sim/radios/stby_nav1_fine_down")
elseif direction == -1 then
xpl_command("sim/radios/stby_nav1_fine_up")
end
end
elseif hw_input_read(input_2)
function encogrande_set(direction)
if direction == 1 then
xpl_command("sim/radios/stby_nav2_coarse_down")
elseif direction == -1 then
xpl_command("sim/radios/stby_nav2_coarse_up")
end
function encochico_set(direction)
if direction == 1 then
xpl_command("sim/radios/stby_nav2_fine_down")
elseif direction == -1 then
xpl_command("sim/radios/stby_nav2_fine_up")
end
end
elseif hw_input_read(input_3)
function encogrande_set(direction)
if direction == 1 then
xpl_command("sim/radios/stby_adf1_hundreds_thous_down")
elseif direction == -1 then
xpl_command("sim/radios/stby_adf1_hundreds_thous_up")
end
function encochico_set(direction)
if direction == 1 then
xpl_command("sim/radios/stby_adf1_ones_tens_down")
elseif direction == -1 then
xpl_command("sim/radios/stby_adf1_ones_tens_up")
end
end
end
input_1 = hw_input_add("Switch connection 1", function(state)
switch_state() -- switch_state is called when the state of this pin changes
end)
input_2 = hw_input_add("Switch connection 2", function(state)
switch_state() -- switch_state is called when the state of this pin changes
end)
input_3 = hw_input_add("Switch connection 3", function(state)
switch_state() -- switch_state is called when the state of this pin changes
end)
-- We add a timer for redundancy
timer_start(nil, 500, function()
switch_state()
end)
hw_dial_add("Encoder Grande", encogrande_set)
hw_dial_add("Encoder Chico", encochico_set)
hw_button_add("Sw NAV1", selnav1)
hw_button_add("Sw NAV2", selnav2)
hw_button_add("Sw ADF", seladf)
Jose