Fmc button matrix
Fmc button matrix
Hi
I want to know how can I use only one Arduino for fmc buttons
I want to know how can I use only one Arduino for fmc buttons
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Fmc button matrix
There's at least two different samples in the Z_2D_XP MCDU with :
[EDIT] added missing function for button nbr to function binding, thanks to Joe's accurate observation
- 32 INPUTS : for 8 x 8 Buttons Array = 64 Push Buttons Maxi
- 5 INPUTS : for 2 x 3 Buttons Array = 6 Push Buttons Maxi
= 37 INPUTS
- 37 INPUTS : for 4 x 8 + 1 x 5 (4 x (4 x 4) + 1 x (2 x 3) Buttons Array) = 70 Push Buttons Maxi
Code: Select all
-----------------------------------------------
-- FMC BUTTONS FUNCTIONS
-----------------------------------------------
function press_INIT() xpl_command("laminar/B738/button/fmc"..str_fmc.."_init_ref") end
function press_RTE() xpl_command("laminar/B738/button/fmc"..str_fmc.."_rte") end
function press_CLB() xpl_command("laminar/B738/button/fmc"..str_fmc.."_clb") end
function press_CRZ() xpl_command("laminar/B738/button/fmc"..str_fmc.."_crz") end
function press_DES() xpl_command("laminar/B738/button/fmc"..str_fmc.."_des") end
function press_MENU() xpl_command("laminar/B738/button/fmc"..str_fmc.."_menu", "BEGIN") end
function release_MENU() xpl_command("laminar/B738/button/fmc"..str_fmc.."_menu", "END") end
function press_LEGS() xpl_command("laminar/B738/button/fmc"..str_fmc.."_legs") end
function press_DEPARR() xpl_command("laminar/B738/button/fmc"..str_fmc.."_dep_app") end
function press_HOLD() xpl_command("laminar/B738/button/fmc"..str_fmc.."_hold") end
function press_PROG() xpl_command("laminar/B738/button/fmc"..str_fmc.."_prog") end
function press_N1() xpl_command("laminar/B738/button/fmc"..str_fmc.."_n1_lim") end
function press_FIX() xpl_command("laminar/B738/button/fmc"..str_fmc.."_fix") end
function press_PREV() xpl_command("laminar/B738/button/fmc"..str_fmc.."_prev_page") end
function press_NEXT() xpl_command("laminar/B738/button/fmc"..str_fmc.."_next_page") end
function press_EXEC() xpl_command("laminar/B738/button/fmc"..str_fmc.."_exec") end
-- ALPHA
function press_A() xpl_command("laminar/B738/button/fmc"..str_fmc.."_A") end
function press_B() xpl_command("laminar/B738/button/fmc"..str_fmc.."_B") end
function press_C() xpl_command("laminar/B738/button/fmc"..str_fmc.."_C") end
function press_D() xpl_command("laminar/B738/button/fmc"..str_fmc.."_D") end
function press_E() xpl_command("laminar/B738/button/fmc"..str_fmc.."_E") end
function press_F() xpl_command("laminar/B738/button/fmc"..str_fmc.."_F") end
function press_G() xpl_command("laminar/B738/button/fmc"..str_fmc.."_G") end
function press_H() xpl_command("laminar/B738/button/fmc"..str_fmc.."_H") end
function press_I() xpl_command("laminar/B738/button/fmc"..str_fmc.."_I") end
function press_J() xpl_command("laminar/B738/button/fmc"..str_fmc.."_J") end
function press_K() xpl_command("laminar/B738/button/fmc"..str_fmc.."_K") end
function press_L() xpl_command("laminar/B738/button/fmc"..str_fmc.."_L") end
function press_M() xpl_command("laminar/B738/button/fmc"..str_fmc.."_M") end
function press_N() xpl_command("laminar/B738/button/fmc"..str_fmc.."_N") end
function press_O() xpl_command("laminar/B738/button/fmc"..str_fmc.."_O") end
function press_P() xpl_command("laminar/B738/button/fmc"..str_fmc.."_P") end
function press_Q() xpl_command("laminar/B738/button/fmc"..str_fmc.."_Q") end
function press_R() xpl_command("laminar/B738/button/fmc"..str_fmc.."_R") end
function press_S() xpl_command("laminar/B738/button/fmc"..str_fmc.."_S") end
function press_T() xpl_command("laminar/B738/button/fmc"..str_fmc.."_T") end
function press_U() xpl_command("laminar/B738/button/fmc"..str_fmc.."_U") end
function press_V() xpl_command("laminar/B738/button/fmc"..str_fmc.."_V") end
function press_W() xpl_command("laminar/B738/button/fmc"..str_fmc.."_W") end
function press_X() xpl_command("laminar/B738/button/fmc"..str_fmc.."_X") end
function press_Y() xpl_command("laminar/B738/button/fmc"..str_fmc.."_Y") end
function press_Z() xpl_command("laminar/B738/button/fmc"..str_fmc.."_Z") end
function press_SPACE() xpl_command("laminar/B738/button/fmc"..str_fmc.."_SP") end
function press_DEL() xpl_command("laminar/B738/button/fmc"..str_fmc.."_del") end
function press_SLASH() xpl_command("laminar/B738/button/fmc"..str_fmc.."_slash") end
function press_CLR() xpl_command("laminar/B738/button/fmc"..str_fmc.."_clr", "BEGIN") end
function release_CLR() xpl_command("laminar/B738/button/fmc"..str_fmc.."_clr", "END") end
-- NUMERIC
function press_ONE() xpl_command("laminar/B738/button/fmc"..str_fmc.."_1") end
function press_TWO() xpl_command("laminar/B738/button/fmc"..str_fmc.."_2") end
function press_THREE() xpl_command("laminar/B738/button/fmc"..str_fmc.."_3") end
function press_FOUR() xpl_command("laminar/B738/button/fmc"..str_fmc.."_4") end
function press_FIVE() xpl_command("laminar/B738/button/fmc"..str_fmc.."_5") end
function press_SIX() xpl_command("laminar/B738/button/fmc"..str_fmc.."_6") end
function press_SEVEN() xpl_command("laminar/B738/button/fmc"..str_fmc.."_7") end
function press_EIGHT() xpl_command("laminar/B738/button/fmc"..str_fmc.."_8") end
function press_NINE() xpl_command("laminar/B738/button/fmc"..str_fmc.."_9") end
function press_PERIOD() xpl_command("laminar/B738/button/fmc"..str_fmc.."_period") end
function press_ZERO() xpl_command("laminar/B738/button/fmc"..str_fmc.."_0") end
function press_MINUS() xpl_command("laminar/B738/button/fmc"..str_fmc.."_minus") end
-- LSK#L
function press_LSK1L() xpl_command("laminar/B738/button/fmc"..str_fmc.."_1L") end
function press_LSK2L() xpl_command("laminar/B738/button/fmc"..str_fmc.."_2L") end
function press_LSK3L() xpl_command("laminar/B738/button/fmc"..str_fmc.."_3L") end
function press_LSK4L() xpl_command("laminar/B738/button/fmc"..str_fmc.."_4L") end
function press_LSK5L() xpl_command("laminar/B738/button/fmc"..str_fmc.."_5L") end
function press_LSK6L() xpl_command("laminar/B738/button/fmc"..str_fmc.."_6L") end
-- LSK#R
function press_LSK1R() xpl_command("laminar/B738/button/fmc"..str_fmc.."_1R") end
function press_LSK2R() xpl_command("laminar/B738/button/fmc"..str_fmc.."_2R") end
function press_LSK3R() xpl_command("laminar/B738/button/fmc"..str_fmc.."_3R") end
function press_LSK4R() xpl_command("laminar/B738/button/fmc"..str_fmc.."_4R") end
function press_LSK5R() xpl_command("laminar/B738/button/fmc"..str_fmc.."_5R") end
function press_LSK6R() xpl_command("laminar/B738/button/fmc"..str_fmc.."_6R") end
Code: Select all
local btn_pr1 = {
[1] = function() press_LSK1L() end,
[2] = function() press_LSK2L() end,
[3] = function() press_LSK3L() end,
[4] = function() press_LSK4L() end,
[5] = function() press_LSK5L() end,
[6] = function() press_LSK6L() end,
[7] = function() press_LSK1R() end,
[8] = function() press_LSK2R() end,
[9] = function() press_LSK3R() end,
[10] = function() press_LSK4R() end,
[11] = function() press_LSK5R() end,
[12] = function() press_LSK6R() end,
[13] = function() press_CRZ() end,
[14] = function() press_DES() end,
[15] = function() press_HOLD() end,
[16] = function() press_PROG() end
}
function pr_arr1_press(row, col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_pr1[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr1_release(row, col)
end
local btn_pr2 = {
[1] = function() press_EXEC() end,
[2] = function() press_INIT() end,
[3] = function() press_RTE() end,
[4] = function() press_CLB() end,
[5] = function() press_MENU() end,
[6] = function() press_LEGS() end,
[7] = function() press_DEPARR() end,
[8] = function() press_N1() end,
[9] = function() press_FIX() end,
[10] = function() press_PREV() end,
[11] = function() press_NEXT() end,
[12] = function() press_ONE() end,
[13] = function() press_TWO() end,
[14] = function() press_THREE() end,
[15] = function() press_FOUR() end,
[16] = function() press_FIVE() end
}
local btn_rl2 = {
[1] = function() end,
[2] = function() end,
[3] = function() end,
[4] = function() end,
[5] = function() release_MENU() end,
[6] = function() end,
[7] = function() end,
[8] = function() end,
[9] = function() end,
[10] = function() end,
[11] = function() end,
[12] = function() end,
[13] = function() end,
[14] = function() end,
[15] = function() end,
[16] = function() end
}
function pr_arr2_press(row, col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_pr2[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr2_release(row, col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_rl2[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
local btn_pr3 = {
[1] = function() press_SIX() end,
[2] = function() press_SEVEN() end,
[3] = function() press_EIGHT() end,
[4] = function() press_NINE() end,
[5] = function() press_PERIOD() end,
[6] = function() press_ZERO() end,
[7] = function() press_MINUS() end,
[8] = function() press_A() end,
[9] = function() press_B() end,
[10] = function() press_C() end,
[11] = function() press_D() end,
[12] = function() press_E() end,
[13] = function() press_F() end,
[14] = function() press_G() end,
[15] = function() press_H() end,
[16] = function() press_I() end
}
function pr_arr3_press(row, col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_pr3[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr3_release(row, col)
end
local btn_pr4 = {
[1] = function() press_J() end,
[2] = function() press_K() end,
[3] = function() press_L() end,
[4] = function() press_M() end,
[5] = function() press_N() end,
[6] = function() press_O() end,
[7] = function() press_P() end,
[8] = function() press_Q() end,
[9] = function() press_R() end,
[10] = function() press_S() end,
[11] = function() press_T() end,
[12] = function() press_U() end,
[13] = function() press_V() end,
[14] = function() press_W() end,
[15] = function() press_X() end,
[16] = function() press_Y() end
}
function pr_arr4_press(row, col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_pr4[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr4_release(row, col)
end
local btn_pr5 = {
[1] = function() press_Z() end,
[2] = function() press_SPACE() end,
[3] = function() press_DEL() end,
[4] = function() press_SLASH() end,
[5] = function() press_CLR() end,
[6] = function() end,
}
local btn_rl5 = {
[1] = function() end,
[2] = function() end,
[3] = function() end,
[4] = function() end,
[5] = function() release_CLR() end,
[6] = function() end,
}
function pr_arr5_press(row, col)
btn_nbr = (col+1)+(row*3)
local f_exec_btn_pr = btn_pr5[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr5_release(row, col)
btn_nbr = (col+1)+(row*3)
local f_exec_btn_pr = btn_rl5[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
local btn_pr6 = {
[1] = function() press_LSK1L() end,
[2] = function() press_LSK2L() end,
[3] = function() press_LSK3L() end,
[4] = function() press_LSK4L() end,
[5] = function() press_LSK5L() end,
[6] = function() press_LSK6L() end,
[7] = function() press_LSK1R() end,
[8] = function() press_LSK2R() end,
[9] = function() press_LSK3R() end,
[10] = function() press_LSK4R() end,
[11] = function() press_LSK5R() end,
[12] = function() press_LSK6R() end,
[13] = function() press_CRZ() end,
[14] = function() press_DES() end,
[15] = function() press_HOLD() end,
[16] = function() press_PROG() end,
[17] = function() press_EXEC() end,
[18] = function() press_INIT() end,
[19] = function() press_RTE() end,
[20] = function() press_CLB() end,
[21] = function() press_MENU() end,
[22] = function() press_LEGS() end,
[23] = function() press_DEPARR() end,
[24] = function() press_N1() end,
[25] = function() press_FIX() end,
[26] = function() press_PREV() end,
[27] = function() press_NEXT() end,
[28] = function() press_ONE() end,
[29] = function() press_TWO() end,
[30] = function() press_THREE() end,
[31] = function() press_FOUR() end,
[32] = function() press_FIVE() end,
[33] = function() press_SIX() end,
[34] = function() press_SEVEN() end,
[35] = function() press_EIGHT() end,
[36] = function() press_NINE() end,
[37] = function() press_PERIOD() end,
[38] = function() press_ZERO() end,
[39] = function() press_MINUS() end,
[40] = function() press_A() end,
[41] = function() press_B() end,
[42] = function() press_C() end,
[43] = function() press_D() end,
[44] = function() press_E() end,
[45] = function() press_F() end,
[46] = function() press_G() end,
[47] = function() press_H() end,
[48] = function() press_I() end,
[49] = function() press_J() end,
[50] = function() press_K() end,
[51] = function() press_L() end,
[52] = function() press_M() end,
[53] = function() press_N() end,
[54] = function() press_O() end,
[55] = function() press_P() end,
[56] = function() press_Q() end,
[57] = function() press_R() end,
[58] = function() press_S() end,
[59] = function() press_T() end,
[60] = function() press_U() end,
[61] = function() press_V() end,
[62] = function() press_W() end,
[63] = function() press_X() end,
[64] = function() press_Y() end,
}
local btn_rl6 = {
[1] = function() end,
[2] = function() end,
[3] = function() end,
[4] = function() end,
[5] = function() end,
[6] = function() end,
[7] = function() end,
[8] = function() end,
[9] = function() end,
[10] = function() end,
[11] = function() end,
[12] = function() end,
[13] = function() end,
[14] = function() end,
[15] = function() end,
[16] = function() end,
[17] = function() end,
[18] = function() release_INIT() end,
[19] = function() end,
[20] = function() end,
[21] = function() release_MENU() end,
[22] = function() end,
[23] = function() end,
[24] = function() end,
[25] = function() end,
[26] = function() end,
[27] = function() end,
[28] = function() end,
[29] = function() end,
[30] = function() end,
[31] = function() end,
[32] = function() end,
[33] = function() end,
[34] = function() end,
[35] = function() end,
[36] = function() end,
[37] = function() end,
[38] = function() end,
[39] = function() end,
[40] = function() end,
[41] = function() end,
[42] = function() end,
[43] = function() end,
[44] = function() end,
[45] = function() end,
[46] = function() end,
[47] = function() end,
[48] = function() end,
[49] = function() end,
[50] = function() end,
[51] = function() end,
[52] = function() end,
[53] = function() end,
[54] = function() end,
[55] = function() end,
[56] = function() end,
[57] = function() end,
[58] = function() end,
[59] = function() end,
[60] = function() end,
[61] = function() end,
[62] = function() end,
[63] = function() end,
[64] = function() end,
}
function pr_arr6_press(row, col)
btn_nbr = (col+1)+(row*9)
local f_exec_btn_pr = btn_pr6[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr6_release(row, col)
btn_nbr = (col+1)+(row*9)
local f_exec_btn_pr = btn_rl6[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
local btn_pr7 = {
[1] = function() press_Z() end,
[2] = function() press_SPACE() end,
[3] = function() press_DEL() end,
[4] = function() press_SLASH() end,
[5] = function() press_CLR() end,
[6] = function() end,
}
local btn_rl7 = {
[1] = function() end,
[2] = function() end,
[3] = function() end,
[4] = function() end,
[5] = function() release_CLR() end,
[6] = function() end,
}
function pr_arr7_press(row, col)
btn_nbr = (col+1)+(row*3)
local f_exec_btn_pr = btn_pr7[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr7_release(row, col)
btn_nbr = (col+1)+(row*3)
local f_exec_btn_pr = btn_rl7[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
Code: Select all
local str_arr1 = "1 x (8 x 8) + 1 x (2 x 3)"
local str_arr2 = "4 x (4 x 4) + 1 x (2 x 3)"
up_arr_str = user_prop_add_enum("CHOOSE HARDWARE BUTTONS ARRAY Number", str_arr1..","..str_arr2, str_arr1, "Choose HARDWARE BUTTONS ARRAY Number which would be used from this MCDU and restart AM Instrument")
arr_str = user_prop_get(up_arr_str)
if bln_btnarray == true then
prtdbg("BUTTON ARRAY","SELECTED","dbg07",true)
if arr_str == str_arr1 then
hw_btn_arr1 = hw_button_array_add("MCDU Push Buttons Array#1 : 8 x rows & 8 x columns", 8, 8, pr_arr6_press, pr_arr6_release)
hw_btn_arr2 = hw_button_array_add("MCDU Push Buttons Array#2 : 2 x rows & 3 x columns", 2, 3, pr_arr7_press, pr_arr7_release)
elseif arr_str == str_arr2 then
hw_btn_arr1 = hw_button_array_add("MCDU Push Buttons Array#1 : 4 x rows & 4 x columns", 4, 4, pr_arr1_press, pr_arr1_release)
hw_btn_arr2 = hw_button_array_add("MCDU Push Buttons Array#2 : 4 x rows & 4 x columns", 4, 4, pr_arr2_press, pr_arr2_release)
hw_btn_arr3 = hw_button_array_add("MCDU Push Buttons Array#3 : 4 x rows & 4 x columns", 4, 4, pr_arr3_press, pr_arr3_release)
hw_btn_arr4 = hw_button_array_add("MCDU Push Buttons Array#4 : 4 x rows & 4 x columns", 4, 4, pr_arr4_press, pr_arr4_release)
hw_btn_arr5 = hw_button_array_add("MCDU Push Buttons Array#5 : 2 x rows & 3 x columns", 2, 3, pr_arr5_press, pr_arr5_release)
end
else
-- .../...
end
Last edited by SimPassion on Mon Sep 05, 2022 11:13 am, edited 4 times in total.
Re: Fmc button matrix
Very nice Gilles.
Can I please ask how you are enumerating the button value to the function list ?
thanks
Joe
Can I please ask how you are enumerating the button value to the function list ?
thanks
Joe
Joe. CISSP, MSc.
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Fmc button matrix
Gilles,
@SimPassion the maximum number of columns and rows is set at 8. You would need to adjust your code as I note you have 9 columns in one of you matrix's. Corjan changed it in Dec 2020.
Keith
@SimPassion the maximum number of columns and rows is set at 8. You would need to adjust your code as I note you have 9 columns in one of you matrix's. Corjan changed it in Dec 2020.
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
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Fmc button matrix
again, I'll take it in account, thanks Keith for this precision I've also missedKeith Baxter wrote: ↑Sun Sep 04, 2022 10:26 am Gilles,
@SimPassion the maximum number of columns and rows is set at 8. You would need to adjust your code as I note you have 9 columns in one of you matrix's. Corjan changed it in Dec 2020.
ice_screenshot_20220904-122032.png
Keith
For all, indeed using, while using buttons array, the user is responsible alone to perform the proper wiring biding and ensure pressing a button will trigger the expected command ... until us, as devs, would be able to include a new feature to ease such buttons array binding nightmare on simmer side
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Fmc button matrix
So, I will build a mock-up using a 2560, in order to be sure all is working properly inside the Z_2D_XP MCDU instrument, with next script fix and release
Gilles
Gilles
Last edited by SimPassion on Sun Sep 04, 2022 11:22 am, edited 1 time in total.
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Fmc button matrix
Hi,
I did this some time ago. It is for the ZIBO.
Keith
I did this some time ago. It is for the ZIBO.
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
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Fmc button matrix
Thanks Keith, I understand the 8 x 8 array is working and your hardware function is more straight forward on direct Arduino binding and usage, for those not wanting to display the graphics parts
In my case I still have to deliver both parts in it and simmers are still able and allowed to hide graphics parts, while using the instrument in an AM/AP panel. However I have to maintain the graphics and visual for usage outside hardware cockpit
In short there's many approaches and one can choose between all is already available
Gilles
In my case I still have to deliver both parts in it and simmers are still able and allowed to hide graphics parts, while using the instrument in an AM/AP panel. However I have to maintain the graphics and visual for usage outside hardware cockpit
In short there's many approaches and one can choose between all is already available
Gilles
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Fmc button matrix
The post #2 have been updated to bring
-- 32 INPUTS : for 8 x 8 Buttons Array = 64 Push Buttons Maxi
-- 5 INPUTS : for 2 x 3 Buttons Array = 6 Push Buttons Maxi
so an overall of 37 INPUTS
targeting the 69 inputs required for keys (the latest one is not use, so the related function is empty)
https://siminnovations.com/forums/viewt ... 258#p48258
I hope it will work, though I still have to perform the testing to ensure I will submit a new Z_2D_XP MCDU release without any issue in it
-- 32 INPUTS : for 8 x 8 Buttons Array = 64 Push Buttons Maxi
-- 5 INPUTS : for 2 x 3 Buttons Array = 6 Push Buttons Maxi
so an overall of 37 INPUTS
targeting the 69 inputs required for keys (the latest one is not use, so the related function is empty)
https://siminnovations.com/forums/viewt ... 258#p48258
I hope it will work, though I still have to perform the testing to ensure I will submit a new Z_2D_XP MCDU release without any issue in it
Last edited by SimPassion on Mon Sep 05, 2022 11:15 am, edited 1 time in total.