• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Built in lighting

Messages
70
Country
unitedkingdom
Hey,

I have been working on adding in the built in lighting to my gauge using our bible created by dragon flight :)
I am a little confused and stuck with the following problem
http://prntscr.com/kae3uk

From what I have learned its not linking correctly and thus I am getting the error. I have confused myself and not sure on how to fix it. (I may be doing it wrong or going about it in the wrong way)
My code snippet is below. Would anybody mind having a nosy and let me know how to fix it?

Code:
void FSAPI com1_update(PGAUGEHDR pgauge, int service_id, UINT32 extra_data)
{
    switch (service_id)
    {
        /* "install_routine()" */

    case    PANEL_SERVICE_PRE_INSTALL:
        break;

        /* "initialize_routine()" */

    case    PANEL_SERVICE_PRE_INITIALIZE:

        break;

        /* "update_routine()" */

    case    PANEL_SERVICE_PRE_UPDATE:

        if (power_on > 0)
        {
            //Remove all lighting flags.
            DARKEN_LISTELEMENT(pgauge->elements_list[0], 1);
            DARKEN_LISTELEMENT(pgauge->elements_list[0], 2);
            DARKEN_LISTELEMENT(pgauge->elements_list[0], 3);
            DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 1);
            DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 2);
            DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 3);

            if (dimbrt == 1)
            {
                //sets backlighting to dim.
                LUMINOUS_LISTELEMENT(pgauge->elements_list[0], 1);
                LUMINOUS_LISTELEMENT(pgauge->elements_list[0], 2);
                LUMINOUS_LISTELEMENT(pgauge->elements_list[0], 3);

            }
            else
                if (dimbrt == 2)
                {
                    //set backligting to bright.
                    LIGHT_LISTELEMENT(pgauge->elements_list[0], 1);
                    LIGHT_LISTELEMENT(pgauge->elements_list[0], 2);
                    LIGHT_LISTELEMENT(pgauge->elements_list[0], 3);
                }

        }
        else
        {
            //if no power turn off lighting.
            DARKEN_LISTELEMENT(pgauge->elements_list[0], 1);
            DARKEN_LISTELEMENT(pgauge->elements_list[0], 2);
            DARKEN_LISTELEMENT(pgauge->elements_list[0], 3);
            DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 1);
            DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 2);
            DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 3);
        }
        break;
    }
}

//-----------------------------------------------------------
//            Image draw parameters
//-----------------------------------------------------------
MAKE_STRING
    (
        com1_active_7seg,
        NULL,
        &com1_fail,
        IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
        0,
        100, 175,
        80, 50,
        5,
        MODULE_VAR_NONE,
        MODULE_VAR_NONE,
        MODULE_VAR_NONE,
        bright_red,
        trans_black,
        bright_yellow,
        dseg7,
        normal,
        GAUGE_CHARSET,
        0,
        NULL,
        NULL,
        com1_active_cb
    )

PELEMENT_HEADER        com1_active_7seg_list[] =
{
    &com1_active_7seg.header,
    NULL
};

MAKE_STRING
(
    com1_stby_7seg,
    &com1_active_7seg_list,
    &com1_fail,
    IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
    0,
    100, 175,
    80, 50,
    5,
    MODULE_VAR_NONE,
    MODULE_VAR_NONE,
    MODULE_VAR_NONE,
    bright_red,
    trans_black,
    bright_yellow,
    dseg7,
    normal,
    GAUGE_CHARSET,
    0,
    NULL,
    NULL,
    com1_stby_cb
)

PELEMENT_HEADER        com1_stby_7seg_list[] =
{
    &com1_stby_7seg.header,
    NULL
};

MAKE_ICON
(
    com1_night,
    BMP_COM1_NIGHT,
    &com1_active_7seg_list,
    NULL,
    IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
    0,
    0, 0,
    MODULE_VAR_NONE,lightstate_cb,
    NULL,
    1,
    0,
    0
)

PELEMENT_HEADER com1_night_list[] =
{
    &com1_night.header,
    NULL
};

