Sign in to follow this  
Guest

Problem with com radio and make_string

Recommended Posts

Hi Guru'sI'm trying to make a Bendix/King com radio, but I have a BIG problem.I can't manage to get the frequency (or any other string) to show up.Here is my make_string element and callback function:MAKE_STRING (com_frequency_whole, NULL, navcom1_fail, erase | bright, 0, 60, 70, 60, 30, 3, MODULE_VAR_NONE, MODULE_VAR_NONE, MODULE_VAR_NONE, RGB(255,0,0), RGB(0,0,0), RGB(92,92,92), GAUGE_FONT_DEFAULT, GAUGE_WEIGHT_DEFAULT, GAUGE_CHARSET, 0, DT_CENTER | DT_VCENTER | DT_SINGLELINE, NULL, frequency_update)FLOAT64 FSAPI frequency_update(PELEMENT_STRING pelement){ FLOAT64 val=pelement->source_var[0].var_value.n; val=!val; lookup_var(&active); //active reads the COM_FREQUENCY tokenVar wsprintf(pelement->string, "%3f", active); return val;}I've tried a LOT of different things just to get it to show anything. But no string in sight... Any help/thoughts will be higly appreciated.Lars Martinhttp://flightsimmers.net/airfield/fma

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

You have to use the .d member, not the .f member of the module var. Ther are several ways to proceed (convert BCD to decimal etc.), but for a simple display, a sprintf like this would do:sprintf(pelement->string,"1%02x.%02x",active.var_value.d/0x100,active.var_value.d%0x100);BTW wsprintf can't print floats (%...f doesn't work) and using a module var directly, and not it's members doesn't make sense.If you set the COMx_FREQUENCY in the MAKE_STRING macro the callback can be simplified to:...#include <stdio.h>...FLOAT64 FSAPI frequency_update(PELEMENT_STRING pelement){ int val = pelement->source_var<0>.var_value.d; sprintf( pelement->string,"1%02x.%02x",val/0x100,val%0x100); return val;}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this