-
Notifications
You must be signed in to change notification settings - Fork 0
/
yaesu2.py
executable file
·1161 lines (1025 loc) · 31.9 KB
/
yaesu2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python3
#
# Author: Tom N4LSJ -- EXPERIMENTAL CODE ONLY FOR TINKERING
# -- USE AT YOUR OWN RISK ONLY
# -- AUTHOR ASSUMES NO LIABILITY
#
# NO WARRANTY
# NO WARRANTY
# NO WARRANTY
# NO WARRANTY
# NO WARRANTY
#
# Yaesu FT757-GX-1 program by N4LSJ
#
# This program works for the FT-757GX -MARK 1- only. The MK2 programming
# is not quite the same, so this program is not considered compatible
# with the FT-757GX 2.
#
# SEE OCTOBER 1985 QST ARTICLE PAGE 38 TITLED, "A CAT Control System"
#
# On page 39, a schematic is there for a circuit that uses a TIL-111
# optoisolator. You want the TIL-111 optoisolator circuit. It's the
# cleanest thing I've tried yet. Other solutions can carry too much
# noise for the overly sensitive TTL level serial interface.
#
# The optoisolator circuit is driven by TTL level, not actual RS-232,
# so you'll want to use TTL level serial, such as from an RS-232 to
# TTL converter. Don't wire the RS-232 straight to the circuit.
#
# The connector on the back of the YAESU FT-757GX is called a
# 3-pin JST-XH with 2.54mm pitch
#
# For keying, a 5V reed relay with a cap across the contacts to
# the rig, and the relay's coil across a GPIO pin and ground,
# specified in the keyer= variable will work nicely.
# Be sure you know the difference between BOARD and BCM with
# regard to the GPIO library before choosing which pins to tie
# your relay to.
#
# The first time you run this program, it will ask you for your
# Call, a Frequency, WPM, and a serial port.
#
# If you get something wrong, you can edit or delete your .yaesuft757gx.conf
# file and it will build new next time you run the program
#
# DATA BYTE:
# | START BIT | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | STOP BIT | STOP BIT |
# 5 BYTE BLOCK COMMAND
# | PARM 4 (LSD) | PARM 3 | PARM 2 | PARM 1 | INSTRUCTION (MSD) |
def DEBUG(x):
global DEBUGTS
N = datetime.datetime.utcnow()
print(x + str(N - DEBUGTS))
DEBUGTS = N
global DEBUGTS
import datetime
DEBUGTS=datetime.datetime.utcnow()
import time
import serial
import RPi.GPIO as GPIO
from tkinter import *
from tkinter.simpledialog import askstring
from tkinter.simpledialog import askinteger
from tkinter.simpledialog import askfloat
from tkinter.simpledialog import messagebox
from os.path import expanduser
from os import path
from time import sleep
global ee
global sending
global keyer
global ser
global mycall
global geom
global othercall
global rxfreq
global savef
global txfreq
global configfn
global wpm
global cw
global qqsy
global serport
global spinning
global spinning_id
global spinny
global spinspeed
global spinningt
global spinning_idt
global spinnyt
global spinspeedt
global tuning
global tuning_idt
global curspinny
global clock_id
global vfosplit
vfosplit = 0
sending = 0
ee = 0
othercall=''
spinning=0
spinny=['|','/','-','\\']
curspinny=0
tuning=0
tuning_idt=''
################################# YOU SET THESE
### once the config file gets written out, these values
### in that get used instead of what's here
serport='/dev/ttyAMA0' # PORT TO TALK TO RIG
rxfreq=7.10000 # DEFAULT FREQ TO USE IF NO CONFIG FILE
txfreq=rxfreq # DEFAULT FREQ TO USE IF NO CONFIG FILE
mycall='CHANGEME' # EMPTY ON PURPOSE
wpm="13" # WPM TO USE IF NO CONFIG FILE (FIX THIS)
keyer = 4 # # GPIO PIN FOR KEYING TO TRANSISTOR
# IMPORTANT.. Look for setmode below and PAY ATTENTION TO BOARD VS BCM
################################# END OF YOU SET THESE
GPIO.setmode(GPIO.BCM)
GPIO.setup(keyer,GPIO.OUT)
qqsy = [
("lb","160M"),
("bb","<F> (EAG)" , "1.8","green"),
("bb","<F> (EAG)" , "2","green"),
("sep","x"),
("lb","80M"),
("bb","<F> (E)" , "3.5","red"),
("bb","<F> (EAGnt)" , "3.525","red"),
("bb","<F> (E)" , "3.6","yellow"),
("bb","<F> (EA)" , "3.7","green"),
("bb","<F> (EAG)" , "3.8","green"),
("bb","<F> (EAG)" , "4","green"),
("sep","x"),
("lb","60M"),
("bb","<F> (EAG)" , "5.332","red"),
("bb","<F> (EAG)" , "5.348","red"),
("bb","<F> (EAG)" , "5.3585","red"),
("bb","<F> (EAG)" , "5.373","red"),
("bb","<F> (EAG)" , "5.405","red"),
("sep","x"),
("lb",""),
("bb","<F> (EAG)" , "5.3305","green"),
("bb","<F> (EAG)" , "5.3465","green"),
("bb","<F> (EAG)" , "5.357","green"),
("bb","<F> (EAG)" , "5.3715","green"),
("bb","<F> (EAG)" , "5.4035","green"),
("sep","x"),
("lb","40M"),
("bb","<F> (E)","7","red"),
("bb","<F> (AGnt)","7.025","red"),
("bb","<F> (EA)","7.125","yellow"),
("bb","<F> (EAG)","7.175","green"),
("bb","<F> (EAG)","7.3","green"),
("sep","x"),
("lb","30M"),
("bb","<F> (EAG)","10.1","red"),
("bb","<F> (EAG)","10.150","red"),
("sep","x"),
("lb","20M"),
("bb","<F> (E)","14","red"),
("bb","<F> (EAG)","14.025","red"),
("bb","<F> (E)","14.15","yellow"),
("bb","<F> (EA)","14.175","green"),
("bb","<F> (EAG)","14.225","green"),
("bb","<F> (EAG)","14.350","green"),
("sep","x"),
("lb","17M"),
("bb","<F> (EAG)","18.068","red"),
("bb","<F> (EAG)","18.11","yellow"),
("bb","<F> (EAG)","18.168","green"),
("sep","x"),
("lb","15M"),
("bb","<F> (E)","21","red"),
("bb","<F> (EAGnt)","21.025","red"),
("bb","<F> (E)","21.2","yellow"),
("bb","<F> (EA)","21.225","green"),
("bb","<F> (EAG)","21.275","green"),
("bb","<F> (EAG)","21.45","green"),
("sep","x"),
("lb","12M"),
("bb","<F> (EAG)","24.89","red"),
("bb","<F> (EAG)","24.93","yellow"),
("bb","<F> (EAG)","24.99","green"),
("sep","x"),
("lb","10M"),
("bb","<F> (EAGNT)","28","red"),
("bb","<F> (EAGNT)","28.3","yellow"),
("bb","<F> (EAG)","28.5","green"),
("bb","<F> (EAG)","29.7","green"),
("sep","x"),
("lb","TIME"),
("dd","W1AW", "1.8175", "3.5815", "7.0475", "14.0475", "18.0975", "21.0675", "28.0675"),
("dd","WWV", "2.5", "5", "10", "15", "20"),
("dd","CHU", "7.335", "7.85", "14.67"),
("sep","x"),
("lb","VOA"),
("dd","VOA", "0.909", "1.296", "1.530", "1.575", "4.930", "4.960", "5.925", "5.930", "6.080","6.195","7.270","7.325","7.375","9.815","12.030","13.590","15.460","15.580","15.715","17.530","17.530","17.790"),
]
cw = {
"A" : ".-", "B" : "-...", "C" : "-.-.", "D" : "-..", "E" : ".", "F" : "..-.",
"G" : "--.", "H" : "....", "I" : "..", "J" : ".---", "K" : "-.-", "L" : ".-..",
"M" : "--", "N" : "-.", "O" : "---", "P" : ".--.", "Q" : "--.-", "R" : ".-.",
"S" : "...", "T" : "-", "U" : "..-", "V" : "...-", "W" : ".--", "X" : "-..-",
"Y" : "-.--", "Z" : "--..", "0" : "-----", "1" : ".----", "2" : "..---",
"3" : "...--", "4" : "....-", "5" : ".....", "6" : "-....", "7" : "--...",
"8" : "---..", "9" : "----.", "." : ".-.-.-", "?" : "..--..", "/" : "-..-.",
"," : "--..--", "!" : "-.-.--", "'" : ".----.", "\"" : ".-..-.", "(" : "-.--.",
")" : "-.--.-", "&" : ".-...", ":" : "---...", ";" : "-.-.-.", "_" : "..--.-",
"=" : "-...-", "+" : ".-.-.", "-" : "-....-", "$" : "...-..-", "@" : ".--.-"
}
configfn=str(expanduser("~"))+"/.yaesuft757gx.conf"
##def eventbark(e):
## print(str(e.widget))
def hovertxt(txt):
hlabel.config(text=txt)
def hover(widg,txt):
widg.bind("<Enter>",lambda evt, tt=txt: hovertxt(tt))
widg.bind("<Leave>",lambda evt, tt="": hovertxt(tt))
def startspinningt(val):
global vfosplit
global spinningt
global spinspeedt
if (vfosplit == 0):
return None
spinspeedt=500
spinningt = 1
spinknobt(val)
def pttaction(val):
if (val == 1):
ptt_on()
if (val == 0):
ptt_off()
def starttuning(val):
global tuning
global tuning_idt
print ("tuning val is "+str(val))
if (val > 1):
ptt_on()
val = val - 1
tuning_idt=root.after(1000,starttuning,val)
else:
root.after_cancel(tuning_idt)
ptt_off()
#def stoptuning(val):
# global tuning
# global tuning_idt
# root.after_cancel(tuning_idt)
# ptt_off()
def startspinning(val):
global spinspeed
global spinning
spinspeed=500
spinning = 1
spinknob(val)
def stopspinningt(*args):
global spinningt
global spinning_idt
global spinspeedt
spinningt = 0
spinspeedt=500
root.after_cancel(spinning_idt)
def stopspinning(*args):
global spinning
global spinning_id
global spinspeed
spinning = 0
spinspeed=500
spinnything.configure(text="")
root.after_cancel(spinning_id)
def spinknob(val):
global curspinny
global spinny
global spinning
global spinning_id
global spinspeed
global rxfreq
curspinny = (curspinny + (1 if val > 0 else -1)) % 4
spinnything.configure(text=spinny[curspinny])
rxfreq = round(rxfreq + val,5);
if (rxfreq > 29.99999):
rxfreq = .5
if (rxfreq < .5):
rxfreq = 29.99999
FREQ()
if (spinning == 1):
spinning_id=root.after(spinspeed,spinknob,val)
spinspeed = 34 if (spinspeed==67) else spinspeed
spinspeed = 67 if (spinspeed==125) else spinspeed
spinspeed = 125 if (spinspeed==250) else spinspeed
spinspeed = 250 if (spinspeed==500) else spinspeed
def spinknobt(val):
global spinnyt
global spinningt
global spinning_idt
global spinspeedt
global txfreq
txfreq = round(txfreq + val,5);
if (txfreq > 29.99999):
txfreq = .5
if (txfreq < .5):
txfreq = 29.99999
itfreq.delete(0,END)
itfreq.insert(0,str('%7.5f' % (txfreq)))
if (spinningt == 1):
spinning_idt=root.after(spinspeedt,spinknobt,val)
spinspeedt = 34 if (spinspeedt==67) else spinspeedt
spinspeedt = 67 if (spinspeedt==125) else spinspeedt
spinspeedt = 125 if (spinspeedt==250) else spinspeedt
spinspeedt = 250 if (spinspeedt==500) else spinspeedt
def startclock(*args):
global clock_id
putdate()
clock_id=root.after(500,startclock,'')
def putdate():
datelab.config(text=str(datetime.datetime.utcnow())[0:19]+" UTC")
def dummy():
return True
def alnumslashonly(val):
for ch in val:
if (not ch in ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/')):
return False
return True
def cwonly(val):
global cw
for ch in val:
ch=ch.upper()
if (not ch in cw.keys() and ch != " "):
print ("BAD CHAR: ["+ch+"]")
return False
return True
def WriteCfg():
global serport
global rxfreq
global configfn
fh=open(configfn,'w+')
fh.write('rxfreq='+str(rxfreq)+"\n")
fh.write('wpm='+str(iwpm.get())+"\n")
fh.write('mycall='+imycall.get()+"\n")
sx=root.geometry().replace('+',' ').split()[1]
sy=root.geometry().replace('+',' ').split()[2]
fh.write("geom=+"+sx+"+"+sy+"\n")
fh.write("serport="+serport+"\n")
for kid in macroframe.winfo_children():
fh.write('macro='+str(kid['text'])+"\n")
print("Saved config to "+configfn)
def SPLU(*args):
global vfosplit
global txfreq
if (vfosplit == int(1)):
itfreq.delete(0,END)
txfreq = txfreq + .001
itfreq.insert(0,str('%7.5f' % (txfreq)))
def SPLD(*args):
global vfosplit
global txfreq
if (vfosplit == int(1)):
itfreq.delete(0,END)
txfreq = txfreq - .001
itfreq.insert(0,str('%7.5f' % (txfreq)))
def VSPL(*args):
global vfosplit
vfosplit = int(1 - vfosplit)
if (vfosplit == int(1)):
itfreq.config(bg='white')
spld.config(fg='black')
splu.config(fg='black')
splsd.config(fg='black')
splsu.config(fg='black')
else:
itfreq.delete(0,END)
itfreq.insert(0,ifreq.get())
itfreq.config(bg='grey')
spld.config(fg='grey')
splu.config(fg='grey')
splsd.config(fg='grey')
splsu.config(fg='grey')
def QUICKQSY(string):
global rxfreq
global txfreq
global vfosplit
ifreq.delete(0,END)
ifreq.insert(0,string)
rxfreq=float(ifreq.get())
vfosplit = 1
VSPL()
QSY()
def MACGRIDNEW():
mr = 0
mc = 0
gs=macroframe.grid_slaves()
for s in gs:
gi=s.grid_info()
gir=gi['row']
if (mr < gir):
mr = gir
for s in gs:
gi=s.grid_info()
gir=gi['row']
gic=gi['column']
if (gir == mr and mc < gic):
mc = gic
print ("max row is "+str(mr)+" and max col is "+str(mc))
if (mc == 5):
return mr+1, 1
else:
return mr, mc+1
def MACROREGRID():
macbuts=[]
gs=macroframe.grid_slaves()
for r in range (1,100):
for c in range (1,6):
for s in gs:
gi=s.grid_info()
rr=gi['row']
cc=gi['column']
if (r == rr and c == cc):
macbuts.append(s)
rr=1
cc=1
for m in macbuts:
m.grid(row=rr, column=cc)
cc=cc+1
if (cc > 5):
cc=1
rr=rr+1
def MAKEMACBUT(txt,rr,cc):
bb=Button(macroframe, text=txt)
bb.grid(row=rr,column=cc)
hover(bb,"Hit to send "+txt+", or right click to edit.")
bb.config(command=lambda widg=bb: RUNMACRO(widg))
bb.bind("<ButtonRelease-3>", lambda ebe, widg=bb: EDITBTN(widg))
return bb
def NEWMACRO(*args):
rr,cc=MACGRIDNEW()
bb=MAKEMACBUT('NEW MACRO',rr,cc)
EDITBTN(bb)
if (bb['text'] == 'NEW MACRO' or bb['text'] == ''):
bb.destroy()
def EDITBTN(widg):
newval = askstring('New Macro','Enter new macro. <C> is your call. <I> is other call.',initialvalue=widg['text'])
if (newval == ''):
widg.destroy()
MACROREGRID()
else:
widg.config(text=newval)
def RUNMACRO(widg):
string=widg['text'].upper().replace('<I>',iothercall.get().upper()).replace('<C>',imycall.get().upper())
tempstr=cwinput.get()
cwinput.delete(0,END)
cwinput.insert(0,string)
QUEUE()
cwinput.delete(0,END)
cwinput.insert(0,tempstr)
#def RUNMACRO(string):
# string=string.replace('<I>',iothercall.get()).replace('<C>',imycall.get())
# tempstr=cwinput.get()
# cwinput.delete(0,END)
# cwinput.insert(0,string)
# QUEUE()
# cwinput.delete(0,END)
# cwinput.insert(0,tempstr)
def ReadCfg():
global serport
global keyer
global geom
global rxfreq
global savef
global configfn
global wpm
global mycall
global ee
if (not path.exists(configfn)):
root.iconify()
mycall=askstring("Call Sign","Please enter your call sign.").upper().strip()
wpm=askinteger("WPM","Enter a default words per minute for CW.",minvalue=5,maxvalue=50)
rxfreq=askfloat("Frequency","Enter the frequency to go to the first time you start.",minvalue=.5,maxvalue=29.99999)
serport=askstring("Serial Port","Serial Port for CAT, e.g. /dev/ttyUSBx").strip()
imycall.delete(0,END)
imycall.insert(0,mycall)
iwpm.delete(0,END)
iwpm.insert(0,wpm)
zz=Button(macroframe,\
text='SAMPLE MACRO')
lmb=lambda widg=zz: RUNMACRO(widg)
zz.config(command=lmb)
zz.grid(row=0,column=1)
WriteCfg()
zz.destroy()
imycall.delete(0,END)
iwpm.delete(0,END)
if (path.exists(configfn)):
print ("Reading Config file now that it exists...")
rr = 1
cc = 1
fh=open(configfn,'r')
cfglines = fh.readlines()
fh.close()
for cfgline in cfglines:
items=cfgline.split('=')
if (items[0] == "rxfreq"):
rxfreq=float(items[1].strip())
savef=rxfreq
if (items[0] == "wpm"):
wpm=items[1].strip()
if (items[0] == "mycall"):
mycall=items[1].strip()
if (items[0] == "geom"):
geom=items[1].strip()
if (items[0] == "serport"):
serport=items[1].strip()
if (items[0] == "macro"):
macrocontents=items[1].strip()
MAKEMACBUT(macrocontents,rr,cc)
cc = cc + 1
if (cc > 5):
rr = rr + 1
cc = 1
return True
else:
print ("No config file yet.")
return None
def Quitter(*args):
GPIO.cleanup(keyer)
WriteCfg()
root.destroy()
def Send(p4,p3,p2,p1,co,vf):
global ser
ser.write(bytes([p4,p3,p2,p1,co]))
ser.flush()
if (vf == 0):
time.sleep(.10)
def SIMPLECMD(byt):
global rxfreq
bandstops = [ 0, 1.5, 3.5, 7, 10, 14, 18, 21, 24.5, 28, 30 ]
#
# RADIO QUIRK:
# The 160M band IS correct and mimics the radio when band
# down is pressed. 2.49999 then BAND DOWN on the radio
# results in being put in the 10M band.
#
# Other quirk:
# When going up 500k on front panel button:
# 29.49999 becomes 29.99999
# 29.50000 becomes 00.50000
# When going down 500k on front panel button:
# 00.50000 becomes 29.50000
# 00.99999 becomes 29.99999
bands = [
[ 1.5, 2.49999 ],
[ 3.5, 3.99999 ],
[ 7.0, 7.49999 ],
[ 10.0, 10.49999 ],
[ 14.0, 14.49999 ],
[ 18.0, 18.49999 ],
[ 21.0, 21.49999 ],
[ 24.5, 24.99999 ],
[ 28.0, 29.99999 ]
]
if (byt == 17 or byt == 18):
if (byt == 17):
if (rxfreq >= 29.5):
rxfreq = round(rxfreq -29,5)
else:
rxfreq = round(rxfreq + .5,5)
if (byt == 18):
if (rxfreq <= 0.99999):
rxfreq = round(rxfreq + 29,5)
else:
rxfreq = round(rxfreq - .5,5)
FREQ()
elif (byt == 7 or byt == 8):
mhz = int(rxfreq)
hun = int(int(rxfreq * 10) - (mhz * 10))
submhz = float(mhz)
if (hun >= 5):
submhz = submhz +float(5/10)
remmhz = rxfreq - submhz
nn = 0
jmpband=float(0)
for xx in bands:
if (rxfreq < bands[nn][0]):
print("You're below the "+str(bands[nn])+" band ")
if (byt == 7):
jmpband = float(bands[(nn)%9][0]);
if (byt == 8):
jmpband = float(bands[(nn - 1)%9][0]);
break
if (bands[nn][0] <= rxfreq <= bands[nn][1]):
print("You're in the "+str(bands[nn])+" band ")
if (byt == 7):
jmpband = float(bands[(nn + 1)%9][0]);
if (byt == 8):
jmpband = float(bands[(nn - 1)%9][0]);
break
else:
nn = nn + 1
rxfreq = round(float(jmpband + remmhz),5)
FREQ()
elif (byt == 10):
QSY()
else:
Send(0,0,0,0,byt,1)
def RXQSY(*args):
global txsav
global rxsav
global rxfreq
global txfreq
global savef
rxfreq=rxsav
txfreq=txsav
#rxfreq=float(ifreq.get())
#txfreq=float(itfreq.get())
FREQ()
def TXQSY(*args):
global txsav
global rxsav
global rxfreq
global txfreq
global savef
txsav=txfreq
rxsav=rxfreq
txfreq=float(ifreq.get())
rxfreq=float(itfreq.get())
FREQ()
def QSY(*args):
global rxfreq
rxfreq=float(ifreq.get())
txfreq=float(itfreq.get())
FREQ()
def FREQ():
global rxfreq
global txfreq
freq=(str(rxfreq).strip())
try:
dec = freq.index('.')
except:
freq = freq + '.'
if (rxfreq >= 10.00000):
freq = "0" + freq + "00000"
else:
freq = "00" + freq + "00000"
b1=int((freq[0:2]),16)
b2=int((freq[2]+freq[4]),16)
b3=int((freq[5:7]),16)
b4=int((freq[7:9]),16)
# 12.345.67 becomes hex 67|45|23|01|0B
co=int('0B',16)
Send(b4,b3,b2,b1,10,vfosplit)
ifreq.delete(0,END)
ifreq.insert(0,str('%7.5f' % (rxfreq)))
if (vfosplit == 0):
itfreq.delete(0,END)
itfreq.insert(0,str('%7.5f' % (rxfreq)))
txfreq=float(itfreq.get())
def ptt_on():
global keyer
GPIO.output(keyer,1)
lcw.config(bg='#00ff00')
root.update()
def ptt_off():
global keyer
lcw.config(bg='#005500')
root.update()
GPIO.output(keyer,0)
def KEY(ch):
global cw
global keyer
global wpm
global vfosplit
global rxfreq
global txfreq
global savef
t = (1200.0/float(wpm))/1000.0
ditlength = t
dahlength = ditlength * 3
if (ch == " "):
if (vfosplit == 1):
rxfreq=savef
FREQ()
True
else :
if (vfosplit == 1 and rxfreq != txfreq):
rxfreq=txfreq
FREQ()
for dd in cw[ch]:
if (dd == "-"):
ptt_on()
sleep(dahlength)
ptt_off()
sleep(ditlength)
if (dd == "."):
ptt_on()
sleep(ditlength)
ptt_off()
sleep(ditlength)
root.update()
# if (vfosplit == 1):
# rxfreq=savef
# FREQ()
sleep (dahlength)
root.update()
def BCLEAR():
cwinput.delete(0,END)
QCLEAR()
def QCLEAR():
global sending
sending = 0
queue.delete(0,END)
def QUEUE(*args):
if (queue.get() != ""):
queue.insert(END," ")
queue.insert(END,cwinput.get().upper())
cwinput.delete(0,END)
def STOP():
global sending
global rxfreq
global savef
sending = 0
lcw.config(bg='#d9d9d9')
rxfreq=savef
FREQ()
def STARTSEND():
global sending
global txfreq
global rxfreq
global savef
txfreq=float(itfreq.get())
savef=rxfreq
QUEUE()
if (sending == 0):
sending = 1
SENDCW()
def SENDCW():
global sending
global wpm
if (sending == 1):
wpm=iwpm.get()
qq = queue.get()
if (qq == ""):
print ("Nothing in queue")
sending = 0
return None
key = qq[0]
qq = qq[1:]
queue.delete(0,END)
queue.insert(0,qq)
# root.update()
KEY(key)
# root.update()
if (queue.get() != ""):
SENDCW()
else:
sending = 0
lcw.config(bg='#d9d9d9')
rxfreq=savef
FREQ()
root=Tk()
butframe=Frame(root,borderwidth=2,relief="groove")
qsyframe=Frame(root,borderwidth=2,relief="groove")
cwframe=Frame(root,borderwidth=2,relief="groove")
keysframe=Frame(root,borderwidth=2,relief="groove")
macroframe=Frame(root,borderwidth=2,relief="groove")
quickqsyframe=Frame(root,borderwidth=2,relief="groove")
helpframe=Frame(root,borderwidth=2,relief="groove")
ifreqframe=Frame(root,borderwidth=2,relief="groove")
dialbutframe=Frame(root,borderwidth=2,relief="groove")
root.bind("<Escape>",Quitter)
root.bind("<Control-w>",Quitter)
root.protocol("WM_DELETE_WINDOW", Quitter)
root.title("Yaesu FT-757GX (MK1)")
macroframe.bind("<ButtonRelease-3>",NEWMACRO)
# CW FRAME WIDGETS
lqueue = Label(cwframe, text="Queue:")
queue = Entry(cwframe, font="Courier", width=84)
lcw = Label(cwframe, text="CW:")
cwinput = Entry(cwframe, font="Courier", width=40, validate="key")
cwinput['validatecommand']=(cwinput.register(cwonly),'%P')
cwinput.bind("<Return>",QUEUE)
cwinput.bind("<KP_Enter>",QUEUE)
lwpm = Label(cwframe,text="wpm:")
iwpm = Entry(cwframe, font = "Courier", width=2)
clr = Button(cwframe,text="clear queue", command=QCLEAR, width=8, fg="white",bg="blue")
clrb = Button(cwframe,text="clear both", command=BCLEAR, width=8, fg="white",bg="blue")
qcw = Button(cwframe,text="queue", command=QUEUE, width=8, bg="yellow")
bcw = Button(cwframe,text="GO", command=STARTSEND, width=8, bg="green")
scw = Button(cwframe,text="STOP", command=STOP, width=8, bg="red")
#HELP
hlabel=Label(helpframe,text="")
# CALLSIGN FRAME
lmycall = Label(keysframe, text="Your Station's Call:")
imycall = Entry(keysframe, width=13, validate="key", justify="center")
imycall['validatecommand']=(imycall.register(alnumslashonly),'%P')
lothercall = Label(keysframe, text="Other Station's Call:")
iothercall = Entry(keysframe, width=13, validate="key", justify="center")
iothercall['validatecommand']=(iothercall.register(alnumslashonly),'%P')
lnotes = Label(keysframe, text="<C> is replaced with your call. <I> is replaced with other station's call.")
ifreq = Entry(ifreqframe, font="Helvetica 44 bold", justify="center", width=9)
ifreq.bind("<Return>",QSY)
ifreq.bind("<KP_Enter>",QSY)
itfreq = Entry(ifreqframe, font="Helvetica 14 bold", justify="center", width=9, bg='grey')
itfreq.bind("<Button-1>",TXQSY)
itfreq.bind("<ButtonRelease-1>",RXQSY)
splu = Button(ifreqframe, text="up 1000", justify="center", width=6, command=SPLU, fg='grey')
vspl = Button(ifreqframe, text="Unbind", justify="center", width=6, command=VSPL)
spld = Button(ifreqframe, text="dn 1000", justify="center", width=6, command=SPLD, fg='grey')
splsu = Button(ifreqframe, text=">>", justify="center", width=2, fg='grey')
splsd = Button(ifreqframe, text="<<", justify="center", width=2, fg='grey')
spllb = Label(ifreqframe, text="(tx freq)")
# RADIO BUTTONS
split = Button(butframe,text="SPLIT", command=lambda: SIMPLECMD(1), width=11) #1
mrvfo = Button(butframe,text="MR/VFO", command=lambda: SIMPLECMD(2), width=11) #2
vtom = Button(butframe,text="V -> M", command=lambda: SIMPLECMD(3), width=11) #3
dlock = Button(dialbutframe,text="D LOCK", command=lambda: SIMPLECMD(4), width=11) #4
vfoab = Button(butframe,text="VFO A/B", command=lambda: SIMPLECMD(5), width=11) #5
mtov = Button(butframe,text="M -> V", command=lambda: SIMPLECMD(6), width=11) #6
bandup = Button(butframe,text="BAND UP", command=lambda: SIMPLECMD(7), width=11) #7
banddn = Button(butframe,text="BAND DN", command=lambda: SIMPLECMD(8), width=11) #8
clar = Button(dialbutframe,text="CLAR", command=lambda: SIMPLECMD(9), width=11) #9
freq = Button(dialbutframe,text="QSY", command=lambda: SIMPLECMD(10), width=11) #10
vmswap = Button(butframe,text="V<>M", command=lambda: SIMPLECMD(11), width=11) #11
datelab = Label (butframe, font="Helvetica 12 bold", text="YYYY-MM-DDDD HH:MM", width=23)
up500k = Button(butframe,text="500k ^", command=lambda: SIMPLECMD(17), width=11) #17 (made up)
dn500k = Button(butframe,text="500k v", command=lambda: SIMPLECMD(18), width=11) #18 (made up)
ptt = Button(dialbutframe,text="PTT", width=11)
tune = Button(dialbutframe,text="TUNE", width=11)
# VFO SPINNERS
u1000 = Button(qsyframe,text=">1000>", width=5)
u500 = Button(qsyframe,text=">500>", width=5)
u100 = Button(qsyframe,text=">100>", width=5)
u10 = Button(qsyframe,text=">10>", width=5)
spinnything = Label (qsyframe,text=" ",font="Helvetica 16 bold", width=3)
d10 = Button(qsyframe,text="<10<", width=5)
d500 = Button(qsyframe,text="<500<", width=5)
d100 = Button(qsyframe,text="<100<", width=5)
d1000 = Button(qsyframe,text="<1000<", width=5)
ptt.bind('<Button-1>',lambda evt, val = 1: pttaction(val))
ptt.bind('<ButtonRelease-1>',lambda evt, val=0: pttaction(val))
tune.bind('<Button-1>',lambda evt, val = float(10): starttuning(val))
splsu.bind('<Button-1>',lambda evt, val = float(.00001): startspinningt(val))
splsu.bind('<ButtonRelease-1>',stopspinningt)
splsd.bind('<Button-1>',lambda evt, val = float(-.00001): startspinningt(val))
splsd.bind('<ButtonRelease-1>',stopspinningt)
u1000.bind('<Button-1>',lambda evt, val = float(.001): startspinning(val))
u1000.bind('<ButtonRelease-1>',stopspinning)
u500.bind('<Button-1>',lambda evt, val = float(.0005): startspinning(val))
u500.bind('<ButtonRelease-1>',stopspinning)
u100.bind('<Button-1>',lambda evt, val = float(.0001): startspinning(val))
u100.bind('<ButtonRelease-1>',stopspinning)
u10.bind('<Button-1>',lambda evt, val = float(.00001): startspinning(val))
u10.bind('<ButtonRelease-1>',stopspinning)
d10.bind('<Button-1>',lambda evt, val = float(-.00001): startspinning(val))
d10.bind('<ButtonRelease-1>',stopspinning)
d100.bind('<Button-1>',lambda evt, val = float(-.0001): startspinning(val))
d100.bind('<ButtonRelease-1>',stopspinning)
d500.bind('<Button-1>',lambda evt, val = float(-.0005): startspinning(val))
d500.bind('<ButtonRelease-1>',stopspinning)
d1000.bind('<Button-1>',lambda evt, val = float(-.001): startspinning(val))
d1000.bind('<ButtonRelease-1>',stopspinning)
rr = 2
cc = 1
qqsym={}
qqmen={}
qqsv={}
dummy=""
quickqsyframeleg=Frame(quickqsyframe)
quickqsyframeleg.grid(row=1,column=1,columnspan=10)
Label(quickqsyframeleg, text="Quick QSY, E/Extra, A/Advanced, G/General, T/Tech, t/Tech CW Only, N/Novice, n/Novice CW Only").grid(row=1,column=1)
Label(quickqsyframeleg, text="CW", bg="red").grid(row=1,column=2)
Label(quickqsyframeleg, text="end CW / begin Phone", bg="yellow").grid(row=1,column=3)
Label(quickqsyframeleg, text="Phone", bg="green").grid(row=1,column=4)
hover(quickqsyframeleg,"This area is the legend for Quick QSY. Hopefully, it closely mimics the band plan.")
# QUICK QSY buttons construction
for qq in qqsy:
if (qq[0] == "dd"):
qqsv[qq[1]]=StringVar(quickqsyframe)
qqsv[qq[1]].set(qq[1])
qqsym[qq[1]]=OptionMenu(quickqsyframe,qqsv[qq[1]],qq[1])
qqsym[qq[1]].grid(row=rr,column=cc)
hover(qqsym[qq[1]],"Press and hold to choose one of the frequencies in the list.")
cc = cc + 1
qqmen[qq[1]]=qqsym[qq[1]].children["menu"]
for qfreq in qq:
if (qfreq == qq[0] or qfreq == qq[1]):
continue
zz=lambda mkr=qfreq: QUICKQSY(mkr)
qqmen[qq[1]].add_command(label=qfreq, command=zz)
if (qq[0] == "bb"):
bb=Button(quickqsyframe,\