MAKE_STATIC
    (
        com1_background,
        BMP_COM1_BACKGROUND,
        &com1_night,
        &com1_fail,
        IMAGE_USE_TRANSPARENCY,
        0,
        0, 0
    )

PELEMENT_HEADER com1_list = &com1_background.header;
 

DragonflightDesign

Resource contributor
Messages
1,082
Country
northernireland
Two problems:-

The error is complaining that it can't find the additional XXXX_LISTELEMENT lighting macros.

1a. If this is FSX you haven't included fsxgauges_sp2.h
1b. If this is P3Dv4 you haven't included gauge_extensions.h

2. The MAKE_STATIC is not linked to com1_night_list, although that would not have thrown a compile error

Also, you can simplify the illumination switching code - turn everything off first and then turn only only what is required. It saves a complete code block. For power_on, you just need to know that it isn't zero, not that it is greater than zero.

Code:
void FSAPI com1_update(PGAUGEHDR pgauge, int service_id, UINT32 extra_data)
{
    switch (service_id)
    {
        /* "install_routine()" */

    case    PANEL_SERVICE_PRE_INSTALL:
        break;

        /* "initialize_routine()" */

    case    PANEL_SERVICE_PRE_INITIALIZE:

        break;

        /* "update_routine()" */

    case    PANEL_SERVICE_PRE_UPDATE:

        //Remove all lighting flags.
        DARKEN_LISTELEMENT(pgauge->elements_list[0], 1);
        DARKEN_LISTELEMENT(pgauge->elements_list[0], 2);
        DARKEN_LISTELEMENT(pgauge->elements_list[0], 3);
        DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 1);
        DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 2);
        DELUMINOUS_LISTELEMENT(pgauge->elements_list[0], 3);
        
        if (power_on)
        {
            if (dimbrt == 1)
            {
                //sets backlighting to dim.
                LUMINOUS_LISTELEMENT(pgauge->elements_list[0], 1);
                LUMINOUS_LISTELEMENT(pgauge->elements_list[0], 2);
                LUMINOUS_LISTELEMENT(pgauge->elements_list[0], 3);

            }
            if (dimbrt == 2)
            {
            //set backligting to bright.
              LIGHT_LISTELEMENT(pgauge->elements_list[0], 1);
              LIGHT_LISTELEMENT(pgauge->elements_list[0], 2);
              LIGHT_LISTELEMENT(pgauge->elements_list[0], 3);
            }
        }
        break;
    }
}

//-----------------------------------------------------------
//            Image draw parameters
//-----------------------------------------------------------
MAKE_STRING
    (
        com1_active_7seg,
        NULL,
        &com1_fail,
        IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
        0,
        100, 175,
        80, 50,
        5,
        MODULE_VAR_NONE,
        MODULE_VAR_NONE,
        MODULE_VAR_NONE,
        bright_red,
        trans_black,
        bright_yellow,
        dseg7,
        normal,
        GAUGE_CHARSET,
        0,
        NULL,
        NULL,
        com1_active_cb
    )

PELEMENT_HEADER        com1_active_7seg_list[] =
{
    &com1_active_7seg.header,
    NULL
};

MAKE_STRING
(
    com1_stby_7seg,
    &com1_active_7seg_list,
    &com1_fail,
    IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
    0,
    100, 175,
    80, 50,
    5,
    MODULE_VAR_NONE,
    MODULE_VAR_NONE,
    MODULE_VAR_NONE,
    bright_red,
    trans_black,
    bright_yellow,
    dseg7,
    normal,
    GAUGE_CHARSET,
    0,
    NULL,
    NULL,
    com1_stby_cb
)

PELEMENT_HEADER        com1_stby_7seg_list[] =
{
    &com1_stby_7seg.header,
    NULL
};

