Skip to content

Commit c96582e

Browse files
author
Jon
committed
Add icon to wxtx
1 parent c704770 commit c96582e

File tree

4 files changed

+198
-16
lines changed

4 files changed

+198
-16
lines changed

fpga_tx/favicon.ico

4.19 KB
Binary file not shown.

fpga_tx/wxtx.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,8 @@ def update_plot(self, event):
226226
self.axes.draw_artist(self.line)
227227
self.figure.canvas.blit()
228228

229-
def on_preset(self, event):
230-
preset_name = sorted(presets.keys())[self.presets.GetCurrentSelection()]
231-
frequency, frequency_units, cutoff, deviation, mode = presets[str(preset_name)]
229+
def settings2gui(self, evt=None):
230+
frequency, frequency_units, cutoff, deviation, mode = self.settings
232231
self.frequency.SetValue(str(frequency))
233232
self.frequency_units.SetSelection(units.index(frequency_units))
234233
self.lpf.SetValue(str(cutoff))
@@ -247,18 +246,27 @@ def on_preset(self, event):
247246
elif mode.upper() == "STEREO":
248247
self.fm_deviation.Enable()
249248

249+
def gui2settings(self, evt=None):
250+
frequency = float(self.frequency.GetValue())
251+
frequency_units = units[self.frequency_units.GetCurrentSelection()]
252+
cutoff = float(self.lpf.GetValue())
253+
deviation = float(self.fm_deviation.GetValue())
254+
mode = modes[self.mode.GetCurrentSelection()]
255+
self.settings = frequency, frequency_units, cutoff, deviation, mode
256+
257+
def on_preset(self, event):
258+
preset_name = sorted(presets.keys())[self.presets.GetCurrentSelection()]
259+
self.settings = presets[str(preset_name)]
260+
self.settings2gui()
261+
250262
def on_save_preset(self, event):
251263
dlg = wx.TextEntryDialog(
252264
self, 'Create Preset')
253265

266+
self.gui2settings()
254267
if dlg.ShowModal() == wx.ID_OK:
255268
preset_name = dlg.GetValue()
256-
frequency = float(self.frequency.GetValue())
257-
frequency_units = units[self.frequency_units.GetCurrentSelection()]
258-
cutoff = float(self.lpf.GetValue())
259-
deviation = float(self.fm_deviation.GetValue())
260-
mode = modes[self.mode.GetCurrentSelection()]
261-
presets[str(preset_name)] = [frequency, frequency_units, cutoff, deviation, mode]
269+
presets[str(preset_name)] = self.settings
262270
presets.sync()
263271
self.presets.SetItems(sorted(presets.keys()))
264272

@@ -316,18 +324,14 @@ def on_mode(self, event):
316324
self.fm_deviation.SetValue("150000")
317325
self.fm_deviation.Enable()
318326

