From 4a2d6ef79e35f49f9852fb8bc05473e447207f67 Mon Sep 17 00:00:00 2001 From: F5OEO Date: Wed, 9 Jan 2019 00:51:49 +0000 Subject: [PATCH] Add initial FT8 menu --- ft8menu.sh | 128 ++++++++++++++++++++++++++++++++++++++++++++ src/Makefile | 1 + src/pift8/pift8.cpp | 40 +++++++++----- 3 files changed, 156 insertions(+), 13 deletions(-) create mode 100755 ft8menu.sh diff --git a/ft8menu.sh b/ft8menu.sh new file mode 100755 index 0000000..0aff1c8 --- /dev/null +++ b/ft8menu.sh @@ -0,0 +1,128 @@ +#!/bin/sh + +status="0" +OUTPUT_FREQ=14.074 +LAST_ITEM="0 CQ" +OUTPUT_CALL="" +OUTPUT_GRID="JN06" + +OM_CALL="" +OM_LEVEL="10" +FREETEXT="RPITX FT8 PI" + +OUTPUT_OFFSET="1240" +TIMESLOT="1" + +do_offset_frequency() +{ + if OFFSET=$(whiptail --inputbox "Choose FT8 offset (10-2600Hz) Default is 1240Hz" 8 78 $OUTPUT_OFFSET --title "Offset Frequency" 3>&1 1>&2 2>&3); then + OUTPUT_OFFSET=$OFFSET + fi +} + +do_slot_choice() +{ + if (whiptail --title "Time slot" --yesno --yes-button 0 --no-button 1 "Which timeslot (current) $TIMESLOT ?" 8 78 3>&1 1>&2 2>&3); then + TIMESLOT="0" + else + TIMESLOT="1" + fi +} + +do_freq_setup() +{ + + if FREQ=$(whiptail --inputbox "Choose FT8 output Frequency (in MHZ) Default is 14.074MHZ" 8 78 $OUTPUT_FREQ --title "Transmit Frequency" 3>&1 1>&2 2>&3); then + OUTPUT_FREQ=$FREQ + fi + + if CALL=$(whiptail --inputbox "Type your call" 8 78 $OUTPUT_CALL --title "Hamradio call" 3>&1 1>&2 2>&3); then + OUTPUT_CALL=$CALL + fi + + if GRID=$(whiptail --inputbox "Type your grid on 4 char:ex JN06" 8 78 $OUTPUT_GRID --title "Hamradio grid" 3>&1 1>&2 2>&3); then + OUTPUT_GRID=$GRID + fi + do_offset_frequency + do_slot_choice +} + +do_status() +{ + LAST_ITEM="$menuchoice" + whiptail --title "Processing ""$LAST_ITEM"" on ""$OUTPUT_FREQ""MHZ" --msgbox "Running" 8 78 + +} + +do_om_call() +{ + + + if CALL=$(whiptail --inputbox "Input new OM" 8 78 $OM_CALL --title "OM Call" 3>&1 1>&2 2>&3); then + OM_CALL=$CALL + fi + + #init level could not be a "-", remove the init + if LEVEL=$(whiptail --inputbox "Received level" 8 78 "0" --title "Received level" 3>&1 1>&2 2>&3); then + OM_LEVEL=$LEVEL + fi + +} + +do_freetext() +{ + + + if TEXT=$(whiptail --inputbox "Type free text(13 chars)" 8 78 $FREETEXT --title "FreeText" 3>&1 1>&2 2>&3); then + FREETEXT=$TEXT + + fi + + if (whiptail --title "FreeText" --yesno "Transmit now ?" 8 78 3>&1 1>&2 2>&3); then + sudo pift8 -f "$OUTPUT_FREQ"e6 "-m $FREETEXT" + fi + +} + +do_freq_setup + + while [ "$status" -eq 0 ] + do + + menuchoice=$(whiptail --default-item "$LAST_ITEM" --title "FT8 with rpitx Slot $TIMESLOT Offset $OUTPUT_OFFSET" --menu "Choose your item" 20 82 12 \ + "0 CQ" "Calling CQ on $OUTPUT_FREQ" \ + "1 ENTER OM" "Input OM call" \ + "2 dB" "Answer Db" \ + "3 RRR" "Answer RRR "\ + "4 Grid" "Answer with grid" \ + "5 R+dB" "Answer with R+level" \ + "6 73" "Answer with 73" \ + "7 Text" "Free text" \ + "8 Refine" "Adjust offset/slot" \ + 3>&2 2>&1 1>&3) + + case "$menuchoice" in + 0\ *) sudo pift8 -f "$OUTPUT_FREQ"e6 -m "CQ $OUTPUT_CALL $OUTPUT_GRID" -o "$OUTPUT_OFFSET" -s "$TIMESLOT" + LAST_ITEM="1 ENTER OM" ;; + 1\ *) do_om_call + LAST_ITEM="2 dB" ;; + 2\ *) sudo pift8 -f "$OUTPUT_FREQ"e6 -m "$OM_CALL $OUTPUT_CALL $OM_LEVEL" -o "$OUTPUT_OFFSET" -s "$TIMESLOT" + LAST_ITEM="3 RRR" ;; + 3\ *) sudo pift8 -f "$OUTPUT_FREQ"e6 -m "$OM_CALL $OUTPUT_CALL RR73" -o "$OUTPUT_OFFSET" -s "$TIMESLOT" + LAST_ITEM="0 CQ" ;; + 4\ *) sudo pift8 -f "$OUTPUT_FREQ"e6 -m "$OM_CALL $OUTPUT_CALL $OUTPUT_GRID" -o "$OUTPUT_OFFSET" -s "$TIMESLOT" + LAST_ITEM="5 R+dB" ;; + 5\ *) sudo pift8 -f "$OUTPUT_FREQ"e6 -m "$OM_CALL $OUTPUT_CALL R$OM_LEVEL" -o "$OUTPUT_OFFSET" -s "$TIMESLOT" + LAST_ITEM="6 73" ;; + 6\ *) sudo pift8 -f "$OUTPUT_FREQ"e6 -m "$OM_CALL $OUTPUT_CALL 73" -o "$OUTPUT_OFFSET" -s "$TIMESLOT" + do_om_call + LAST_ITEM="4 Grid" ;; + 7\ *) do_freetext ;; + 8\ *) do_offset_frequency + do_slot_choice + LAST_ITEM="0 CQ" ;; + *) status=1 + whiptail --title "Bye bye" --msgbox "Thanks for using rpitx!" 8 78 + ;; + esac + done diff --git a/src/Makefile b/src/Makefile index 1070c0c..0668a0c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -90,3 +90,4 @@ install: all install -m 0755 ../freedv /usr/bin install -m 0755 ../dvbrf /usr/bin install -m 0755 ../rpitx /usr/bin + install -m 0755 ../pift8 /usr/bin diff --git a/src/pift8/pift8.cpp b/src/pift8/pift8.cpp index 2606a96..859a3f0 100644 --- a/src/pift8/pift8.cpp +++ b/src/pift8/pift8.cpp @@ -19,10 +19,12 @@ bool running=true; void usage() { fprintf(stderr,\ "\npift8 -%s\n\ -Usage:\npift8 [-m Message][-f Frequency][-p ppm] [-h] \n\ +Usage:\npift8 [-m Message][-f Frequency][-p ppm][-o offset][-s slot][-r] [-h] \n\ -m message to transmit (13 caracters)\n\ -f float frequency carrier Hz(50 kHz to 1500 MHz),\n\ -p set clock ppm instead of ntp adjust\n\ +-o set frequency offset(0-2500Hz) default:1240\n\ +-s set time slot to transmit 0 or 1 (2 is always)\n\ -r repeat (every 15s)\n\ -h help (this help).\n\ Example : sudo pift8 -m \"CQ CA0ALL JN06\" -f 14.074e6\n\ @@ -40,14 +42,14 @@ terminate(int num) } void wait_every( - int seconds + int seconds, int slot ) { time_t t; struct tm* ptm; for(;running;){ time(&t); ptm = gmtime(&t); - if( (ptm->tm_sec % seconds)==0 ) break; + if( ((ptm->tm_sec) % seconds)==slot ) break; usleep(1000); } usleep(800000); // wait another second @@ -61,13 +63,14 @@ int main(int argc, char **argv) { float frequency=14.07e6; float ppm=1000; - const char *message; + const char *message="CQ"; bool repeat=false; - + int slot=0; + float offset=1240; while(1) { - a = getopt(argc, argv, "m:f:p:hr"); + a = getopt(argc, argv, "m:f:p:hro:s:"); if(a == -1) { @@ -95,9 +98,16 @@ int main(int argc, char **argv) { usage(); exit(1); break; - case 'r': // help + case 'r': // repeat repeat=true; break; + case 's': // time slot + slot=atoi(optarg); + fprintf(stderr,"slot=%d\n",slot); + break; + case 'o': // frequency offset + offset=atof(optarg); + break; case -1: break; case '?': @@ -161,7 +171,7 @@ int main(int argc, char **argv) { float Deviation=6.25; dbg_setlevel(1); - fskburst fsk(frequency, 6.25*Upsample, Deviation, 14, FifoSize); + fskburst fsk(frequency+offset, 6.25*Upsample, Deviation, 14, FifoSize); if(ppm!=1000) { //ppm is set else use ntp fsk.Setppm(ppm); @@ -179,16 +189,20 @@ int main(int argc, char **argv) { //fprintf(stderr,"Freq %f\n",Symbols[i]); } fprintf(stderr,"Wait 1st Tx\n"); - wait_every(15); + wait_every(30,slot*15); do { - - if(!running) exit(0); fprintf(stderr,"Tx!\n"); fsk.SetSymbols(Symbols, (ft8::NN)*Upsample); fsk.stop(); - fprintf(stderr,"Wait 30s\n"); - wait_every(30); + if(repeat) + { + fprintf(stderr,"Wait 30s\n"); + if(slot<2) + wait_every(30,slot*15); + else + wait_every(15,slot*15); + } } while(repeat&&running); }