From f606954f52bd50b7bf1105735727c2791cc9757f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 24 Mar 2023 21:46:49 -0400 Subject: [PATCH] added pd and put control --- rpitx.py | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/rpitx.py b/rpitx.py index 838c209c..2c7b3194 100644 --- a/rpitx.py +++ b/rpitx.py @@ -11,6 +11,9 @@ from os import system print("CubeSatSim v1.1 rpitx.py starting...") +pd = 21 +ptt = 20 + GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) @@ -50,6 +53,11 @@ GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4 GPIO.setwarnings(False) GPIO.setup(txLed, GPIO.OUT) +GPIO.setup(pd, GPIO.OUT) +output(pd, 1) +GPIO.setup(ptt, GPIO.OUT) +output (ptt, 1) + output(txLed, txLedOn) sleep(1) output(txLed, txLedOff) @@ -92,15 +100,15 @@ if __name__ == "__main__": GPIO.setup(txLed, GPIO.OUT) sleep(1) + output (ptt, 0) output(txLed, txLedOn) # if (debug_mode == 1): # system("echo 'hi hi de " + callsign + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") # else: # system("echo 'hi hi de " + callsign + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") system("echo 'hi hi de " + callsign + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1 && aplay /home/pi/CubeSatSim/morse.wav") - sleep(4); # was 8 output(txLed, txLedOff) - + output (ptt, 1) sleep(1) @@ -119,6 +127,7 @@ if __name__ == "__main__": except: system("echo '" + callsign + "-11>APCSS:hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/t.txt && echo 'AMSAT>APCSS:010101/hi hi ' >> /home/pi/CubeSatSim/t.txt") for x in range(5): + output (ptt, 0) output(txLed, txLedOn) # if (debug_mode == 1): # system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") @@ -127,16 +136,19 @@ if __name__ == "__main__": system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && aplay /home/pi/CubeSatSim/telem.wav") sleep(0.2) output(txLed, txLedOff) + output (ptt, 1) sleep(3.8) while True: try: f = open("/home/pi/CubeSatSim/ready") output(txLed, txLedOn) + output (ptt, 0) # if (debug_mode == 1): # system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") # else: # system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && aplay /home/pi/CubeSatSim/telem.wav") + output (ptt, 1) output(txLed, txLedOff) f.close() system("sudo rm /home/pi/CubeSatSim/ready") @@ -152,23 +164,27 @@ if __name__ == "__main__": except: system("echo 'hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/cw.txt") output(txLed, txLedOn) + output (ptt, 0) # if (debug_mode == 1): # system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") # else: # system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && aplay /home/pi/CubeSatSim/morse.wav") output(txLed, txLedOff) + output (ptt, 1) while True: try: f = open("/home/pi/CubeSatSim/cwready") output(txLed, txLedOn) + output (ptt, 0) # if (debug_mode == 1): # system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") # else: # system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && aplay /home/pi/CubeSatSim/morse.wav") output(txLed, txLedOff) + output (ptt, 1) f.close() system("sudo rm /home/pi/CubeSatSim/cwready") sleep(1) @@ -193,6 +209,7 @@ if __name__ == "__main__": # while 1: output(txLed, txLedOff) + output (ptt, 1) if (camera_present == 1): try: file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") @@ -200,12 +217,14 @@ if __name__ == "__main__": system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") print ("Sending SSTV image") output(txLed, txLedOn) + output (ptt, 0) system("aplay -D hw:0,0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav") # if (debug_mode == 1): # system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # else: # system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") output(txLed, txLedOff) + output (ptt, 1) # sleep(1) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") @@ -216,12 +235,14 @@ if __name__ == "__main__": system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") print ("Sending SSTV image") output(txLed, txLedOn) - system("aplay -D hw:0,0 /home/pi/CubeSatSim/camera_out.jpg.wav") + output (ptt, 0) + system("aplay /home/pi/CubeSatSim/camera_out.jpg.wav") # if (debug_mode == 1): # system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # else: # system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") output(txLed, txLedOff) + output (ptt, 1) system("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1") sleep(1) else: @@ -231,12 +252,14 @@ if __name__ == "__main__": system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") print ("Sending SSTV image") output(txLed, txLedOn) - system("aplay -D hw:0,0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") + output (ptt, 0) + system("aplay /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") # if (debug_mode == 1): # system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # else: # system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") output(txLed, txLedOff) + output (ptt, 1) sleep(1) except: print("image 1 did not load - copy from CubeSatSim/sstv directory") @@ -247,21 +270,26 @@ if __name__ == "__main__": while 1: print ("Sending SSTV image") output(txLed, txLedOn) - system("aplay -D hw:0,0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") + output (ptt, 0) + system("aplay /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") # if (debug_mode == 1): # system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # else: # system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") output(txLed, txLedOff) + output (ptt, 1) sleep(5) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") - system("aplay -D hw:0,0 /home/pi/CubeSatSim/sstv.wav") + system("aplay /home/pi/CubeSatSim/sstv.wav") # system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 &") while 1: output(txLed, txLedOn) - sleep(60) + output (ptt, 0) +# sleep(60) + system("aplay /home/pi/CubeSatSim/sstv.wav") output(txLed, txLedOff) + output (ptt, 1) sleep(1) elif (mode == 'b'):