P3D v4 C-Gauge: MAKE_MOVING - Displays, but doesn't move.

#1
Hey All,

I'm basically brand new to aircraft development... and I'm not sure what I'm missing. I can get MAKE_SLIDER to work, but I can't get MAKE_MOVING to work. It shows up in the correct place (with it's mask); but is static.

I've verified the callback function is being called, and is returning the correct value.

C++:
#pragma region "ASI Tape"
FLOAT64 FSAPI asi_tapex_cb(PELEMENT_MOVING_IMAGE pelement) {
    return 0.0;
}
FLOAT64 FSAPI asi_tapey_cb(PELEMENT_MOVING_IMAGE pelement) {
    FLOAT64 val = pelement->source_var_y.var_value.n;
    if (val >= 0) {
        return val;
    }
    else {
        return 0.0;
    }
}
MAKE_MOVING(asi_tape,
    ASI_TAPE,
    NULL,
    NULL,
    IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY,
    0,
    75, 550 - 3275,
    MODULE_VAR_NONE, asi_tapex_cb,
    0.0,0.0,
    AIRSPEED, asi_tapey_cb,
    0.0, 2500.0)
#pragma endregion
 
Last edited:

ddawson

Resource contributor
#2
You have specified an origin point for the element of {75,-2725} This is above the gauge bitmap.
As airspeed increases, the tape will move downwards.
I rather expect that you want to specify {75,550} as your origin, and have the callback function return the negative of your airspeed, in order to have the tape move upwards from the the 550 origin value.
Sorry I don't have a block of working source code for you on this. I just rebuilt my system over the weekend and virtually nothing is re-installed yet... :confused:
 
#3
So that's actually the direction I want the image to move. As the image moves down, the airspeed increases, similar to a boeing / airbus style PFD. It does show up in the right spot (starting at 0), and the return call is giving back a positive number, which should move the gauge down (as desired). The confusing part to me is the gauge doesn't move at all... it's permanently stuck at 0 regardless of the callback return (I've tried changing directions and such, but it never moves).

I've never done anything with D2D... but the further I get into this the more I think I should just start learning that method instead...

Thanks for the help!

Capture.PNG
 

n4gix

Resource contributor
#4
Here is an example of a "MOVING" in one of my working gauges (EDM700 EGT/CHT gauge). The moving element rises from the bottom:

C++:
FLOAT64 FSAPI EDM700_L_callback12( PELEMENT_MOVING_IMAGE pelement)
{
    FLOAT64 rwertX=pelement->source_var_x.var_value.n;
    FLOAT64 rwertY=pelement->source_var_y.var_value.n;
    rwertY = (float)eng1_cyl2_egt * 1.2 ;
    if ( panlights == 1 ) { LIGHT_IMAGE(pelement) ; } else { DARKEN_IMAGE(pelement) ; }
    if ( MASTER_BATTERYvar.var_value.n == 1 ) { SHOW_IMAGE(pelement) ; } else { HIDE_IMAGE(pelement) ; }
    return rwertX;
}
FLOAT64 FSAPI EDM700_L_callbackS12( PELEMENT_MOVING_IMAGE pelement)
{
    FLOAT64 rwertY=pelement->source_var_y.var_value.n;
    FLOAT64 rwertX=pelement->source_var_x.var_value.n;
    rwertY = (float)eng1_cyl2_egt * 1.2 ;
    if ( panlights == 1 ) { LIGHT_IMAGE(pelement) ; } else { DARKEN_IMAGE(pelement) ; }
    if ( MASTER_BATTERYvar.var_value.n == 1 ) { SHOW_IMAGE(pelement) ; } else { HIDE_IMAGE(pelement) ; }
    return rwertY;
}


MAKE_MOVING(EDM700_L_Moving12,Rec2,&EDM700_L_ElementList13,NULL,
            IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,125,120,
            MODULE_VAR_NONE,EDM700_L_callback12,0,0,
            MODULE_VAR_NONE,EDM700_L_callbackS12,0,1900)
