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 >> 12) & 15, (data >> 8) & 15);
|
||||
|
||||
if ((data & 0xff) == 0)
|
||||
putc(' ', out);
|
||||
else
|
||||
if ((data & 0xff) == 0) {
|
||||
fputs(" ", out);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
@ -558,19 +583,14 @@ static void print_offset(FILE *out, uint32_t rx_bcd, uint32_t tx_bcd)
|
||||
if (delta == 0) {
|
||||
fprintf(out, "+0 ");
|
||||
} else if (delta > 0 && delta/50000 <= 255) {
|
||||
if (delta % 1000000 == 0)
|
||||
fprintf(out, "+%-7u", delta / 1000000);
|
||||
else
|
||||
fprintf(out, "+%-7.3f", delta / 1000000.0);
|
||||
fprintf(out, "+");
|
||||
print_mhz(out, delta);
|
||||
} else if (delta < 0 && -delta/50000 <= 255) {
|
||||
delta = - delta;
|
||||
if (delta % 1000000 == 0)
|
||||
fprintf(out, "-%-7u", delta / 1000000);
|
||||
else
|
||||
fprintf(out, "-%-7.3f", delta / 1000000.0);
|
||||
fprintf(out, "-");
|
||||
print_mhz(out, -delta);
|
||||
} else {
|
||||
// Cross band mode.
|
||||
fprintf(out, " %-7.4f", tx_hz / 1000000.0);
|
||||
fprintf(out, " ");
|
||||
print_mhz(out, tx_hz);
|
||||
}
|
||||
}
|
||||
|
||||
@ -696,7 +716,7 @@ static void print_chan_base(FILE *out, channel_t *ch, int cnum)
|
||||
fprintf(out, " ");
|
||||
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)
|
||||
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 >> 12) & 15, (data >> 8) & 15);
|
||||
|
||||
if ((data & 0xff) == 0)
|
||||
putc(' ', out);
|
||||
else
|
||||
if ((data & 0xff) == 0) {
|
||||
fputs(" ", out);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
@ -582,19 +607,14 @@ static void print_offset(FILE *out, uint32_t rx_bcd, uint32_t tx_bcd)
|
||||
if (delta == 0) {
|
||||
fprintf(out, "+0 ");
|
||||
} else if (delta > 0 && delta/50000 <= 255) {
|
||||
if (delta % 1000000 == 0)
|
||||
fprintf(out, "+%-7u", delta / 1000000);
|
||||
else
|
||||
fprintf(out, "+%-7.3f", delta / 1000000.0);
|
||||
fprintf(out, "+");
|
||||
print_mhz(out, delta);
|
||||
} else if (delta < 0 && -delta/50000 <= 255) {
|
||||
delta = - delta;
|
||||
if (delta % 1000000 == 0)
|
||||
fprintf(out, "-%-7u", delta / 1000000);
|
||||
else
|
||||
fprintf(out, "-%-7.3f", delta / 1000000.0);
|
||||
fprintf(out, "-");
|
||||
print_mhz(out, -delta);
|
||||
} else {
|
||||
// Cross band mode.
|
||||
fprintf(out, " %-7.4f", tx_hz / 1000000.0);
|
||||
fprintf(out, " ");
|
||||
print_mhz(out, tx_hz);
|
||||
}
|
||||
}
|
||||
|
||||
@ -720,7 +740,7 @@ static void print_chan_base(FILE *out, channel_t *ch, int cnum)
|
||||
fprintf(out, " ");
|
||||
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)
|
||||
fprintf(out, "- ");
|
||||
|
Loading…
Reference in New Issue
Block a user