Results 131 to 140 of 737
Thread: Progamming help with FSBus dll
-
07-05-2009, 08:14 AM #131
Re: Progamming help with FSBus dll
Ok, that explains why it doesn't work.
I will have another look at Rob's code. He seems to use a different format for his coding and I've found it a little difficult to work out.
Also, my rotary encoders have a momentary switch when you push the knob. I have read somewhere that it is possible to convert it to a dual encoder by using this switch ie: tune the main three digits, push the knob and then tune the decimal places.
Is this possible?
Thanks
David
-
07-05-2009, 09:18 AM #132
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
Hi,
what you mean with "He seems to use a different format for his coding "?
with the pushbutton is a possible way.
Stefan
-
07-05-2009, 07:21 PM #133
Re: Progamming help with FSBus dll
Rob uses "Eventhandler" a lot and I don't understand it. It's just my lack of knowledge.
His method of defining is different to how I've been laying out my code. His seems quite advanced compared to my 'learning' code.
How can it be done with the rotary encoder with the push switch?
I will go though Rob's code later today to see if I can pull out the right info.
David
-
07-06-2009, 01:39 AM #134
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
The "EventHandler" is the highest Funktion in Robs code.
The Type of defining is more effektive, btw. we dont use Groups with 32 Objects. Our groups have 256 objekts.
Your Encoder is only an normal Encoder and a normal push button, nothing special. You have too make Code for the Mode Switching and rotation.
Stefan
-
07-06-2009, 07:54 AM #135
Re: Progamming help with FSBus dll
I've done lots of trial and error using the EventHandler with no success so I've rebuilt Rob's code in the format I've got used to.
I have had reasonable success as such. Rob uses 3 encoders ie: 1, 10,100.
If I assign my rotary encoder (1 at a time to test) to each, it moves my display as it should, but doesn't move the display on the screen. If I change the numbers on the screen with my cursor, the numbers in my display also change.
It appears the encoder is writing correctly to Fsbus, but not to FS and FS is writing to Fsbus correctly.
I'll attache the code and if you get a chance, could you take a look and see what I've missed.
Also, I have no idea how to put together the code for the mode switching and rotation so I'd love some help there too if possible.
I'll just post the case part:
Code:void cbNav (int oid, int val, double dval) { int x; switch (oid) { /*----------------------- ADF Events ----------------------*/ case FS_ADF1FREQUENCY: ADF1 = (ADF1 / 10000) * 10000 + BCD2Int(val) * 10 + ADF1 % 10; FsbusWrite(C_DADF1, ADF1); if (bSynchronised == false) { FsbusWrite(C_DADF1, ADF1); } break; case FS_EXTENDEDADF1: ADF1 = BCD2Int(val >> 8) * 10000 + ((ADF1/10)%1000)*10 + BCD2Int(val & 0x00FF); FsbusWrite(C_DADF1, ADF1); if (bSynchronised == false) { FsbusWrite(C_DADF1, ADF1); } break; case C_RADF_100: x = ADF1 / 1000; // hundreds x = x + val; // update 100s if (x > 17) x = 1; // wrap elseif (x < 1) x = 17; // wrap ADF1 = x * 1000 + ADF1 % 1000; // new 100s FsbusWrite(C_DADF1, ADF1); FsWrite(C_DADF1, ADF1);//***ADDED THIS MYSELF TO SEE IF I COULD GET IT TO WRITE TO FSX break; case C_RADF_10: x = (ADF1 % 1000) / 10; // tens + units x = x + val; // update 10s if (x > 99) x = 0; // wrap elseif (x < 0) x = 99; // wrap ADF1 = (ADF1 / 1000) * 1000 + x * 10 + ADF1 % 10; // new 10s FsbusWrite(C_DADF1, ADF1); break; case C_RADF_1: x = ADF1 % 10; // .1 units x = x + val; // update 10s if (x > 9) x = 0; // wrap elseif (x < 0) x = 9; // wrap ADF1 = (ADF1 / 10) * 10 + x; FsbusWrite(C_DADF1, ADF1); break; } }
David
Update: I have changed FsWrite(C_DADF1, ADF1); to FsWrite(FS_ADF1FREQUENCY, ADF1) as of course C_DADF1 is not an FS Object and now it is writing to FSX but random numbers. In FSInterrogate, it is making random hexidecimal numbers. If I leave the FSWrite out, my display moves perfectly when I move the encoder, but when I add the FSWrite in, it become random. Any ideas?
-
07-06-2009, 08:34 AM #136
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
Hi,
that is my ADF Code.
Btw. ADF need 2 FSUIPC Offset.
Code:/* adf1_dec and adf1_fra are static int variables (read/write from the corresponding fsuipc offsets) */ static int adf1_dec; static int adf1_fra; MkFsObject(FS_EXTENDEDADF1,"",EventHandler,0x0356, 2,TP_UI16,FS_NORMAL); MkFsObject(FS_ADF1FREQUENCY,"",EventHandler,0x034C, 2,TP_UI16,FS_NORMAL); case FS_ADF1FREQUENCY: ADF1 = (ADF1 / 10000) * 10000 + BCD2Int(val) * 10 + ADF1 % 10; FsbusWrite(CD_ADF_1, ADF1); if (bSynchronised == false) { ADF1Stb = ADF1; FsbusWrite(CD_ADF_1, ADF1Stb); } break; case FS_EXTENDEDADF1: ADF1 = BCD2Int(val >> 8) * 10000 + ((ADF1/10)%1000)*10 + BCD2Int(val & 0x00FF); FsbusWrite(CD_ADF_1, ADF1); if (bSynchronised == false) { ADF1Stb = ADF1; FsbusWrite(CD_ADF_1, ADF1Stb); } break; case CR_ADF_100: x = ADF1Stb / 1000; // hundreds x = x + val; // update 100s if (x > 17) x = 1; // wrap else if (x < 1) x = 17; // wrap ADF1Stb = x * 1000 + ADF1Stb % 1000; // new 100s FsbusWrite(CD_ADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); break; case CR_ADF_10: x = (ADF1Stb % 1000) / 10; // tens + units x = x + val; // update 10s if (x > 99) x = 0; // wrap else if (x < 0) x = 99; // wrap ADF1Stb = (ADF1Stb / 1000) * 1000 + x * 10 + ADF1Stb % 10; // new 10s FsbusWrite(CD_ADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); break; case CR_ADF_1: x = ADF1Stb % 10; // .1 units x = x + val; // update 10s if (x > 9) x = 0; // wrap else if (x < 0) x = 9; // wrap ADF1Stb = (ADF1Stb / 10) * 10 + x; FsbusWrite(CD_ADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); break;
Fast freestyle not tested.
Code:/* adf1_dec and adf1_fra are static int variables (read/write from the corresponding fsuipc offsets) */ static int adf1_dec; static int adf1_fra; static int adfmode=0; MkFsbusObject (BTP_ROTARY, CR_ADF,"",EventHandler, 27,32); MkFsbusObject (BTP_D_IN, C_ADFPush,"",EventHandler, 4, 55); MkFsObject(FS_EXTENDEDADF1,"",EventHandler,0x0356, 2,TP_UI16,FS_NORMAL); MkFsObject(FS_ADF1FREQUENCY,"",EventHandler,0x034C, 2,TP_UI16,FS_NORMAL); case FS_ADF1FREQUENCY: ADF1 = (ADF1 / 10000) * 10000 + BCD2Int(val) * 10 + ADF1 % 10; FsbusWrite(CD_ADF_1, ADF1); if (bSynchronised == false) { ADF1Stb = ADF1; FsbusWrite(CD_ADF_1, ADF1Stb); } break; case FS_EXTENDEDADF1: ADF1 = BCD2Int(val >> 8) * 10000 + ((ADF1/10)%1000)*10 + BCD2Int(val & 0x00FF); FsbusWrite(CD_ADF_1, ADF1); if (bSynchronised == false) { ADF1Stb = ADF1; FsbusWrite(CD_ADF_1, ADF1Stb); } break; case C_ADFPush: if(val==0) { adfmode+=1; if (adfmode>2) adfmode=0; } break; case CR_ADF: if (adfmode==0) { x = ADF1Stb / 1000; // hundreds x = x + val; // update 100s if (x > 17) x = 1; // wrap else if (x < 1) x = 17; // wrap ADF1Stb = x * 1000 + ADF1Stb % 1000; // new 100s FsbusWrite(CD_ADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); } if (adfmode==1) { x = (ADF1Stb % 1000) / 10; // tens + units x = x + val; // update 10s if (x > 99) x = 0; // wrap else if (x < 0) x = 99; // wrap ADF1Stb = (ADF1Stb / 1000) * 1000 + x * 10 + ADF1Stb % 10; // new 10s FsbusWrite(CD_ADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); } if (adfmode==1) { x = ADF1Stb % 10; // .1 units x = x + val; // update 10s if (x > 9) x = 0; // wrap else if (x < 0) x = 9; // wrap ADF1Stb = (ADF1Stb / 10) * 10 + x; FsbusWrite(CD_ADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); } break;
static int ADF1 = 0; // binary, units 0.1 KHz
static int ADF1Stb = 0; // binary, units 0.1
good luck
Stefan
-
Post Thanks / Like - 1 Thanks, 0 Likes, 0 DislikesRobiD thanked for this post
-
07-06-2009, 09:05 PM #137
Re: Progamming help with FSBus dll
Stefan,
Great. This works almost perfect.
I think it is mode 1. the 10s, 1s and .1s ie: 1448.8 (48.8) Hope this explains what I mean.
The 48 increments correctly but the .8 increments with the 8 ie: 48.8, 49.9, 50.0, 51.1.
I'm sure it's probably a little change, but other than that it works. Writes to Fsbus and FSX and FSX writes correctly to Fsbus.
Just a thought, it is possible to have mode 0, mode 1 and mode 2 (so there are three clicks ie: mode 0 for thousands and hundreds, mode 1 for tens and ones, and mode 2 for the .1 to .9)
So this is what I have now with the minor mods to keep in line with my methodology:
Code:staticint ADF1 = 0; // binary, units 0.1 KHz staticint ADF1Stb = 0; // binary, units 0.1 /* adf1_dec and adf1_fra are static int variables (read/write from the corresponding fsuipc offsets) */ staticint adf1_dec; staticint adf1_fra; staticint adfmode=0; void cbNavBuildObjects() { MkFsbusObject (BTP_ROTARY, C_RADF,"",cbNav, 27,32); MkFsbusObject (BTP_D_IN, C_ADFPush,"",cbNav, 27, 16); MkFsbusObject(BTP_DISPLAY, C_DADF_1, "",cbNav, 14, 0); DisplayOptions(C_DADF_1,5,0,TRUE,2); MkFsObject(FS_EXTENDEDADF1,"",cbNav,0x0356, 2,TP_UI16,FS_NORMAL); MkFsObject(FS_ADF1FREQUENCY,"",cbNav,0x034C, 2,TP_UI16,FS_NORMAL); } void cbNav (int oid, int val, double dval) { int x; switch (oid) { case FS_ADF1FREQUENCY: ADF1 = (ADF1 / 10000) * 10000 + BCD2Int(val) * 10 + ADF1 % 10; FsbusWrite(C_DADF_1, ADF1); if (bSynchronised == false) { ADF1Stb = ADF1; FsbusWrite(C_DADF_1, ADF1Stb); } break; case FS_EXTENDEDADF1: ADF1 = BCD2Int(val >> 8) * 10000 + ((ADF1/10)%1000)*10 + BCD2Int(val & 0x00FF); FsbusWrite(C_DADF_1, ADF1); if (bSynchronised == false) { ADF1Stb = ADF1; FsbusWrite(C_DADF_1, ADF1Stb); } break; case C_ADFPush: if(val==0) { adfmode+=1; if (adfmode>2) adfmode=0; } break; case C_RADF: if (adfmode==0) { x = ADF1Stb / 1000; // hundreds x = x + val; // update 100s if (x > 17) x = 1; // wrap elseif (x < 1) x = 17; // wrap ADF1Stb = x * 1000 + ADF1Stb % 1000; // new 100s FsbusWrite(C_DADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); } if (adfmode==1) { x = (ADF1Stb % 1000) / 10; // tens + units x = x + val; // update 10s if (x > 99) x = 0; // wrap elseif (x < 0) x = 99; // wrap ADF1Stb = (ADF1Stb / 1000) * 1000 + x * 10 + ADF1Stb % 10; // new 10s FsbusWrite(C_DADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); } if (adfmode==1) { x = ADF1Stb % 10; // .1 units x = x + val; // update 10s if (x > 9) x = 0; // wrap elseif (x < 0) x = 9; // wrap ADF1Stb = (ADF1Stb / 10) * 10 + x; FsbusWrite(C_DADF_1, ADF1Stb); x = Int2BCD(ADF1Stb); FsWrite(FS_EXTENDEDADF1, ((x & 0x0F0000) >> 8) | (x & 0x00000F)); FsWrite(FS_ADF1FREQUENCY, (x & 0x00FFF0) >> 4); } break; } }
-
07-07-2009, 12:25 AM #138
Re: Progamming help with FSBus dll
Ok, worked out what was wrong, there were two instances of mode 1, I changed the second to mode 2 and now it works like it should.
Yee haa.
Thanks as always Stefan.
I'm now going to try to do this with the Nav1
David
-
07-07-2009, 02:13 AM #139
Re: Progamming help with FSBus dll
Just completed the NAV1 radio. Use the mode method you gave me and it works great, swap works so all is good.
Just can't find an offset for the test button (not that is important).
-
07-07-2009, 02:24 AM #140
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: Progamming help with FSBus dll
That is right, this funktion dosenīt work on FS.
Similar Threads
-
Fsbus CDK
By flyandre in forum General Builder Questions All Aircraft TypesReplies: 4Last Post: 12-27-2014, 12:58 PM -
Need Help Getting My FSBUS NG I/O Going Again..
By JBRoberts in forum I/O Interfacing Hardware and SoftwareReplies: 14Last Post: 03-21-2010, 01:38 PM -
Fsbus ng io
By Davral in forum I/O Interfacing Hardware and SoftwareReplies: 0Last Post: 01-10-2009, 10:38 PM -
Fsbus 2.4.3
By Anderson/SBSP in forum I/O Interfacing Hardware and SoftwareReplies: 9Last Post: 11-30-2008, 04:25 PM -
Help FSBUS
By cesarfsim in forum I/O Interfacing Hardware and SoftwareReplies: 2Last Post: 10-26-2008, 02:23 PM
Find Prettys Girls from your town for night
Is it just me? - Upper ECAM...