MAKE_ICON
(
    com1_night,
    BMP_COM1_NIGHT,
    &com1_active_7seg_list,
    NULL,
    IMAGE_USE_ERASE | IMAGE_USE_BRIGHT | IMAGE_USE_TRANSPARENCY,
    0,
    0, 0,
    MODULE_VAR_NONE,lightstate_cb,
    NULL,
    1,
    0,
    0
)

PELEMENT_HEADER com1_night_list[] =
{
    &com1_night.header,
    NULL
};

MAKE_STATIC
    (
        com1_background,
        BMP_COM1_BACKGROUND,
        &com1_night_list,
        &com1_fail,
        IMAGE_USE_TRANSPARENCY,
        0,
        0, 0
    )

PELEMENT_HEADER com1_list = &com1_background.header;
 
Messages
70
Country
unitedkingdom
Thank you for the input

I relised I didnt link the MAKE STATIC with com1_night and sorted that out when I was reading through my code.

I have definitely included fsxgauges_sp2.h in my main cpp file. (also removed it from my project and put it back in to make sure it was not corrupted somehow)
I am building for P3D v3 would I need the gauge_extensions.h for this version too?

I may try the other way of lighting just to play around with my options lol

Daniel
 

DragonflightDesign

Resource contributor
Messages
1,082
Country
northernireland
gauge_extensions.h was built for P3Dv4 onwards; fsxgauges_sp2.h should be okay. What's bothering me is that the gauge macros are being recognised but the imagedata LISTELEMENTS are not, yet they are in the same header file. It's almost as if fsxgauges_sp2.h has had those lines deleted. Try removing fsxgauges_sp2.h and adding in the original P3Dv3 gauges.h file. At the top of the gauges.h file add

#include "gauge_extensions.h"

and make sure that the gauge_extensions.h file is in the same folder as the gauges.h file.
 
Messages
70
Country
unitedkingdom
That is what had me thinking, so I went into the header file and searched for listelements and they are there.
http://prntscr.com/katjec

the rest of my code has no problems looking at the header file it just seems to be listelements.

I will PM you the link to my github with the source code too for you to ponder over when you have time.
 

DragonflightDesign

Resource contributor
Messages
1,082
Country
northernireland
Okay... I've taken a look at your source code and there's a few problems. The biggest one - and the cause of your grief - is that you haven't included dragonflight.h which contains calls to a lot of other header files.

In the Solution Explorer remove the windsaloft.h file

In your shorts.cpp file:

1. Remove #include "fsxgauges_sp2.h"
2. Add #include "dragonflight.h" (it's in the sd2gau \source code folder but it's not in your project)
3. (Optional) Comment out #include "module_vars.h" in dragonflight.h

In the shorts.h file add the missing bitmap definitions

// Comm1
#define BMP_COM1_BACKGROUND 0x0001
#define BMP_COM1_NIGHT 0x0002


In shorts.oil.cpp you have object declarations inside a CASE statement. VS2010 might allow it but it's not a good idea and I'd very strongly recommend updating to the VS2015 Community Edition, unless the P3Dv2 SDK specifies that you must use VS2010. In either case, cut

//timer Init
int maxTime = 15 * 60;
time(&timer);
double mins = difftime(timer, maxTime);


from inside the case PANEL_SERVICE_PRE_UPDATE and paste it above the switch(service_id) statement

The project should now compile, with the exception that you might (depending on VS) get a 'label redefined' error for ENGINE1_ON_FIRE and ENGINE1_FUEL_PUMP_ON. It looks like you might be missing an enumeration somewhere.

//Will need to program a new way of shutting down engine that can not be restarted.

Easy. Create an event handler and trap the KEY_TOGGLE_STARTER events. Also, set the fuel pump to permanently off. It's very difficult to seize a PT67R (unless you totally destroy the engine), so don't forget to feather the prop. I've got a PT67R maintenance manual somewhere but because I want to look at it, of course I can't find it. :rotfl:
 

ddawson

Resource contributor
Messages
862
Country
canada
...
//Will need to program a new way of shutting down engine that can not be restarted.

