Experiment with OOK

This commit is contained in:
Jan Hamal Dvořák 2024-02-27 21:47:20 +01:00
parent 68ca4f14f4
commit 2732df5bc3

View file

@ -847,6 +847,7 @@ static void command(const char *cmd)
puts("brx N FREQ - receive on pin N, binary output");
puts("bpsk N FREQ - transmit on pin N with BPSK");
puts("fsk N FREQ - transmit on pin N with FSK");
puts("ook N FREQ - transmit on pin N with OOK");
puts("sweep N F G S - sweep from F to G with given step");
puts("noise N - transmit random noise");
return;
@ -970,6 +971,45 @@ static void command(const char *cmd)
return;
}
if (3 == sscanf(cmd, " ook %i %f %[\a]", &n, &f, tmp)) {
float actual = rx_lo_init(f);
printf("Frequency: %.0f\n", actual);
rf_tx_start(n);
puts("Transmitting, press ENTER to stop.");
bool off = false;
const double step_hz = (double)CLK_SYS_HZ / (LO_WORDS * 32);
while (true) {
int c = getchar_timeout_us(10000);
if ('\r' == c) {
break;
} else if (' ' == c) {
off = !off;
gpio_set_oeover(n, off * 2);
} else if ('+' == c) {
actual = rx_lo_init(actual + step_hz);
printf("Frequency: %.0f\n", actual);
} else if ('-' == c) {
actual = rx_lo_init(actual - step_hz);
printf("Frequency: %.0f\n", actual);
} else if ((c >= '1') && (c <= '9')) {
for (int i = 0; i < 1000; i++) {
off = !off;
gpio_set_oeover(n, off * 2);
sleep_us(1000 / (c - '0'));
}
}
}
rf_tx_stop();
gpio_set_oeover(n, 0);
puts("Done.");
return;
}
if (5 == sscanf(cmd, " sweep %i %f %f %i %[\a]", &n, &f, &g, &x, tmp)) {
const float step_hz = (float)CLK_SYS_HZ / (LO_WORDS * 32);
const float start = roundf(f / step_hz) * step_hz;