Hi folks,
My panel is coming together, the Arduino is mounted, and the wiring is being tied down.
Since my hardware "gauge" configuration settings sometimes get wiped-out, I'm going through my file and changing the hw "adds" from Named to Hardware ID formats, so they stay put. They aren't changing, so hard coding them is preferred at this point.
My rotary encoders switched over correctly, as did momentary buttons, and they all work just fine.
But my switches are not going so well. For example, my fuel selector 4 position switch went from ...
hw_switch_add("fuel selector", 4, fuel_selector)
with the four pins listed in the config page ... (don't know if this will show up or not)
to ...
hw_switch_add("ARDUINO_MEGA2560_A_D36","ARDUINO_MEGA2560_A_D37","ARDUINO_MEGA2560_A_D39","ARDUINO_MEGA2560_A_D38", 4, fuel_selector)
and the switches no longer show up in the config page, as expected, but the switch no longer works.
I've looked for missing comma's, typos, misspellings, etc., but I can't see what I'm doing wrong. Any ideas?
Thanks,
Jim
hw_switch_add issue
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: hw_switch_add issue
Hi Jim,
Try this
hw_switch_add("ARDUINO_MEGA2560_A_D36","ARDUINO_MEGA2560_A_D37","ARDUINO_MEGA2560_A_D39","ARDUINO_MEGA2560_A_D38", fuel_selector)
Keith
Try this
hw_switch_add("ARDUINO_MEGA2560_A_D36","ARDUINO_MEGA2560_A_D37","ARDUINO_MEGA2560_A_D39","ARDUINO_MEGA2560_A_D38", fuel_selector)
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
Re: hw_switch_add issue
Yep, Keith’s right. You do not need to specify the nr_pins when not using named hardware because it’s implicit in the number of hardware_ids you use.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: hw_switch_add issue
Of course! Thank you very much guys. The syntax was right there in front of me in the wiki, and I missed it.
Works perfectly now, thank you.
Would you happen to know if there is a single command, perhaps a reset of sorts, that will cause AM to read all of the hardware and assert the settings accordingly? I've noticed that AM does this when it starts, and I'm in the process of creating a "sync" button that will, in response to a button push on my panel, read all of the switch settings and set them in the simulator? If I load a new flight scenario, I'd like to push one button and have the simulator synchronized to the switch settings, without having to manually cycle all of the switches. I'm learning a lot though, building this thing switch-by-switch, but it occurred to me that if AM does this at start up, there might be a way to initiate it in a Lua script.
Thank you again for your help with the switch set-up!
Jim
Works perfectly now, thank you.
Would you happen to know if there is a single command, perhaps a reset of sorts, that will cause AM to read all of the hardware and assert the settings accordingly? I've noticed that AM does this when it starts, and I'm in the process of creating a "sync" button that will, in response to a button push on my panel, read all of the switch settings and set them in the simulator? If I load a new flight scenario, I'd like to push one button and have the simulator synchronized to the switch settings, without having to manually cycle all of the switches. I'm learning a lot though, building this thing switch-by-switch, but it occurred to me that if AM does this at start up, there might be a way to initiate it in a Lua script.
Thank you again for your help with the switch set-up!
Jim
Re: hw_switch_add issue
What I do is continually monitor the sim data and compare it with the hardware states. If for some reason the command did not get through or as in your scenario you load a new flight then this can be used to fix any differences. You can force this to run at regular intervals if you wish but you could also link a button into doing a single pass if this is preferred. It just gives a belt and braces way of ensuring the sim is doing as it’s told. It also helps with dropped commands, although I haven’t seen this myself others have reported it.
Tony
Tony
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: hw_switch_add issue
I didn’t have any issue. Confused.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: hw_switch_add issue
Hi Mike,
For hardware switches you need to read the state then activate the commands so that the sim matches the hardware state. (switches and buttons)
For led, relays, stepper motors, 7seg displays, you read the state then set the hardware to suite.
Did you try that code I sent you?
Keith
For hardware switches you need to read the state then activate the commands so that the sim matches the hardware state. (switches and buttons)
For led, relays, stepper motors, 7seg displays, you read the state then set the hardware to suite.
Did you try that code I sent you?
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
Re: hw_switch_add issue
What thread is that? I’ve never had an issue with this. So like I say, confused.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: hw_switch_add issue
Hi Mike
You are not answering my question in the previous post.
"Did you try that code I sent you?"
Keith
You are not answering my question in the previous post.
"Did you try that code I sent you?"
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