Easy. Create an event handler and trap the KEY_TOGGLE_STARTER events. Also, set the fuel pump to permanently off. It's very difficult to seize a PT67R (unless you totally destroy the engine), so don't forget to feather the prop. I've got a PT67R maintenance manual somewhere but because I want to look at it, of course I can't find it. :rotfl:

There are events to fail the engines.
 
Messages
70
Country
unitedkingdom
Dai you sir are a legend,

thank you for looking at my source so quickly too.

I have made the changes stated above, and I am still getting the LNK2019 error message from my original first post. :banghead:

I was looking in the fsxgauges_sp2.h file again and noticed LIGHT_LISTELEMENT and DARKEN_LISTELEMENT was declared twice.
http://prntscr.com/kbatqh

Thought maybe that was throwing the compiler off so deleted the second one, this tho did not work.

went over your directions agian to double check and I can confirm that dragonflight.h is in my project now
http://prntscr.com/kbbdgp

full output (i am aware of the warnings and will fix them)
Code:
1>------ Rebuild All started: Project: Shorts360, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(368,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>  Shorts.cpp
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\verrsrc.h(18): warning C4005: 'VS_VERSION_INFO': macro redefinition
1>  c:\users\admin\desktop\aircraft dev\panel design\c++ panels\shorts_360 panel\Short.h(17): note: see previous definition of 'VS_VERSION_INFO'
1>c:\users\admin\desktop\aircraft dev\panel design\c++ panels\shorts_360 panel\short.Voltmeter.cpp(132): warning C4002: too many actual parameters for macro 'MAKE_ICON'
1>c:\users\admin\desktop\aircraft dev\panel design\c++ panels\shorts_360 panel\Short.Oil.cpp(12): warning C4002: too many actual parameters for macro 'GAUGE_HEADER_FS700'
1>c:\users\admin\desktop\aircraft dev\panel design\c++ panels\shorts_360 panel\Short.Oil.cpp(158): warning C4553: '==': operator has no effect; did you intend '='?
1>c:\users\admin\desktop\aircraft dev\panel design\c++ panels\shorts_360 panel\Short.Prop_RPM.cpp(31): warning C4005: 'MAX_RPM': macro redefinition
1>  c:\users\admin\desktop\aircraft dev\panel design\c++ panels\shorts_360 panel\Shorts.RpmPct.cpp(32): note: see previous definition of 'MAX_RPM'
1>     Creating library .\Shorts360.lib and object .\Shorts360.exp
1>Shorts.obj : error LNK2019: unresolved external symbol _add_imagedata_to_listelement@12 referenced in function "void __stdcall com1_update(struct GAUGEHDR *,int,unsigned int)" (?com1_update@@YGXPAUGAUGEHDR@@HI@Z)
1>Shorts.obj : error LNK2019: unresolved external symbol _remove_imagedata_from_listelement@12 referenced in function "void __stdcall com1_update(struct GAUGEHDR *,int,unsigned int)" (?com1_update@@YGXPAUGAUGEHDR@@HI@Z)
1>.\Shorts360.dll : fatal error LNK1120: 2 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

I am definitely going to have to pick at your brains to up my skills in C/C++ at some point in the future :stirthepo.

If you ever come across that maintenance manual I would love to have a look at it. I was talking to a cargo airline in the states and the chief engineer was kind enough to send me a copy of the flight manual, which is very handy.

Daniel
 

DragonflightDesign

Resource contributor
Messages
1,082
Country
northernireland
Daniel: Are you using VS2010? And if you check, you've just removed the LUMINOUS macros.

Doug: thanks for the reminder :)
 
Last edited:
Messages
70
Country
unitedkingdom
I fixed the problem, I needed to include gauges.extenstions.h like a noob i forgot to un-comment it last night. suppose that's the problem, you get worked up with why its not working you can miss the obvious stuff.
 

DragonflightDesign

Resource contributor
Messages
1,082
Country
northernireland
It happens. I forgot to add a gauge to the export table recently and spent almost an hour trying to find out why it wouldn't display.
 
Top