Jump to content

Sign in to follow this  
Guest

Problem with com radio and make_string

Recommended Posts

Guest

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
Guest bartels

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...