June 22, 201015 yr Hi allI'm new at this gauge creating thing and I stumble across a problem while creating my first gauge.The gauge I'm creating is an analogue IASI with s display in the middle showing the mach number and the IAS. The mach number always shows .20 if you are below that mach number. The IAS starts counting from 60. But the strings don't show up ...Would appreciate it if anybody could help me out cause I'm stuck and my C ain't that good yet :(I've also searched on the net for some good documentation about the C language used by the gauges but haven't really found yet, so any advise on those is welcome too :).h file // DC-8 Project Super 60 gauges// Copyright (c) 2010 DC-8 Project. All rights reserved.//#define VERSION_MAJOR 1#define VERSION_MINOR 0#define VERSION_BUILD 0// magic to get the preprocessor to do what we want#define lita(arg) #arg#define xlita(arg) lita(arg)#define cat3(w,x,z) w##.##x##.##z##\000#define xcat3(w,x,z) cat3(w,x,z)#define VERSION_STRING xlita(xcat3(VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD))#ifndef VS_VERSION_INFO#define VS_VERSION_INFO 0x0001#endif///////////////////////////////////////////////////////////////////////////////// AirspeedDigital Bitmaps//#define BMP_AIRSPEED_DIGITAL_BACKGROUND 0x1000#define BMP_AIRSPEED_DIGITAL_NEEDLE 0x1100 .rc // Microsoft Visual C++ generated resource script.//#include "resource.h"#define APSTUDIO_READONLY_SYMBOLS///////////////////////////////////////////////////////////////////////////////// Generated from the TEXTINCLUDE 2 resource.//#include "afxres.h"/////////////////////////////////////////////////////////////////////////////#undef APSTUDIO_READONLY_SYMBOLS/////////////////////////////////////////////////////////////////////////////// Dutch (Belgium) resources#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLB)#ifdef _WIN32LANGUAGE LANG_DUTCH, SUBLANG_DUTCH_BELGIAN#pragma code_page(1252)#endif //_WIN32///////////////////////////////////////////////////////////////////////////////// Version//VS_VERSION_INFO VERSIONINFO FILEVERSION 0,1,0,0 PRODUCTVERSION 0,1,0,0 FILEFLAGSMASK 0x3fL#ifdef _DEBUG FILEFLAGS 0x1L#else FILEFLAGS 0x0L#endif FILEOS 0x10004L FILETYPE 0x1L FILESUBTYPE 0x0LBEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "DC-8 Project" VALUE "FileDescription", "FS2004 DC-8 Super 60 Gauge" VALUE "FileVersion", "0.1.0" VALUE "LegalCopyright", "Your Copyright." VALUE "ProductName", "DC-8 Project" VALUE "ProductVersion", "0.1.0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 ENDEND///////////////////////////////////////////////////////////////////////////////// Bitmap//BMP_AIRSPEED_DIGITAL_BACKGROUND BITMAP "res\\DC8spr60.AirspeedDigital.bg.BMP"BMP_AIRSPEED_DIGITAL_NEEDLE BITMAP "res\\DC8spr60.AirspeedDigital.Ndl.BMP"#ifdef APSTUDIO_INVOKED///////////////////////////////////////////////////////////////////////////////// TEXTINCLUDE//1 TEXTINCLUDE BEGIN "resource.\0"END3 TEXTINCLUDE BEGIN "\r\0"END#endif // APSTUDIO_INVOKED#endif // Dutch (Belgium) resources/////////////////////////////////////////////////////////////////////////////#ifndef APSTUDIO_INVOKED///////////////////////////////////////////////////////////////////////////////// Generated from the TEXTINCLUDE 3 resource.///////////////////////////////////////////////////////////////////////////////#endif // not APSTUDIO_INVOKED .c #include "..\inc\gauges.h"#include "DC8spr60.h"/////////////////////////////////////////////////////////////////////////////// Attitude/////////////////////////////////////////////////////////////////////////////#define GAUGE_NAME "Digital_ASI"#define GAUGEHDR_VAR_NAME gaugehdr_DigitalAsi#define GAUGE_W 100#include "DC8spr60.digasi.c"/////////////////////////////////////////////////////////////////////////////// Gauge table entries/////////////////////////////////////////////////////////////////////////////GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_DigitalAsi)GAUGE_TABLE_END() ASI c file // DC8Spr60.AirspeedDigital.c// Copyright (c) 2000 Microsoft Corporation. All rights reserved.// Set up gauge headerchar digasi_gauge_name[] = GAUGE_NAME;extern PELEMENT_HEADER digasi_list;extern MOUSERECT digasi_mouse_rect[];GAUGE_HEADER_FS700(GAUGE_W, digasi_gauge_name, &digasi_list,\ digasi_mouse_rect, 0, 0, 0, 0);#define GAUGE_CHARSET DEFAULT_CHARSET#define GAUGE_FONT_DEFAULT "Courier New"#define GAUGE_WEIGHT_DEFAULT FW_NORMAL/////////////////////////////////////////////////////////////////////////////FAILURE_RECORD digasi_fail[] ={ {FAIL_GAUGE_AIRSPEED, FAIL_ACTION_ZERO}, {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_ZERO}, {FAIL_NONE, FAIL_ACTION_NONE}};FAILURE_RECORD ias_fail[] ={ {FAIL_GAUGE_AIRSPEED, FAIL_ACTION_ZERO}, {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_ZERO}, {FAIL_NONE, FAIL_ACTION_NONE}};FAILURE_RECORD mach_fail[] ={ {FAIL_GAUGE_AIRSPEED, FAIL_ACTION_ZERO}, {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_ZERO}, {FAIL_NONE, FAIL_ACTION_NONE}};#define GAUGE_MIN_SPEED 60#define GAUGE_MAX_SPEED 400FLOAT64 FSAPI asi_needle_cb( PELEMENT_NEEDLE pelement ){ FLOAT64 val = pelement->source_var.var_value.n; if (val > GAUGE_MAX_SPEED) val = GAUGE_MAX_SPEED; else if (val < GAUGE_MIN_SPEED) val = GAUGE_MIN_SPEED; return val;}FLOAT64 FSAPI mach_string_cb( PELEMENT_STRING pelement ){ FLOAT64 val = pelement->source_var[0].var_value.n; if (val < 0.20) val = 0.20; else val=val; //wsprintf(pelement->string, "%3d", (UINT32)val); return val;}FLOAT64 FSAPI asi_ias_cb( PELEMENT_STRING pelement ){ FLOAT64 val = pelement->source_var[0].var_value.n; if (val > GAUGE_MAX_SPEED) val = GAUGE_MAX_SPEED; else if (val < GAUGE_MIN_SPEED) val = '---'; //wsprintf(pelement->string, "%3d", (UINT32)val); return val;}NONLINEARITY speed_nonlinearity[] ={ {{474, 131}, 0, 0}, {{513, 132}, 60, 0}, {{700, 184}, 80, 0}, {{843, 318}, 100, 0}, {{881, 506}, 120, 0}, {{829, 688}, 140, 0}, {{698, 828}, 160, 0}, {{512, 872}, 180, 0}, {{327, 829}, 200, 0}, {{193, 691}, 250, 0}, {{142, 510}, 300, 0}, {{190, 326}, 350, 0}, {{326, 187}, 400, 0}};MAKE_STRING( mach_string, NULL, mach_fail, IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY, 0, 492, 380, 70, 52, 3, MACH, MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(213,208,171), RGB(0,0,0), RGB(92,92,92), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, mach_string_cb)MAKE_STRING( ias_string, NULL, ias_fail, IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE, 0, 428, 576, 70, 52, 3, AIRSPEED, MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(213,208,171), RGB(0,0,0), RGB(92,92,92), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, asi_ias_cb)MAKE_NEEDLE( asi_needle, BMP_AIRSPEED_DIGITAL_NEEDLE, NULL, digasi_fail, IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE, 0, 510, 506, 33, 38, AIRSPEED,asi_needle_cb, speed_nonlinearity, 18 )PELEMENT_HEADER digasi_needle_list[] ={ &mach_string.header, &ias_string.header, &asi_needle.header, NULL};MAKE_STATIC( asi_background, BMP_AIRSPEED_DIGITAL_BACKGROUND, &digasi_needle_list, digasi_fail, IMAGE_USE_TRANSPARENCY, 0, 0,0)PELEMENT_HEADER digasi_list = &asi_background.header;/////////////////////////////////////////////////////////////////////////////MOUSE_BEGIN( digasi_mouse_rect, HELPID_GAUGE_AIRSPEED, 0, 0 )MOUSE_END/////////////////////////////////////////////////////////////////////////////#undef GAUGE_NAME#undef GAUGEHDR_VAR_NAME#undef GAUGE_W
June 22, 201015 yr I'm just learning a little bit about "C" so I can use the principles in xml gauges.It looks to me like the ASI c file FLOAT64 FSAPI mach_string_cb( PELEMENT_STRING pelement ) section has 0.20 Mach set as minimum to display: FLOAT64 val = pelement->source_var[0].var_value.n; if (val < 0.20) val = 0.20; else val=val; //wsprintf(pelement->string, "%3d", (UINT32)val); I'm interpreting that as: "if Mach is less than 0.20, Display 0.20, otherwise display Mach"...Don
June 22, 201015 yr I'm just learning a little bit about "C" so I can use the principles in xml gauges.It looks to me like the ASI c file FLOAT64 FSAPI mach_string_cb( PELEMENT_STRING pelement ) section has 0.20 Mach set as minimum to display:I'm interpreting that as: "if Mach is less than 0.20, Display 0.20, otherwise display Mach"...Donyep that's correct. if Mach number is lower then .20 it should display .20, otherwise it should display the current mach number. But it doesn't show anything ... :s
June 22, 201015 yr Commercial Member First... you commented out where it actually creates the strings for display://wsprintf(pelement->string, "%3d", (UINT32)val);Second... those are formating integer values, which won't work for float values. Ed Wilson Mindstar AviationMy Playland - I69
June 22, 201015 yr Commercial Member Don't use 'stacked' PELEMENT headers PELEMENT_HEADER digasi_needle_list[] ={ &mach_string.header, &ias_string.header, &asi_needle.header, NULL}; - I can guarantee you're storing up trouble for yourself as you get better at this game. For further info on this - and gauge design in general - search sd2gau29.zip in the Avsim or Flightsim libraries.Also, your problem is here;- //wsprintf(pelement->string, "%3d", (UINT32)val); You do need that print command but it should say sprintf(pelement->string, "%0.3f", val); MACH is returned as a float and is always less than one (unless you are supersonic). Better still - but it depends on your version of Visual Studio - you should consider using the security verisons of commands such as s_sprintf instead of sprintf. -Dai
June 22, 201015 yr Great, thx for the help so farnew code looks like this, but now my needle doesn't show up any more :( And the mach number the string is showing is way off ... While I should be at .50 the string shows me 801 for instance ... // DC8Spr60.AirspeedDigital.c// Copyright (c) 2000 Microsoft Corporation. All rights reserved.// Set up gauge headerchar digasi_gauge_name[] = GAUGE_NAME;extern PELEMENT_HEADER digasi_list;extern MOUSERECT digasi_mouse_rect[];GAUGE_HEADER_FS700(GAUGE_W, digasi_gauge_name, &digasi_list,\ digasi_mouse_rect, 0, 0, 0, 0);#define GAUGE_CHARSET DEFAULT_CHARSET#define GAUGE_FONT_DEFAULT "Courier New"#define GAUGE_WEIGHT_DEFAULT FW_NORMAL/////////////////////////////////////////////////////////////////////////////FAILURE_RECORD digasi_fail[] ={ {FAIL_GAUGE_AIRSPEED, FAIL_ACTION_ZERO}, {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_ZERO}, {FAIL_NONE, FAIL_ACTION_NONE}};FAILURE_RECORD ias_fail[] ={ {FAIL_GAUGE_AIRSPEED, FAIL_ACTION_ZERO}, {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_ZERO}, {FAIL_NONE, FAIL_ACTION_NONE}};FAILURE_RECORD mach_fail[] ={ {FAIL_GAUGE_AIRSPEED, FAIL_ACTION_ZERO}, {FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_ZERO}, {FAIL_NONE, FAIL_ACTION_NONE}};#define GAUGE_MIN_SPEED 0#define GAUGE_MAX_SPEED 400FLOAT64 FSAPI asi_needle_cb( PELEMENT_NEEDLE pelement ){ FLOAT64 val = pelement->source_var.var_value.n; if (val > GAUGE_MAX_SPEED) val = GAUGE_MAX_SPEED; else if (val < 60) val = GAUGE_MIN_SPEED; return val;}FLOAT64 FSAPI mach_string_cb( PELEMENT_STRING pelement ){ FLOAT64 val = pelement->source_var[0].var_value.n; if (val < 0.20) val = 0.20; else val=val; sprintf(pelement->string, "%0.3f", val); return val;}FLOAT64 FSAPI asi_ias_cb( PELEMENT_STRING pelement ){ FLOAT64 val = pelement->source_var[0].var_value.n; if (val > GAUGE_MAX_SPEED) val = GAUGE_MAX_SPEED; else if (val < GAUGE_MIN_SPEED) val = '---'; sprintf(pelement->string, "%3d", (UINT32)val); return val;}NONLINEARITY speed_nonlinearity[] ={ {{474, 131}, 0, 0}, {{513, 132}, 60, 0}, {{700, 184}, 80, 0}, {{843, 318}, 100, 0}, {{881, 506}, 120, 0}, {{829, 688}, 140, 0}, {{698, 828}, 160, 0}, {{512, 872}, 180, 0}, {{327, 829}, 200, 0}, {{193, 691}, 250, 0}, {{142, 510}, 300, 0}, {{190, 326}, 350, 0}, {{326, 187}, 400, 0}};MAKE_NEEDLE( asi_needle, BMP_AIRSPEED_DIGITAL_NEEDLE, NULL, digasi_fail, IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE, 0, 510, 506, 33, 38, AIRSPEED,asi_needle_cb, speed_nonlinearity, 18 )PELEMENT_HEADER asi_needle_list[] ={&asi_needle.header,NULL};MAKE_STRING( mach_string, NULL, mach_fail, IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY, 0, 492, 380, 140, 80, 3, MACH, MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(213,208,171), RGB(0,0,0), RGB(92,92,92), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, mach_string_cb)PELEMENT_HEADER mach_string_list[] ={&mach_string.header,NULL};/*MAKE_STRING( ias_string, NULL, ias_fail, IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE, 0, 428, 576, 180, 70, 3, AIRSPEED, MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(213,208,171), RGB(0,0,0), RGB(92,92,92), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, asi_ias_cb)PELEMENT_HEADER ias_string_list[] ={&ias_string.header,NULL};*/MAKE_STATIC( asi_background, BMP_AIRSPEED_DIGITAL_BACKGROUND, mach_string_list, digasi_fail, IMAGE_USE_TRANSPARENCY, 0, 0,0)PELEMENT_HEADER digasi_list = &asi_background.header;/////////////////////////////////////////////////////////////////////////////MOUSE_BEGIN( digasi_mouse_rect, HELPID_GAUGE_AIRSPEED, 0, 0 )MOUSE_END/////////////////////////////////////////////////////////////////////////////#undef GAUGE_NAME#undef GAUGEHDR_VAR_NAME#undef GAUGE_W you might notice that I commented the IAS string because I'm still trying to find out how to make this: sprintf(pelement->string, "%0.3f", val); work for IASand s_sprintf doesn't work, undeclared identifier ...EDIT: got the needle back to work
June 22, 201015 yr Commercial Member Do you know how to program in C/C++ to begin with? Ed Wilson Mindstar AviationMy Playland - I69
June 22, 201015 yr Do you know how to program in C/C++ to begin with?very basic Cthat's why I placed this in the first post:Would appreciate it if anybody could help me out cause I'm stuck and my C ain't that good yet ohmy.gifI've also searched on the net for some good documentation about the C language used by the gauges but haven't really found yet, so any advise on those is welcome too
June 22, 201015 yr Commercial Member Seriously - download sd2gau29.zip. It will answer a lot of your questions, plus a few you didn't even think of yet.-Dai[Edit] s_sprintf is not included in your version of Visual Studio. I guess you are using VS2003.
June 22, 201015 yr Commercial Member sprintf is used to format strings. Use of the help file, or a search of the internet would be a great deal of help for you in understanding how to use it: http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ Ed Wilson Mindstar AviationMy Playland - I69
June 22, 201015 yr already got that creating C-gauges file open and using it since the beginning.using VS2008 Pro (got it from school)
June 22, 201015 yr Moderator As I already stated as FS-Developer, the MACH variable in FS doesn't actually return a "mach value" at all... MACH, // mach, 64k=3.2 mach (would be better as UIF32) That's why there's a macro to convert the FS return to "mach": #define FS_MACH(val) (val*3.2/65536.0) Alternatively, you could simply use this FS variable instead: BARBER_POLE_MACH, // real mach Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
June 22, 201015 yr Commercial Member BARBER_POLE_MACH is Mmo... not current mach. Ed Wilson Mindstar AviationMy Playland - I69
June 23, 201015 yr Commercial Member Mach speed FLOAT64 tempval = 0.0;lookup_var (&mach); //module var MACHtempval = mach.var_value.n;machind = (UINT32)(tempval / 20.480);sprintf(pelement->string, "%03d", machind); Airspeed lookup_var (&ias); //module var AIRSPEEDsprintf(pelement->string, "%03d", (int)ias.var_value.n); -Dai
Create an account or sign in to comment