Jump to content
The simFlight Network Forums

How to read radio audio switches

Recommended Posts

1 hour ago, Abdullah Radwan said:

After playing a lot, here is working code:

Well done. But in general, when you want to test one "bit" in a byte, you'd use:

if (x & mask) ...

where x is the value you've read, and "mask" is the value of the bit( you want to test for. So in your case:

if (audioSelection & 128)
  for COM1, and

if (audioSelection & 64)
  for COM2

There are other bits for the other audio switches.

Bit values are derived from evaluation 2 to the power n, i.e. 2 times 2 'n' number of times, with the special-seeming case that 0 results always in the value 1. So:

bit 0 = 1
bit 1 = 2
bit 2 = 4
bit 3 = 8
bit 4 = 16
bit 5 = 32
bit 6 = 64
bit 7 = 128

For more about bits, see the FAQ subforum help thread entitled
About bits, numbers and hexadecimal



  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.