D868UV: print ctcss and dcs tones.

This commit is contained in:
Serge Vakulenko 2018-10-26 12:40:32 -07:00
parent 68e8a5b3bd
commit 39010def93

View File

@ -270,6 +270,20 @@ static const char *DIGITAL_ADMIT_NAME[] = { "-", "Free", "NColor", "Color" };
static const char *ANALOG_ADMIT_NAME[] = { "-", "Tone", "Free", "Free" }; static const char *ANALOG_ADMIT_NAME[] = { "-", "Tone", "Free", "Free" };
static const char *BANDWIDTH[] = { "12.5", "25" }; static const char *BANDWIDTH[] = { "12.5", "25" };
//
// CTCSS tones, Hz*10.
//
#define NCTCSS 51
static const int CTCSS_TONES[NCTCSS] = {
625, 670, 693, 719, 744, 770, 797, 825, 854, 885,
915, 948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230,
1273, 1318, 1365, 1413, 1462, 1514, 1567, 1598, 1622, 1655,
1679, 1713, 1738, 1773, 1799, 1835, 1862, 1899, 1928, 1966,
1995, 2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503,
2541,
};
// //
// Print a generic information about the device. // Print a generic information about the device.
// //
@ -466,7 +480,7 @@ static void print_rx_freq(FILE *out, unsigned data)
(data >> 12) & 15, (data >> 8) & 15, (data >> 12) & 15, (data >> 8) & 15,
(data >> 20) & 15, (data >> 16) & 15); (data >> 20) & 15, (data >> 16) & 15);
if ((data & 0xff) == 0) { if (((data >> 24) & 0xff) == 0) {
fputs(" ", out); fputs(" ", out);
} else { } else {
fprintf(out, "%d", (data >> 28) & 15); fprintf(out, "%d", (data >> 28) & 15);
@ -626,16 +640,34 @@ static void print_digital_channels(FILE *out, int verbose)
} }
} }
static void print_ctcss(FILE *out, unsigned ctcss) //
// Print CTSS tone.
//
static void print_ctcss(FILE *out, unsigned index, unsigned custom)
{ {
//TODO int dhz = (index < NCTCSS) ? CTCSS_TONES[index] : custom;
fprintf(out, "0x%02x ", ctcss); unsigned a = dhz / 1000;
unsigned b = (dhz / 100) % 10;
unsigned c = (dhz / 10) % 10;
unsigned d = dhz % 10;
if (a == 0)
fprintf(out, "%d%d.%d ", b, c, d);
else
fprintf(out, "%d%d%d.%d", a, b, c, d);
} }
//
// Print DCS tone.
//
static void print_dcs(FILE *out, unsigned dcs) static void print_dcs(FILE *out, unsigned dcs)
{ {
//TODO unsigned i = (dcs >> 9) & 1;
fprintf(out, "0x%04x ", dcs); unsigned a = (dcs >> 6) & 7;
unsigned b = (dcs >> 3) & 7;
unsigned c = dcs & 7;
fprintf(out, "D%d%d%d%c", a, b, c, i ? 'I' : 'N');
} }
static void print_analog_channels(FILE *out, int verbose) static void print_analog_channels(FILE *out, int verbose)
@ -682,7 +714,7 @@ static void print_analog_channels(FILE *out, int verbose)
fprintf(out, "%-7s ", "Normal"); fprintf(out, "%-7s ", "Normal");
if (ch->rx_ctcss) if (ch->rx_ctcss)
print_ctcss(out, ch->ctcss_receive); print_ctcss(out, ch->ctcss_receive, ch->custom_ctcss);
else if (ch->rx_dcs) else if (ch->rx_dcs)
print_dcs(out, ch->dcs_receive); print_dcs(out, ch->dcs_receive);
else else
@ -690,7 +722,7 @@ static void print_analog_channels(FILE *out, int verbose)
fprintf(out, " "); fprintf(out, " ");
if (ch->tx_ctcss) if (ch->tx_ctcss)
print_ctcss(out, ch->ctcss_transmit); print_ctcss(out, ch->ctcss_transmit, ch->custom_ctcss);
else if (ch->tx_dcs) else if (ch->tx_dcs)
print_dcs(out, ch->dcs_transmit); print_dcs(out, ch->dcs_transmit);
else else