MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / sprintf_freq

Function sprintf_freq

src/misc.c:384–421  ·  view source on GitHub ↗

* \brief Pretty print a frequency * \param str for result (may need up to 17 char) * \param freq input in Hz * * rig_freq_snprintf? * pretty print frequencies * str must be long enough. max can be as long as 17 chars */

Source from the content-addressed store, hash-verified

382 * str must be long enough. max can be as long as 17 chars
383 */
384int HAMLIB_API sprintf_freq(char *str, int str_len, freq_t freq)
385{
386 double f;
387 const char *hz;
388 int decplaces = 10;
389 int retval;
390
391 // too verbose
392 //rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
393
394 if (llabs(freq) >= GHz(1))
395 {
396 hz = "GHz";
397 f = (double)freq / GHz(1);
398 }
399 else if (llabs(freq) >= MHz(1))
400 {
401 hz = "MHz";
402 f = (double)freq / MHz(1);
403 decplaces = 7;
404 }
405 else if (llabs(freq) >= kHz(1))
406 {
407 hz = "kHz";
408 f = (double)freq / kHz(1);
409 decplaces = 4;
410 }
411 else
412 {
413 hz = "Hz";
414 f = (double)freq;
415 decplaces = 1;
416 }
417
418 SNPRINTF(str, str_len, "%.*f %s", decplaces, f, hz);
419 retval = strlen(str);
420 return retval;
421}
422
423
424/**

Callers 14

dummy_set_freqFunction · 0.85
dummy_set_modeFunction · 0.85
dttsp_set_freqFunction · 0.85
dttsp_set_modeFunction · 0.85
gs100_set_freqFunction · 0.85
gs100_set_tx_freqFunction · 0.85
miniVNA_set_freqFunction · 0.85
gr_set_freqFunction · 0.85
gr_set_modeFunction · 0.85
dumpcapsFunction · 0.85
dump_chanFunction · 0.85
dumpstateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected