From 3f8b2846bd673b0b74c533f9e33e16690cb757d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= <mordae@anilinux.org>
Date: Sat, 24 Feb 2024 22:25:05 +0100
Subject: [PATCH] Improve BPSK with output polarity inversion

---
 src/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c
index 5a8046a..645ef36 100644
--- a/src/main.c
+++ b/src/main.c
@@ -839,19 +839,21 @@ static void command(const char *cmd)
 		rf_tx_start(n);
 		puts("Transmitting, press ENTER to stop.");
 
+		bool phase = false;
+
 		while (true) {
 			int c = getchar_timeout_us(1000);
 
 			if ('\r' == c) {
 				break;
 			} else if (' ' == c) {
-				pio_sm_exec(pio1, 1, pio_encode_nop());
-				pio_sm_exec(pio1, 1, pio_encode_nop());
-				pio_sm_exec(pio1, 1, pio_encode_nop());
+				phase = !phase;
+				gpio_set_outover(n, phase);
 			}
 		}
 
 		rf_tx_stop();
+		gpio_set_outover(n, 0);
 		puts("Done.");
 		return;
 	}