From f0fc245cf442c6097f5922774499c94256e6f65f Mon Sep 17 00:00:00 2001 From: eleccoder <9162301+eleccoder@users.noreply.github.com> Date: Wed, 28 Dec 2022 17:49:32 +0100 Subject: [PATCH] PTT control added to the 'beacon' demo --- README.md | 8 +++++-- src/aprs_pico_beacon_demo.c | 45 +++++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 41e9b1b..75d04c2 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ The line-out voltage can be as high as 2.7 Vpp (~1 Vrms) ( ## Build the library and the 'beacon' demo application +NOTE: In case you want to allow the Pico to control the PTT (*Push-To-Talk*) input of your transmitter, set the appropriate `#define` parameters in `src/aprs_pico_beacon_demo.c`. + ``` git clone https://github.com/eleccoder/raspi-pico-aprs-tnc.git cd raspi-pico-aprs-tnc @@ -52,7 +54,9 @@ cmake --build build ## Run the 'beacon' demo application -The analog AFSK audio signal will be available at the filter's line-out. You can probe it by a scope, listen to it by using an audio amp, or connect it to any RF transceiver to send it on the air (ham radio license required). But for testing the signal integrity, you can feed the signal into the soundcard of your computer and let decode its data content by [Dire Wolf](https://github.com/wb2osz/direwolf) - see down below. +The analog AFSK audio signal will be available at the filter's line-out. You can probe it by a scope, listen to it by using an audio amp, or connect it to any RF transceiver to send it on the air (ham radio license required). + +But for testing the signal integrity, you can feed the signal into the soundcard of your computer and let decode its data content by [Dire Wolf](https://github.com/wb2osz/direwolf) - see down below. ### Flash the Pico @@ -60,7 +64,7 @@ The analog AFSK audio signal will be available at the filter's line-out. You can cd build ``` -Flash 'aprs_pico_beacon_demo[.uf2|.elf|.bin|.hex]' to the Pico board as you're usually doing. +Flash `aprs_pico_beacon_demo[.uf2|.elf|.bin|.hex]` to the Pico board as you're usually doing. ### Test the 'beacon' demo application using *Dire Wolf* (on LINUX) diff --git a/src/aprs_pico_beacon_demo.c b/src/aprs_pico_beacon_demo.c index 14f16dd..9d742dd 100644 --- a/src/aprs_pico_beacon_demo.c +++ b/src/aprs_pico_beacon_demo.c @@ -16,23 +16,50 @@ * along with this program. If not, see . */ + +/* This program demonstrates the usage of the 'libaprs_pico.a' library by showing + * how to send a static APRS beacon. + * + * Optionally, PTT control can be enabled (see the #define section down below). + */ + +// Define whether/how the RPi Pico should control a transmitter's PTT input +#define PTT_ENABLE (false) +#define PTT_GPXX_PIN (1) +#define PTT_DELAY_BEFORE_TX_IN_MSEC (400) +#define PTT_TX_PERIOD_IN_MIN (10) + + #include "aprs_pico.h" #include "pico/stdlib.h" #include + int main() { stdio_init_all(); +#if PTT_ENABLE == true + + gpio_init(PTT_GPXX_PIN); + gpio_set_dir(PTT_GPXX_PIN, GPIO_OUT); + +#endif // PTT_ENABLE + audio_buffer_pool_t* audio_buffer_pool = aprs_pico_init(); - // Let the altitude run over time - double alt_in_m = 0.0; - - while (true) // Loop forever + // Loop forever + while (true) { +#if PTT_ENABLE == true + + gpio_put(PTT_GPXX_PIN, true); + sleep_ms(PTT_DELAY_BEFORE_TX_IN_MSEC); + +#endif // PTT_ENABLE + // Send an APRS test message aprs_pico_sendAPRS(audio_buffer_pool, "DL3TG-9", // Source call sign @@ -42,13 +69,17 @@ int main() "APRS by RPi-Pico - https://github.com/eleccoder/raspi-pico-aprs-tnc", // Text message 48.75588, // Latitude (in deg) 9.19011, // Longitude (in deg) - alt_in_m, // Altitude (in m) + 483, // Altitude (in m) '/', // APRS symbol table: Primary '>', // APRS symbol code: Car 128u); // Volume (0 ... 256) - // Don't raise too high ... - alt_in_m = (alt_in_m < 1000.0) ? alt_in_m + 100.0 : 0.0; +#if PTT_ENABLE == true + + gpio_put(PTT_GPXX_PIN, false); + sleep_ms(PTT_TX_PERIOD_IN_MIN * 60 * 1000); + +#endif // PTT_ENABLE } return 0;