Thanks ill have to try that and if im understanding look at posts #136 and #137 and change it some over to the COM and NAV swap buttons?
Printable View
Thanks ill have to try that and if im understanding look at posts #136 and #137 and change it some over to the COM and NAV swap buttons?
The post you mean are only ADF and XPNDR.
I can write you a code sample from my cockpit, but that dont base on the FS Swap offset.
Code:case C_COM1Trans:
FsWrite (FS_COM1FREQUENCY, COM1S);
FsWrite (FS_COM1STANDBY, COM1);
FsbusWrite (C_COM1DisplayS, BCD2Int(COM1)+10000);
FsbusWrite (C_COM1DisplayA, comstby+10000);
x1 = COM1;
x2 = COM1S;
COM1 = x2;
COM1S = x1;
break;
Sure that would be great and i have the code for all the COM1 + COM1 stby and so on just dont have the Swap button in there. Was thinking of trying to put it all into C++ before i get my IO pcbs in the mail but almost think i should wait for them so i can learn and teach my self on how the IO board works. then that way i can also play with the code and the switch at the same time.
Hi Trevor,
It is definately better to have the boards wired up and ready to test your code, otherwise you won't know if it is working properly. Having the boards also lets you problem solve any issues.
Here is the code that I am grateful to Stefan's help with (this is a working code that I am using for my cockpit so it should work fine for you):
(If you are still having trouble working it out, let me know and I'll post the entire radios .cpp file for you)
Don't forget to define the int at the top:
David
static int nav1mode=0;
Code:/*----------------------- NAV1 Events ---------------------*/
case FS_NAV1FREQUENCY:
Nav1Fr = 10000 + BCD2Int(val);
FsbusWrite(C_DNAV1, Nav1Fr);
break;
case FS_NAV1STANDBY:
Nav1FrStb = 10000 + BCD2Int(val);
FsbusWrite(C_DNAV1STB, Nav1FrStb);
break;
case C_NAV1Push:
if(val==0)
{
nav1mode+=1;
if (nav1mode>1)
nav1mode=0;
}
break;
case C_RNAV1:
if (nav1mode==0)
{
x = Nav1FrStb % 100; // behind dec point
x = x + 5 * val; // in steps of 0.05
if (x > 95)
x = 0 ;
else if (x < 0)
x = 95;
Nav1FrStb = Nav1FrStb / 100 * 100 + x; // units: 0.01
FsbusWrite(C_DNAV1STB, Nav1FrStb);
x = Int2BCD(Nav1FrStb % 10000);
FsWrite(FS_NAV1STANDBY, x);
break;
}
if (nav1mode==1)
{
x = Nav1FrStb / 100;
x = x + val; // in steps of 1.00
if (x > 117)
x = 108;
else if (x < 108)
x = 117;
Nav1FrStb = x * 100 + Nav1FrStb % 100; // units: 0.01
FsbusWrite(C_DNAV1STB, Nav1FrStb);
x = Int2BCD(Nav1FrStb % 10000);
FsWrite (FS_NAV1STANDBY, x);
break;
case C_SNAV1SWAP:
if (val == 0)
FsWrite(FS_RADIOUSESTBYTOGGLE, 0x02); // toggle bit 1 (NAV1)
break;
}
Thank You David for your post that helped out alot. Also Stefan Sent me a file of a sample project and that has also helped out alot. Thanks guys
0x08 toggle bit 3 (COM1)
0x04 toggle bit 2 (COM2)
0x02 toggle bit 1 (NAV1)
0x01 toggle bit 3 (NAV2)
So if the bits are that above how do you get that out of
2^3 = COM1
2^2 = COM2
2^1 = NAV1
2^0 = NAV2
I'm not quite sure about what you are trying to work out either.
The swap is done with the Nav1mode part of the code. I haven't used any offsets for the swap, just Nav1mode==0 and Nav1mode==1.
Stefan showed me how to use this and it works perfect.
Do you want my entire .cpp code for the radios so you can see how it's put together without using offsets for the swap? (I'm more than happy for you to use the whole thing in it's entireity or just bits of it)
David
Hi David,
yes we both and Rob in the Sample File use the Radioīs ase Input Only devices.
We swap the frequenzies self.
If you donīt need the FS default Swap Offset, you also dont need to read out the frequenzies from the FS.
Stefan
(Light goes on in head) O.... ok thanks that makes since now! Yeah I understood that A=B but just didnt understand on why it did but i get it now. It was almost like in Math in school where i understood that this = this but didnt see the work for it to prove on why it did. I get it now thanks again Jan!
And David i think im ok now just was wondering on why above was why it was thats all, but thanks anyways. I might take you up on your offer later down the road for the mcp maybe but well see.
Trevor