kopia lustrzana https://github.com/Hamlib/Hamlib
* added freq_sprintf helper
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@457 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.1
rodzic
5163ec58f4
commit
2fa640d629
29
src/misc.c
29
src/misc.c
|
@ -6,7 +6,7 @@
|
|||
* Provides useful routines for data handling, used by backend
|
||||
* as well as by the frontend.
|
||||
*
|
||||
* $Id: misc.c,v 1.4 2000-12-22 01:16:17 javabear Exp $
|
||||
* $Id: misc.c,v 1.5 2001-04-24 19:52:28 f4cfe Exp $
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -223,3 +223,30 @@ void rig_debug(enum rig_debug_level_e debug_level, const char *fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* rig_freq_snprintf
|
||||
* pretty print frequencies
|
||||
* str must be long enough. max can be as long as 17 chars
|
||||
*/
|
||||
int freq_sprintf(char *str, freq_t freq)
|
||||
{
|
||||
double f;
|
||||
char *hz;
|
||||
|
||||
if (freq >= GHz(1)) {
|
||||
hz = "GHz";
|
||||
f = (double)freq/GHz(1);
|
||||
} else if (freq >= MHz(1)) {
|
||||
hz = "MHz";
|
||||
f = (double)freq/MHz(1);
|
||||
} else if (freq >= kHz(1)) {
|
||||
hz = "kHz";
|
||||
f = (double)freq/kHz(1);
|
||||
} else {
|
||||
hz = "Hz";
|
||||
f = (double)freq;
|
||||
}
|
||||
|
||||
return sprintf (str, "%g%s", f, hz);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Provides useful routines for data handling, used by backends
|
||||
* as well as by the frontend.
|
||||
*
|
||||
* $Id: misc.h,v 1.4 2000-12-22 01:16:17 javabear Exp $
|
||||
* $Id: misc.h,v 1.5 2001-04-24 19:52:28 f4cfe Exp $
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -62,5 +62,8 @@ unsigned long long from_bcd(const unsigned char bcd_data[], int bcd_len);
|
|||
unsigned char *to_bcd_be(unsigned char bcd_data[], unsigned long long freq, int bcd_len);
|
||||
unsigned long long from_bcd_be(const unsigned char bcd_data[], int bcd_len);
|
||||
|
||||
int freq_sprintf(char *str, freq_t freq);
|
||||
|
||||
|
||||
#endif /* _MISC_H */
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue