Page 21 of 74 FirstFirst ... 111718192021222324253171 ... LastLast
Results 201 to 210 of 737
  1. #201
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    Thanks Stefan.

    Are those setting for the 2313's?

    David

  2. #202
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    318
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    that is right.

  3. #203
    150+ Forum Groupie


    388TH_A's Avatar
    Join Date
    Nov 2008
    Location
    Medford, Oregon (USA)
    Posts
    239
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    OK WOW i feel dumb now i should have came here first but no... in stead i have been spending a week on this and going to the library and reading books and just plain messing with C++ just to get something to work right. But if i came here i could have coped and pasted some of your guys code to get me off on a faster foot in the right direction instead of a slow one. Anyways i am only trying to get my COM1 Display to work and so far i got it to show for example in FSX the Freq is 118.00 but on the display it shows 080.00 instead. I have coped some of the code in here from the manual and also typing in things just to see if it would work. But here is my code any ideas on how i can get this to work so i can move on to getting others to work also. Thanks in advance!!!


    FSBUScockpit.cpp

    // FSBUScockpit.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"


    int _tmain(int argc, _TCHAR* argv[])
    {
    int v = GetFsbusDLLVersion ();
    if (v < 100)
    {
    printf ("Program requires Fsbus DLL version 1.0.0 or higher\r\n");
    return 1;
    }

    CheckIn();
    FsbusOpen ("COM1");

    BuildRadiostackObjects(); // TODO: add more of your individual Build.. functions HERE

    printf ("FSBUS hardware connected ...\r\n");

    FsConnect();
    printf ("Flightsim connected ...\r\n");

    //TODO: add functions to create the fsbus software objects
    printf ("press any key to exit ...\r\n");

    while (!_kbhit())
    FsbusMux(500);
    }

    //---------------------------------------------------------------------------
    void EventCallback (int oid, int val, double dval)
    {
    switch (oid & OID_GROUP_MASK)
    {
    case OID_RADIOSTACK_GROUP:
    cbRadiostack (oid, val, dval);
    // TODO: add the group handlers of your individual cockpit groups
    }
    }


    stdafx.h

    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //

    #pragma once

    #include "targetver.h"

    #include
    #include

    // TODO: reference additional headers your program requires here
    #include "fsbus.h"

    #include "radiostack.h"


    stdafx.cpp

    #include "stdafx.h"


    radiostack.cpp

    #include "stdafx.h"

    void BuildRadiostackObjects ()
    {

    MkFsbusObject (BTP_DISPLAY, C_COM1DISPLAY, "COM1DISPLAY", cbRadiostack, 1, 0);
    DisplayOptions (C_COM1DISPLAY, 5, 0, true, 3);
    MkFsObject(FS_RADIOSTACKCOM1, "COM1DISPLAY", cbRadiostack, 0x034E, 2, TP_UI16, FS_NORMAL);
    }

    void cbRadiostack (int oid, int val, double dval)
    {
    int x;
    static int COM1 = 0;

    switch (oid)
    {
    case C_COM1DISPLAY:
    x = BCD2Int(COM1);
    x += val*5;
    if (x > 13697)
    x = 13697;
    if (x < 11800)
    x = 11800;
    COM1 = Int2BCD(x);
    FsWrite (FS_RADIOSTACKCOM1, (COM1&0x0fff0) >> 4);
    FsbusWrite (C_COM1DISPLAY, x);
    break;

    case FS_RADIOSTACKCOM1:
    // main 3 digits, in Binary Coded Decimal.
    // A frequency of 1234.5 will have 0x0234 here
    // and 0x0105 in offset 0356.
    x = val;
    COM1 = (COM1 & 0xf000f) | (x << 4);
    FsbusWrite (C_COM1DISPLAY, BCD2Int(COM1));
    break;

    }
    }

    radiostack.h

    #ifndef __RADIOSTACK_H
    #define __RADIOSTACK_H

    #define OID_RADIOSTACK_GROUP (1 << OID_CONTROL_BITS)
    // any OID_xxx_GROUP should have a unique number, left shifted by OID_CONTROL_BITS

    // declaration of all (max 32) objects of this group
    #define C_COM1DISPLAY OID_RADIOSTACK_GROUP + 0
    #define FS_RADIOSTACKCOM1 OID_RADIOSTACK_GROUP + 1

    // declare the functions in the corresponding .cpp file
    void BuildRadiostackObjects();
    void cbRadiostack (int oid, int val, double dval);

    #endif

  4. #204
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    Hey Stefan,

    Hope you can find the problem here, I've spent some time going through it and comparing it to my code and I think my brain has fried.

    I know I had a similar issue at one point and resolved it. It was something simple but I can't remember what it was.

    I used the same format as my ADF and changed around the object names etc and it all worked.

    Remembering, I am using a single rotary with a push switch in it.

    Here's the base code I used for the ADF. Hope it helps a little.
    This is the .cpp 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==2)
    {
    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;
    }
    }

  5. #205
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    318
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    Quote Originally Posted by 388TH_A View Post

    radiostack.cpp

    #include "stdafx.h"

    void BuildRadiostackObjects ()
    {

    MkFsbusObject (BTP_DISPLAY, C_COM1DISPLAY, "COM1DISPLAY", cbRadiostack, 1, 0);
    DisplayOptions (C_COM1DISPLAY, 5, 0, true, 3);
    MkFsObject(FS_RADIOSTACKCOM1, "COM1DISPLAY", cbRadiostack, 0x034E, 2, TP_UI16, FS_NORMAL);
    }

    void cbRadiostack (int oid, int val, double dval)
    {
    int x;
    static int COM1 = 0;

    switch (oid)
    {
    case C_COM1DISPLAY:
    x = BCD2Int(COM1);
    x += val*5;
    if (x > 13697)
    x = 13697;
    if (x < 11800)
    x = 11800;
    COM1 = Int2BCD(x);
    FsWrite (FS_RADIOSTACKCOM1, (COM1&0x0fff0) >> 4);
    FsbusWrite (C_COM1DISPLAY, x);
    break;

    case FS_RADIOSTACKCOM1:
    // main 3 digits, in Binary Coded Decimal.
    // A frequency of 1234.5 will have 0x0234 here
    // and 0x0105 in offset 0356.
    x = val;
    COM1 = (COM1 & 0xf000f) | (x << 4);
    FsbusWrite (C_COM1DISPLAY, BCD2Int(COM1));
    break;

    }
    }
    HI,

    you have used code from ADF that is not like COM or NAV.
    Her some Code that will work.
    Code:
    case C_COM1DISPLAY:
            x = BCD2Int(COM1);
    	    x += val*5;
    		if (x > 13697)
    			x = 13697;
    		if (x < 11800)
    			x = 11800;
    		COM1 = Int2BCD(x);
    		FsWrite (FS_RADIOSTACKCOM1, COM1);
    		FsbusWrite (C_COM1DISPLAY, x);
    		break;
    But with that Code you will have problems with the 25, 50, 75, 00 order.
    Her my Code, but i use 2 encoder.
    Code:
    case C_COM1ROTARYnk:
    			comstby = BCD2Int(COM1S);
    			//x1=2, if last digit =2;
    			/***********************/
    			x2=comstby/10;
    			x2=x2*10;
    			x1=comstby-x2;
    			comstby = comstby *10;
    			if((x1==2) | (x1==7))
    			comstby+= 5;
    		    comstby += val * 25;
    			x3=comstby;
    			x3/=10;
    			comstby=x3;
    			/***********************/
    			if (comstby > 3697)
    				comstby = 3697;
    			if (comstby < 1800)			
    				comstby = 1800;
    			COM1S = Int2BCD(comstby);
    			FsbusWrite (C_COM1DisplayS, comstby+10000);
    			FsWrite (FS_COM1STANDBY, COM1S);
    		break;
    
    	case C_COM1ROTARYvk:
    			comstby = BCD2Int(COM1S);
    			comstby += val * 100;
    			if (comstby > 3697)
    				comstby = 3600 + comstby%100;
    			if (comstby < 1800){
    				comstby = 1800 + comstby%100;
    				}
    			COM1S = Int2BCD(comstby);
    			FsbusWrite (C_COM1DisplayS, comstby+10000);
    			FsWrite (FS_COM1STANDBY, COM1S);
    		break;
    Her my code for the back way FS to Hardware.
    Code:
    case FS_COM1FREQUENCY:
            // main 3 digits, in Binary Coded Decimal.
            // A frequency of 1234.5 will have 0x0234 here
            // and 0x0105 in offset 0356.
           		COM1= val;
            FsbusWrite(C_COM1DisplayA, BCD2Int(COM1)+10000);
            break;
    Stefan

  6. Thanks 388TH_A thanked for this post
  7. #206
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    318
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    Quote Originally Posted by RobiD View Post
    Hey Stefan,

    Hope you can find the problem here, I've spent some time going through it and comparing it to my code and I think my brain has fried.

    I know I had a similar issue at one point and resolved it. It was something simple but I can't remember what it was.

    I used the same format as my ADF and changed around the object names etc and it all worked.

    Remembering, I am using a single rotary with a push switch in it.

    Here's the base code I used for the ADF. Hope it helps a little.
    Hi,
    what errors do you have, i cant see a bug.
    I only find to things but i think that are only format errors in the board.
    staticint = wrong
    static int = right
    elseif = wrong
    else if = right

    If it is more, describe what error you have.

    Stefan

  8. #207
    300+ Forum Addict RobiD's Avatar
    Join Date
    Sep 2007
    Location
    Gold Coast, Australia
    Posts
    430
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    Hi Stefan,

    No, mine is working (thanks to your previous help). I put my code up to try to help 388TH_A with his COM1.

    I thought you might be able to find his problem.

    David

  9. #208
    150+ Forum Groupie


    388TH_A's Avatar
    Join Date
    Nov 2008
    Location
    Medford, Oregon (USA)
    Posts
    239
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    Thanks you SO much it help and works but when i load up the exe it resets the display shows all 00000 then shows the right freq for whats in FS. But.... i change it to one freq to another it works fine but after the 3 or 4th freq change it starts to show the wrong freq like one time i got it to so 147.35 ummm thats not right lol any ideas? and how do you guys show your code in blue like that? AND THANKS AGAIN FOR THE HELP. Im so close to moving on to Com1 Stby and then Com2 and so on








    void cbRadiostack (int oid, int val, double dval)
    {
    int x;
    static int COM1 = 0;

    switch (oid)
    {
    case C_COM1DISPLAY:
    x = BCD2Int(COM1);
    x += val*5;
    if (x > 13697)
    x = 13697;
    if (x < 11800)
    x = 11800;
    COM1 = Int2BCD(x);
    FsWrite (FS_RADIOSTACKCOM1, (COM1));
    FsbusWrite (C_COM1DISPLAY, x);
    break;

    case FS_RADIOSTACKCOM1:
    // main 3 digits, in Binary Coded Decimal.
    // A frequency of 1234.5 will have 0x0234 here
    // and 0x0105 in offset 0356.
    x = val;
    COM1 = (COM1) | (x);
    FsbusWrite (C_COM1DISPLAY, BCD2Int(COM1)+10000);
    break;

    }
    }

  10. #209
    150+ Forum Groupie


    388TH_A's Avatar
    Join Date
    Nov 2008
    Location
    Medford, Oregon (USA)
    Posts
    239
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    i just went from 126.22 and it shows that on the Display then changed it to 118.00 and it showed 144.62 ummm....

    Thanks, Trevor

  11. #210
    150+ Forum Groupie


    388TH_A's Avatar
    Join Date
    Nov 2008
    Location
    Medford, Oregon (USA)
    Posts
    239
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Progamming help with FSBus dll

    #include "stdafx.h"

    void BuildRadiostackObjects ()
    {

    MkFsbusObject (BTP_DISPLAY, C_COM1DISPLAY, "COM1DISPLAY", cbRadiostack, 1, 0);
    DisplayOptions (C_COM1DISPLAY, 5, 0, true, 3);
    MkFsObject(FS_RADIOSTACKCOM1, "COM1DISPLAY", cbRadiostack, 0x034E, 2, TP_UI16, FS_NORMAL);
    }

    void cbRadiostack (int oid, int val, double dval)
    {
    int x;
    static int COM1 = 0;

    switch (oid)
    {
    case C_COM1DISPLAY:
    x = BCD2Int(COM1);
    x += val*5;
    if (x > 13697)
    x = 13697;
    if (x < 11800)
    x = 11800;
    COM1 = Int2BCD(x);
    FsWrite (FS_RADIOSTACKCOM1, (COM1));
    FsbusWrite (C_COM1DISPLAY, x);
    break;

    case FS_RADIOSTACKCOM1:
    x = val;
    COM1 = (COM1) | (x);
    FsbusWrite (C_COM1DISPLAY, BCD2Int(COM1)+10000);
    break;

    }
    }



    Why does in FS and on the display when i first start the program show the same thing 126.22 but then when i change it to 118.00 and it showed 118.00 in FS but on the display it showed 144.62? am i missing somthing?

Similar Threads

  1. Fsbus CDK
    By flyandre in forum General Builder Questions All Aircraft Types
    Replies: 4
    Last Post: 12-27-2014, 12:58 PM
  2. Need Help Getting My FSBUS NG I/O Going Again..
    By JBRoberts in forum I/O Interfacing Hardware and Software
    Replies: 14
    Last Post: 03-21-2010, 01:38 PM
  3. Fsbus ng io
    By Davral in forum I/O Interfacing Hardware and Software
    Replies: 0
    Last Post: 01-10-2009, 10:38 PM
  4. Fsbus 2.4.3
    By Anderson/SBSP in forum I/O Interfacing Hardware and Software
    Replies: 9
    Last Post: 11-30-2008, 04:25 PM
  5. Help FSBUS
    By cesarfsim in forum I/O Interfacing Hardware and Software
    Replies: 2
    Last Post: 10-26-2008, 02:23 PM

Tags for this Thread