319-
320327
def on_transmit(self, event):
321328
if event.IsChecked():
322-
frequency = float(self.frequency.GetValue())
323-
frequency_units = units[self.frequency_units.GetCurrentSelection()]
329+
self.gui2settings()
330+
frequency, frequency_units, cutoff, deviation, mode = self.settings
324331
if frequency_units == "MHz":
325332
frequency *= 1e6
326333
elif frequency_units == "kHz":
327334
frequency *= 1e3
328-
cutoff = float(self.lpf.GetValue())
329-
deviation = float(self.fm_deviation.GetValue())
330-
mode = modes[self.mode.GetCurrentSelection()]
331335
source = sources[self.source.GetCurrentSelection()]
332336
input_file = self.input_file_button.GetValue()
333337
(
@@ -350,5 +354,7 @@ def on_transmit(self, event):
350354
app = wx.PySimpleApp()
351355
fr = wx.Frame(None, size=(500, 600), title='wxtx')
352356
panel = CanvasPanel(fr)
357+
favicon = wx.Icon(os.path.join(os.path.dirname(__file__), 'favicon.ico'), wx.BITMAP_TYPE_ICO, 16, 16)
358+
fr.SetIcon(favicon)
353359
fr.Show()
354360
app.MainLoop()

psk31_encode.py

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
varicodes = [
2+
"1010101011", #00 NUL Null character
3+
"1011011011", #01 SOH Start of Header
4+
"1011101101", #02 STX Start of Text
5+
"1101110111", #03 ETX End of Text
6+
"1011101011", #04 EOT End of Transmission
7+
"1101011111", #05 ENQ Enquiry
8+
"1011101111", #06 ACK Acknowledgment
9+
"1011111101", #07 BEL Bell
10+
"1011111111", #08 BS Backspace
11+
"11101111", #09 HT Horizontal Tab
12+
"11101", #0A LF Line feed
13+
"1101101111", #0B VT Vertical Tab
14+
"1011011101", #0C FF Form feed
15+
"11111", #0D CR Carriage return
16+
"1101110101", #0E SO Shift Out
17+
"1110101011", #0F SI Shift In
18+
"1011110111", #10 DLE Data Link Escape
19+
"1011110101", #11 DC1 Device Control 1 (XON)
20+
"1110101101", #12 DC2 Device Control 2
21+
"1110101111", #13 DC3 Device Control 3 (XOFF)
22+
"1101011011", #14 DC4 Device Control 4
23+
"1101101011", #15 NAK Negative Acknowledgement
24+
"1101101101", #16 SYN Synchronous Idle
25+
"1101010111", #17 ETB End of Trans. Block
26+
"1101111011", #18 CAN Cancel
27+
"1101111101", #19 EM End of Medium
28+
"1110110111", #1A SUB Substitute
29+
"1101010101", #1B ESC Escape
30+
"1101011101", #1C FS File Separator
31+
"1110111011", #1D GS Group Separator
32+
"1011111011", #1E RS Record Separator
33+
"1101111111", #1F US Unit Separator
34+
"1", #20 SP
35+
"111111111", #21 !
36+
"101011111", #22 "
37+
"111110101", #23 #
38+
"111011011", #24 $
39+
"1011010101", #25 %
40+
"1010111011", #26 &
41+
"101111111", #27 '
42+
"11111011", #28 (
43+
"11110111", #29 )
44+
"101101111", #2A *
45+
"111011111", #2B +
46+
"1110101", #2C ,
47+
"110101", #2D -
48+
"1010111", #2E .
49+
"110101111", #2F /
50+
"10110111", #30 0
51+
"10111101", #31 1
52+
"11101101", #32 2
53+
"11111111", #33 3
54+
"101110111", #34 4
55+
"101011011", #35 5
56+
"101101011", #36 6
57+
"110101101", #37 7
58+
"110101011", #38 8
59+
"110110111", #39 9
60+
"11110101", #3A :
61+
"110111101", #3B ;
62+
"111101101", #3C <
63+
"1010101", #3D =
64+
"111010111", #3E >
65+
"1010101111", #3F ?
66+
"1010111101", #40 @
67+
"1111101", #41 A
68+
"11101011", #42 B
69+
"10101101", #43 C
70+
"10110101", #44 D
71+
"1110111", #45 E
72+
"11011011", #46 F
73+
"11111101", #47 G
74+
"101010101", #48 H
75+
"1111111", #49 I
76+
"111111101", #4A J
77+
"101111101", #4B K
78+
"11010111", #4C L
79+
"10111011", #4D M
80+
"11011101", #4E N
81+
"10101011", #4F O
82+
"11010101", #50 P
83+
"111011101", #51 Q
84+
"10101111", #52 R
85+
"1101111", #53 S
86+
"1101101", #54 T
87+
"101010111", #55 U
88+
"110110101", #56 V
89+
"101011101", #57 W
90+
"101110101", #58 X
91+
"101111011", #59 Y
92+
"1010101101", #5A Z
93+
"111110111", #5B [
94+
"111101111", #5C \
95+
"111111011", #5D ]
96+
"1010111111", #5E ^
97+
"101101101", #5F _
98+
"1011011111", #60 `
99+
"1011", #61 a
100+
"1011111", #62 b
101+
"101111", #63 c
102+
"101101", #64 d
103+
"11", #65 e
104+
"111101", #66 f
105+
"1011011", #67 g
106+
"101011", #68 h
107+
"1101", #69 i
108+
"111101011", #6A j
109+
"10111111", #6B k
110+
"11011", #6C l
111+
"111011", #6D m
112+
"1111", #6E n
113+
"111", #6F o
114+
"111111", #70 p
115+
"110111111", #71 q
116+
"10101", #72 r
117+
"10111", #73 s
118+
"101", #74 t
119+
"110111", #75 u
120+
"1111011", #76 v
121+
"1101011", #77 w
122+
"11011111", #78 x
123+
"1011101", #79 y
124+
"111010101", #7A z
125+
"1010110111", #7B {
126+
"110111011", #7C |
127+
"1010110101", #7D }
128+
"1011010111", #7E ~
129+
"1110110101", #7F DEL
130+
]
131+
132+
import struct
133+
import sys
134+
135+
import numpy as np
136+
import matplotlib.pyplot as plt
137+
import scipy.signal as signal
138+
import scipy.io.wavfile as wav
139+
140+
def encode(message, sample_rate, baud_rate, subcarrier_frequency):
141+
n = sample_rate//baud_rate
142+
143+
#varicode message
144+
varicoded = "".join([varicodes[ord(i)]+"00" for i in message])
145+
varicoded = "1111110000" + varicoded + "000001111111"
146+
147+
#phase code
148+
one = np.ones(n)
149+
zero = np.concatenate([
150+
np.cos(np.linspace(0, np.pi, n/2))+1,
151+
np.cos(np.linspace(0, np.pi, n/2))-1
152+
])*0.5
153+
154+
phase = 1
155+
phase_codes = []
156+
for i in varicoded:
157+
if i=='1':
158+
phase_codes.append(phase*one)
159+
else:
160+
phase_codes.append(phase*zero)
161+
phase *= -1
162+
phase_coded = np.concatenate(phase_codes)
163+
164+
165+
#add subcarrier
166+
t = np.arange(0, len(phase_coded))
167+
subcarrier = np.sin(2*np.pi*t*subcarrier_frequency/sample_rate)
168+
169+
plt.plot(phase_coded*subcarrier)
170+
plt.show()
171+
return phase_coded * subcarrier
172+
173+
pcm_fp = encode("hello world", 8000, 31.25, 1000)*0.5
174+
wav.write("psk.wav", 8000, pcm_fp)
175+

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
url='https://github.com/dawsonjon/FPGA-TX',
88
version='1.0',
99
scripts=['tx', 'wxtx'],
10-
packages=find_packages()
10+
packages=find_packages(),
11+
package_data={'fpga_tx': ['favicon.ico']}
1112
)

0 commit comments

Comments
 (0)