PELEMENT_HEADER EDM700_L_ElementList14[] = {
    &EDM700_L_Moving12.header,
    NULL
};
Nota bene: This code was developed in my earliest days and was largely generated by the ancient programmer's tool called "Easy Gauge". As a result, the structure is based on a rather generic template, to account for either x or y movement depending on the "programmer's" needs. The only reason for posting this is because it does work, and perhaps might help identify why your code is failing. :coffee:
 

JB3DG

Resource contributor
#5
I've never done anything with D2D... but the further I get into this the more I think I should just start learning that method instead...
Better off learning GDI+ and combining it with the multi threading technique in the D2D sample on in the resources section. The MSDN GDI+ gauge example is also there.
 
#6
Thanks for the example. I've actually copied yours into my code piece by piece (replacing variables and such as necessary to make it valid), and the gauge is still completely static for me... Which implies it's not in this part of my code, but somehow I've got something else causing that gauge to be static. Weirdly if I change it over to a MAKE_SLIDER it works fine (although without the mask to make it look correct)... so I'm completely at a loss here.

Thanks for the advice on GDI+... I'll go start looking into that side of it. I've been making decent progress with this method; but random issues like this are definitely frustrating! And I'm already seeing I'm going to run into issues in the future for some of the things I want to implement being royal pains with this setup anyway. Onto more learning!
 

DragonflightDesign

Resource contributor
#7
Do your tape and your mask have sequential resource numbers in the header file? It not, it won't work e.g.
Code:
#define myTape       0x1500
#define myTapeMask   0x1501
 

JB3DG

Resource contributor
#8
Thanks for the example. I've actually copied yours into my code piece by piece (replacing variables and such as necessary to make it valid), and the gauge is still completely static for me... Which implies it's not in this part of my code, but somehow I've got something else causing that gauge to be static. Weirdly if I change it over to a MAKE_SLIDER it works fine (although without the mask to make it look correct)... so I'm completely at a loss here.

Thanks for the advice on GDI+... I'll go start looking into that side of it. I've been making decent progress with this method; but random issues like this are definitely frustrating! And I'm already seeing I'm going to run into issues in the future for some of the things I want to implement being royal pains with this setup anyway. Onto more learning!
Urm....The GDI+/D2D examples only use a MAKE_STATIC image. Any moving elements are not going to be the FS gauge macros, but rather something you do in your GDI+ calls.
 

n4gix

Resource contributor
#9
Do your tape and your mask have sequential resource numbers in the header file? It not, it won't work e.g.
Code:
#define myTape       0x1500
#define myTapeMask   0x1501
Good call on sequential resource numbers:

From my .rc file:
C++:
Rec2       BITMAP  DISCARDABLE     "res\\EGT1_bar.BMP"
Rec3       BITMAP  DISCARDABLE     "res\\EGT1_mask.BMP"
Rec4       BITMAP  DISCARDABLE     "res\\CHTBarGraph.bmp"
Rec5       BITMAP  DISCARDABLE     "res\\CHTBarGraph_mask.bmp"
From my .h file:
C++:
#define  Rec2 0x1200
#define  Rec3 0x1201
#define  Rec4 0x1500
#define  Rec5 0x1501
 
#10
Thanks for the example. I've actually copied yours into my code piece by piece (replacing variables and such as necessary to make it valid), and the gauge is still completely static for me... Which implies it's not in this part of my code, but somehow I've got something else causing that gauge to be static. Weirdly if I change it over to a MAKE_SLIDER it works fine (although without the mask to make it look correct)... so I'm completely at a loss here.

Thanks for the advice on GDI+... I'll go start looking into that side of it. I've been making decent progress with this method; but random issues like this are definitely frustrating! And I'm already seeing I'm going to run into issues in the future for some of the things I want to implement being royal pains with this setup anyway. Onto more learning!
I did that C++ coding (MAKE_stuff ) at very first as FSX SDK guide and used @DragonflightDesign C++ tutorial . it just like XML coding (using image manipulation) in general. it easy to do but lot of work by, create an image, insert and build a code in C++.
@JB3DG introduce about GDI+, yes it bit hard at first because at first it start from image base for coding and turn to full code when create gauge in GDI+.
now, I not look anymore at C++ as per SDK guide. feel more comfortable and it have wider way to manipulate gauge in GDI+ (eventhough it still in C++). :)
 
Top