import os , time import sys import greatfet import codext TXFREQUENCY=7028000 DELTAFREQ=170 gf = greatfet.GreatFET() """ RTTY via GREATFET via AD9820 """ W_CLK = "J1_P4" FQ_UD = "J1_P6" DATA = "J1_P28" RESET = "J1_P30" CLKIN = 125000000 pW_CLK = gf.gpio.get_pin(W_CLK) pW_CLK.set_direction(gf.gpio.DIRECTION_OUT) pFQ_UD = gf.gpio.get_pin(FQ_UD) pFQ_UD.set_direction(gf.gpio.DIRECTION_OUT) pDATA = gf.gpio.get_pin(DATA) pDATA.set_direction(gf.gpio.DIRECTION_OUT) pRESET = gf.gpio.get_pin(RESET) pRESET.set_direction(gf.gpio.DIRECTION_OUT) pW_CLK.write(False) pFQ_UD.write(False) pDATA.write(False) pRESET.write(False) def pulsePin(pin): pin.write(True) pin.write(True) pin.write(True) pin.write(False) return def setFreq( f): pulsePin(pFQ_UD) freq = int((f*(2**32))/CLKIN) phase = 0 phas = int ((phase*(2**5))/360) for i in range (0,34): pDATA.write( freq & 0x01) pulsePin(pW_CLK) freq = freq >> 1 pDATA.write( 0x00 & 0x01) pulsePin(pW_CLK) for j in range (0,4): pDATA.write( phas & 0x01) pulsePin(pW_CLK) phas = phas >> 1 pDATA.write( 0x00 & 0x01) pulsePin(pW_CLK) pulsePin(pFQ_UD) def setBit( bit): # The recommended audio frequencies are 2125 Hz for the MARK audio frequency and 2295(+170) Hz for the SPACE audio frequency. #print("**", bit) time.sleep(0.01) if bit==0: setFreq( TXFREQUENCY + DELTAFREQ) # SPACE else: setFreq( TXFREQUENCY ) # MARK # ----------------------------------------------------------- pulsePin(pRESET) pulsePin(pW_CLK) pulsePin(pW_CLK) pulsePin(pW_CLK) setBit(1) # IDLE is MARK s= "ON4CKO ON4CKO CQ CQ PSE K" bitstring = codext.encode( s, 'baudot-ccitt2') print("TO DO:", s) i=0 for c in [(bitstring[i:i+5][::-1]) for i in range(0, len(bitstring), 5)]: try: print( "%s(%c)"%(c, s[i]) ,end=" ") sys.stdout.flush() except: pass setBit( 0) # 1 (start) for b in c: # 2,3,4,5,6 if b=='0': setBit( 0) # 7 else: setBit( 1) setBit(1) # 7 (2 x stop bit is MARk for amateur RTTY) setBit(1) # 8 MARK i = i + 1 print("\nDONE")