Print all digits of frequency.
This commit is contained in:
parent
dbbcbdaaa0
commit
37592a6554
50
md380.c
50
md380.c
@ -472,10 +472,16 @@ static void print_freq(FILE *out, unsigned data)
|
|||||||
(data >> 20) & 15, (data >> 16) & 15,
|
(data >> 20) & 15, (data >> 16) & 15,
|
||||||
(data >> 12) & 15, (data >> 8) & 15);
|
(data >> 12) & 15, (data >> 8) & 15);
|
||||||
|
|
||||||
if ((data & 0xff) == 0)
|
if ((data & 0xff) == 0) {
|
||||||
putc(' ', out);
|
fputs(" ", out);
|
||||||
else
|
} else {
|
||||||
fprintf(out, "%d", (data >> 4) & 15);
|
fprintf(out, "%d", (data >> 4) & 15);
|
||||||
|
if ((data & 0x0f) == 0) {
|
||||||
|
fputs(" ", out);
|
||||||
|
} else {
|
||||||
|
fprintf(out, "%d", data & 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -546,6 +552,25 @@ static int freq_to_hz(uint32_t bcd)
|
|||||||
return (((((((a*10 + b) * 10 + c) * 10 + d) * 10 + e) * 10 + f) * 10 + g) * 10 + h) * 10;
|
return (((((((a*10 + b) * 10 + c) * 10 + d) * 10 + e) * 10 + f) * 10 + g) * 10 + h) * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Print frequency as MHz.
|
||||||
|
//
|
||||||
|
static void print_mhz(FILE *out, uint32_t hz)
|
||||||
|
{
|
||||||
|
if (hz % 1000000 == 0)
|
||||||
|
fprintf(out, "%-8u", hz / 1000000);
|
||||||
|
else if (hz % 100000 == 0)
|
||||||
|
fprintf(out, "%-8.1f", hz / 1000000.0);
|
||||||
|
else if (hz % 10000 == 0)
|
||||||
|
fprintf(out, "%-8.2f", hz / 1000000.0);
|
||||||
|
else if (hz % 1000 == 0)
|
||||||
|
fprintf(out, "%-8.3f", hz / 1000000.0);
|
||||||
|
else if (hz % 100 == 0)
|
||||||
|
fprintf(out, "%-8.4f", hz / 1000000.0);
|
||||||
|
else
|
||||||
|
fprintf(out, "%-8.5f", hz / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Print the transmit offset or frequency.
|
// Print the transmit offset or frequency.
|
||||||
//
|
//
|
||||||
@ -558,19 +583,14 @@ static void print_offset(FILE *out, uint32_t rx_bcd, uint32_t tx_bcd)
|
|||||||
if (delta == 0) {
|
if (delta == 0) {
|
||||||
fprintf(out, "+0 ");
|
fprintf(out, "+0 ");
|
||||||
} else if (delta > 0 && delta/50000 <= 255) {
|
} else if (delta > 0 && delta/50000 <= 255) {
|
||||||
if (delta % 1000000 == 0)
|
fprintf(out, "+");
|
||||||
fprintf(out, "+%-7u", delta / 1000000);
|
print_mhz(out, delta);
|
||||||
else
|
|
||||||
fprintf(out, "+%-7.3f", delta / 1000000.0);
|
|
||||||
} else if (delta < 0 && -delta/50000 <= 255) {
|
} else if (delta < 0 && -delta/50000 <= 255) {
|
||||||
delta = - delta;
|
fprintf(out, "-");
|
||||||
if (delta % 1000000 == 0)
|
print_mhz(out, -delta);
|
||||||
fprintf(out, "-%-7u", delta / 1000000);
|
|
||||||
else
|
|
||||||
fprintf(out, "-%-7.3f", delta / 1000000.0);
|
|
||||||
} else {
|
} else {
|
||||||
// Cross band mode.
|
fprintf(out, " ");
|
||||||
fprintf(out, " %-7.4f", tx_hz / 1000000.0);
|
print_mhz(out, tx_hz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,7 +716,7 @@ static void print_chan_base(FILE *out, channel_t *ch, int cnum)
|
|||||||
fprintf(out, " ");
|
fprintf(out, " ");
|
||||||
print_offset(out, ch->rx_frequency, ch->tx_frequency);
|
print_offset(out, ch->rx_frequency, ch->tx_frequency);
|
||||||
|
|
||||||
fprintf(out, " %-4s ", POWER_NAME[ch->power]);
|
fprintf(out, "%-4s ", POWER_NAME[ch->power]);
|
||||||
|
|
||||||
if (ch->scan_list_index == 0)
|
if (ch->scan_list_index == 0)
|
||||||
fprintf(out, "- ");
|
fprintf(out, "- ");
|
||||||
|
50
uv380.c
50
uv380.c
@ -496,10 +496,16 @@ static void print_freq(FILE *out, unsigned data)
|
|||||||
(data >> 20) & 15, (data >> 16) & 15,
|
(data >> 20) & 15, (data >> 16) & 15,
|
||||||
(data >> 12) & 15, (data >> 8) & 15);
|
(data >> 12) & 15, (data >> 8) & 15);
|
||||||
|
|
||||||
if ((data & 0xff) == 0)
|
if ((data & 0xff) == 0) {
|
||||||
putc(' ', out);
|
fputs(" ", out);
|
||||||
else
|
} else {
|
||||||
fprintf(out, "%d", (data >> 4) & 15);
|
fprintf(out, "%d", (data >> 4) & 15);
|
||||||
|
if ((data & 0x0f) == 0) {
|
||||||
|
fputs(" ", out);
|
||||||
|
} else {
|
||||||
|
fprintf(out, "%d", data & 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -570,6 +576,25 @@ static int freq_to_hz(uint32_t bcd)
|
|||||||
return (((((((a*10 + b) * 10 + c) * 10 + d) * 10 + e) * 10 + f) * 10 + g) * 10 + h) * 10;
|
return (((((((a*10 + b) * 10 + c) * 10 + d) * 10 + e) * 10 + f) * 10 + g) * 10 + h) * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Print frequency as MHz.
|
||||||
|
//
|
||||||
|
static void print_mhz(FILE *out, uint32_t hz)
|
||||||
|
{
|
||||||
|
if (hz % 1000000 == 0)
|
||||||
|
fprintf(out, "%-8u", hz / 1000000);
|
||||||
|
else if (hz % 100000 == 0)
|
||||||
|
fprintf(out, "%-8.1f", hz / 1000000.0);
|
||||||
|
else if (hz % 10000 == 0)
|
||||||
|
fprintf(out, "%-8.2f", hz / 1000000.0);
|
||||||
|
else if (hz % 1000 == 0)
|
||||||
|
fprintf(out, "%-8.3f", hz / 1000000.0);
|
||||||
|
else if (hz % 100 == 0)
|
||||||
|
fprintf(out, "%-8.4f", hz / 1000000.0);
|
||||||
|
else
|
||||||
|
fprintf(out, "%-8.5f", hz / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Print the transmit offset or frequency.
|
// Print the transmit offset or frequency.
|
||||||
//
|
//
|
||||||
@ -582,19 +607,14 @@ static void print_offset(FILE *out, uint32_t rx_bcd, uint32_t tx_bcd)
|
|||||||
if (delta == 0) {
|
if (delta == 0) {
|
||||||
fprintf(out, "+0 ");
|
fprintf(out, "+0 ");
|
||||||
} else if (delta > 0 && delta/50000 <= 255) {
|
} else if (delta > 0 && delta/50000 <= 255) {
|
||||||
if (delta % 1000000 == 0)
|
fprintf(out, "+");
|
||||||
fprintf(out, "+%-7u", delta / 1000000);
|
print_mhz(out, delta);
|
||||||
else
|
|
||||||
fprintf(out, "+%-7.3f", delta / 1000000.0);
|
|
||||||
} else if (delta < 0 && -delta/50000 <= 255) {
|
} else if (delta < 0 && -delta/50000 <= 255) {
|
||||||
delta = - delta;
|
fprintf(out, "-");
|
||||||
if (delta % 1000000 == 0)
|
print_mhz(out, -delta);
|
||||||
fprintf(out, "-%-7u", delta / 1000000);
|
|
||||||
else
|
|
||||||
fprintf(out, "-%-7.3f", delta / 1000000.0);
|
|
||||||
} else {
|
} else {
|
||||||
// Cross band mode.
|
fprintf(out, " ");
|
||||||
fprintf(out, " %-7.4f", tx_hz / 1000000.0);
|
print_mhz(out, tx_hz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +740,7 @@ static void print_chan_base(FILE *out, channel_t *ch, int cnum)
|
|||||||
fprintf(out, " ");
|
fprintf(out, " ");
|
||||||
print_offset(out, ch->rx_frequency, ch->tx_frequency);
|
print_offset(out, ch->rx_frequency, ch->tx_frequency);
|
||||||
|
|
||||||
fprintf(out, " %-4s ", POWER_NAME[ch->power]);
|
fprintf(out, "%-4s ", POWER_NAME[ch->power]);
|
||||||
|
|
||||||
if (ch->scan_list_index == 0)
|
if (ch->scan_list_index == 0)
|
||||||
fprintf(out, "- ");
|
fprintf(out, "- ");
|
||||||
|
Loading…
Reference in New Issue
Block a user