Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FLOAT64 to wstring

Featured Replies

When you use some code like this: FLOAT64 freq; execute_calculator_code("(A:ADF STANDBY FREQUENCY:1, KHz)", &freq, NULL, NULL);to read the ADF freq, what are you then doing to get it into text?If the ADF is tuned to say 315.0, what is in the FLOAT64?

  • Moderator

Patrick, the benefit of using this method to fetch the ADF frequency is that the return is in KHz, and therefore needs no BCD to DEC conversion... ;)Here is a code segment from my Honewell RTU, which features 2 ADF memory slots.fron the Honeywell_RTU.h file, the variables used://////////////////////////////////////////FLOAT64 adf1_frequency = 0;FLOAT64 ADF_MemA = 0;FLOAT64 ADF_MemB = 500; // defaults to 500 KHz???bool AdfFlag = false;int adf1_freq_high_carry = 0;//////////////////////////////////////////from the functions.cpp file:execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1, KHz)",&adf1_frequency,NULL,NULL);if (AdfFlag == false) { ADF_MemA = adf1_frequency; }if (AdfFlag == true) { ADF_MemB = adf1_frequency; }char cString[8] = ""; sprintf(cString, "%07.2f", adf1_frequency); // since the character "0" is ascii code 48, // then subtracting 48 from the character code of // the desired character gives us the numeric equivalent. adf1_freq_high_carry = cString[2] - 48;//////////////////////////////////////////and, in case you're wondering what the devil the adf1_freq_high_carry is used for, here's a snip from the Honeywell_RTU_MouseFunctions.cpp file. This allows my "universal knob" to keep track of the decimal rollover:////////////////////////////////////////// if ( ( pagebutton == 1 && Pg1SelectCurs == 9 && dimbutton == 0 ) || ( pagebutton == 8 && Pg8SelectCurs == 7 && dimbutton == 0 ) ) { if (rtuthousandsknob == 1) { trigger_key_event (KEY_ADF_10_INC,0); if (adf1_freq_high_carry == 9) { trigger_key_event(KEY_ADF_100_INC,0); } rtuthousandsknob = 0; PageTimer = 0; } if (rtuthousandsknob == -1) { trigger_key_event (KEY_ADF_10_DEC,0); if (adf1_freq_high_carry == 0) { trigger_key_event(KEY_ADF_100_DEC,0); } rtuthousandsknob = 0; PageTimer = 0; } }

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Paradoxically, I don't mind the BCD stuff. =)But, I can't get at the ADF freq's without the XML vars, so I'm stuck trying to use that method.I'll try this:wstring RadioPage::GetAdf1Active(){ FLOAT64 freq; WCHAR freqStr[8] = {0}; execute_calculator_code("(A:ADF ACTIVE FREQUENCY:1, KHz)", &freq, NULL, NULL); swprintf_s(freqStr, 8, L"%07.2f", freq); return freqStr;}For the COM freq's I'm using this:wstring RadioPage::GetCom1Active(){ lookup_var(&m_com_frequency); lookup_var(&m_com_radio_25_khz_tunable); UINT32 bcd = m_com_frequency.var_value.d; m_Com1Freq[0] = '1'; m_Com1Freq[1] = ((bcd >> 12) & 0xF) + 0x30; m_Com1Freq[2] = ((bcd >> 8) & 0xF) + 0x30; m_Com1Freq[3] = '.'; m_Com1Freq[4] = ((bcd >> 4) & 0xF) + 0x30; m_Com1Freq[5] = ((bcd) & 0xF) + 0x30; if(m_Com1Freq[5] == '2' || m_Com1Freq[5] == '7') { m_Com1Freq[6] = '5'; m_Com1Freq[7] = '0'; // NULL Terminator } else { m_Com1Freq[6] = '0'; // NULL Terminator } m_Com1Freq[7] = '0'; // NULL Terminator wstring wstr = m_Com1Freq; return wstr;}Which is fine. Sometime I'll profile the alternate method and see which is faster.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.