Skip to content

Commit 36263ab

Browse files
committed
Update for juliac use (@main routine)
1 parent 9fc864e commit 36263ab

File tree

2 files changed

+43
-41
lines changed

2 files changed

+43
-41
lines changed

src/GUI.jl

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function start_runtime(sdr,carrierFreq,samplingRate,gain,acquisition;kw...)
294294
# --- Create GUI
295295
# ----------------------------------------------------
296296
# --- Define the Grid Layout
297-
figure = Figure(backgroundcolor=:lightgrey,resolution=(1800,1200))
297+
figure = Figure(backgroundcolor=:lightgrey,size=(1400,1000))
298298
panelImage = figure[1:2, 1:3] = GridLayout()
299299
panelRefresh = figure[3, 1:4] = GridLayout()
300300
panelYt = figure[4, 1:4] = GridLayout()
@@ -310,45 +310,46 @@ function start_runtime(sdr,carrierFreq,samplingRate,gain,acquisition;kw...)
310310
delay = collect(50 : 90)
311311
corr = zeros(Float32,length(delay))
312312
ScreenRenderer._plotInteractiveCorrelation(axT,delay,corr,OBS_fv[],:turquoise4)
313+
fontsize = 18
313314
# The zoomed correlation
314315
axZ = Makie.Axis(panelYt[1,1])
315316
ScreenRenderer._plotInteractiveCorrelation(axZ,delay,corr,0.0,:gold4)
316317
# Run mode
317-
btnStart = Button(panelInfo[1,1], label = "START", fontsize=35,halign=:center,tellwidth=false,tellheight=true,cornerradius=12,buttoncolor=RGBf(0.67, 0.91, 0.77))
318+
btnStart = Button(panelInfo[1,1], label = "START", fontsize=fontsize,halign=:center,tellwidth=false,tellheight=true,cornerradius=12,buttoncolor=RGBf(0.67, 0.91, 0.77))
318319
# Panel to Exit
319-
bttnKill = Button(panelInfo[1,2], label = "Exit", fontsize=40,halign=:center,tellwidth=true,tellheight=false,cornerradius=12,buttoncolor=RGBf(0.96, 0.71, 0.69))
320+
bttnKill = Button(panelInfo[1,2], label = "Exit", fontsize=fontsize,halign=:center,tellwidth=true,tellheight=false,cornerradius=12,buttoncolor=RGBf(0.96, 0.71, 0.69))
320321
# Refresh panel
321-
l_fv = Label(panelInfo[2,1], "Refresh Rate",tellwidth = false,fontsize=24,halign=:left)
322-
boxRefresh = Textbox(panelInfo[2,2], placeholder = "Refresh Rate",validator = Float64, tellwidth = false,fontsize=24,halign=:left)
322+
l_fv = Label(panelInfo[2,1], "Refresh Rate",tellwidth = false,fontsize=fontsize,halign=:left)
323+
boxRefresh = Textbox(panelInfo[2,2], placeholder = "Refresh Rate",validator = Float64, tellwidth = false,fontsize=fontsize,halign=:left)
323324
# Panel for yt
324-
l_yt = Label(panelInfo[3,1], "Height size",tellwidth = false,fontsize=24,halign=:left)
325-
boxYt = Textbox(panelInfo[3,2], placeholder = "$(OBS_yt[])",validator = Int64, tellwidth = false,fontsize=24,halign=:left)
325+
l_yt = Label(panelInfo[3,1], "Height size",tellwidth = false,fontsize=fontsize,halign=:left)
326+
boxYt = Textbox(panelInfo[3,2], placeholder = "$(OBS_yt[])",validator = Int64, tellwidth = false,fontsize=fontsize,halign=:left)
326327
panelInfo[3, 3] = buttongrid = GridLayout(tellwidth = false,halign=:left)
327-
btnYt_plus = Button(buttongrid[1,1], label = "+", tellwidth = false,fontsize=24,halign=:left,width=20)
328-
btnYt_minus = Button(buttongrid[2,1], label = "-", tellwidth = false,fontsize=24,halign=:left,width=20)
328+
btnYt_plus = Button(buttongrid[1,1], label = "+", tellwidth = false,fontsize=fontsize,halign=:left,width=20)
329+
btnYt_minus = Button(buttongrid[2,1], label = "-", tellwidth = false,fontsize=fontsize,halign=:left,width=20)
329330
rowgap!(buttongrid,0.15)
330331
# Panel to redo correlation
331-
bttnCorr = Button(panelInfo[4,1], label = "Correlate !", fontsize=35,halign=:left,cornerradius=12)
332+
bttnCorr = Button(panelInfo[4,1], label = "Correlate !", fontsize=fontsize,halign=:left,cornerradius=12)
332333
# Slider for Radio gain
333-
l_gain = Label(panelInfo[5,1], "Radio Gain",tellwidth = false,fontsize=24,halign=:left)
334+
l_gain = Label(panelInfo[5,1], "Radio Gain",tellwidth = false,fontsize=fontsize,halign=:left)
334335
sliderGain = Slider(panelInfo[5,2], range = 0:1:50, startvalue = 3)
335336
# SDR carrier frequency
336-
l_freq = Label(panelInfo[6,1], "Carrier freq (MHz)",tellwidth = false,fontsize=24,halign=:left)
337-
boxFreq = Textbox(panelInfo[6,2], placeholder = "$(HztoMHz(carrierFreq))",validator = Float64, tellwidth = false,fontsize=24,halign=:left)
337+
l_freq = Label(panelInfo[6,1], "Carrier freq (MHz)",tellwidth = false,fontsize=fontsize,halign=:left)
338+
boxFreq = Textbox(panelInfo[6,2], placeholder = "$(HztoMHz(carrierFreq))",validator = Float64, tellwidth = false,fontsize=fontsize,halign=:left)
338339
# SDR carrier frequency
339-
l_samp = Label(panelInfo[7,1], "Sample Rate (MHz)",tellwidth = false,fontsize=24,halign=:left)
340-
boxSamp = Textbox(panelInfo[7,2], placeholder = "$(HztoMHz(samplingRate))",validator = Float64, tellwidth = false,fontsize=24,halign=:left)
340+
l_samp = Label(panelInfo[7,1], "Sample Rate (MHz)",tellwidth = false,fontsize=fontsize,halign=:left)
341+
boxSamp = Textbox(panelInfo[7,2], placeholder = "$(HztoMHz(samplingRate))",validator = Float64, tellwidth = false,fontsize=fontsize,halign=:left)
341342
# LPF coefficient
342-
l_filt = Label(panelInfo[8,1], "Low pass filter",tellwidth = false,fontsize=24,halign=:left)
343+
l_filt = Label(panelInfo[8,1], "Low pass filter",tellwidth = false,fontsize=fontsize,halign=:left)
343344
sliderLPF = Slider(panelInfo[8,2], range = Float32.(0:0.05:1), startvalue = Float32(OBS_α[]))
344345
# Panel for configuration
345-
l_config = Label(panelInfo[9,1], "Configuration ",tellwidth = false,fontsize=24,halign=:left)
346-
l_config_out = Label(panelInfo[9,2], "$(getDescription(VIDEO_CONFIG)[1])",tellwidth = false,fontsize=24,halign=:left)
346+
l_config = Label(panelInfo[9,1], "Configuration ",tellwidth = false,fontsize=fontsize,halign=:left)
347+
l_config_out = Label(panelInfo[9,2], "$(getDescription(VIDEO_CONFIG)[1])",tellwidth = false,fontsize=fontsize,halign=:left)
347348
# Panel for configuration
348-
#l_config = Label(panelInfo[9,1], "Frame size (theo) ",tellwidth = false,fontsize=24,halign=:left)
349-
#l_config_th = Label(panelInfo[9,2], "$(getDescription(VIDEO_CONFIG)[2])",tellwidth = false,fontsize=24,halign=:left)
349+
#l_config = Label(panelInfo[9,1], "Frame size (theo) ",tellwidth = false,fontsize=fontsize,halign=:left)
350+
#l_config_th = Label(panelInfo[9,2], "$(getDescription(VIDEO_CONFIG)[2])",tellwidth = false,fontsize=fontsize,halign=:left)
350351
# Panel to redo correlation
351-
bttnRecord = Button(panelInfo[4,2], label = "Record !", fontsize=35,halign=:left,cornerradius=12,buttoncolor=RGBf(0.56, 0.71, 0.69))
352+
bttnRecord = Button(panelInfo[4,2], label = "Record !", fontsize=fontsize,halign=:left,cornerradius=12,buttoncolor=RGBf(0.56, 0.71, 0.69))
352353
353354
# Display the image
354355
display(figure)
@@ -693,7 +694,7 @@ function gui(;
693694
end
694695
# Start the runtime
695696
tup = start_runtime(sdr,carrierFreq,samplingRate,gain,acquisition;kw...)
696-
@async begin
697+
begin
697698
while(FLAG_KILL == false)
698699
sleep(0.1)
699700
yield()

src/TempestSDR.jl

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ export stop_runtime
6161

6262
""" Parse Keywords and returns the value based on ARGS. If the parameter is not given, return a default value
6363
"""
64-
function get_args(arg,default::T) where T
64+
function get_args(ARGS,arg,default::T) where T
6565
# Find good argument in list of args
6666
goodLine = findall(occursin.(arg,ARGS))
67-
6867
# If not present, get base value
6968
if isempty(goodLine)
7069
if default == nothing
@@ -86,8 +85,7 @@ end
8685

8786
""" Create additionnal keywords as a NamedTuple
8887
"""
89-
function get_kw()
90-
excep = ["sdr","carrierFreq","samplingRate","gain"]
88+
function get_kw(ARGS,excep)
9189
# --- Serve as container for final tuple generation
9290
inList = ()
9391
outList = []
@@ -110,20 +108,19 @@ function get_kw()
110108
end
111109

112110

113-
114-
115-
116111
""" This is a sandbox function to generate an app
117112
"""
118-
function julia_main()::Cint
113+
function @main(ARGS::Vector{String})::Cint
119114
#include("config.jl")
120-
121-
sdr = get_args("sdr",:radiosim)
122-
carrierFreq = get_args("carrierFreq",868e6)
123-
samplingRate = get_args("samplingRate",4e6)
124-
acquisition = get_args("acquisition",0.05)
125-
gain = get_args("gain",10)
126-
kw = get_kw()
115+
# --- Core parameters
116+
sdr = get_args(ARGS,"sdr",:radiosim)
117+
carrierFreq = get_args(ARGS,"carrierFreq",868e6)
118+
samplingRate = get_args(ARGS,"samplingRate",4e6)
119+
acquisition = get_args(ARGS,"acquisition",0.05)
120+
gain = get_args(ARGS,"gain",10)
121+
# Additional are keywords
122+
excep = ["sdr","carrierFreq","samplingRate","gain"]
123+
kw = get_kw(ARGS,excep)
127124
# This should import all we need
128125
tup = gui(;
129126
sdr,
@@ -133,11 +130,15 @@ function julia_main()::Cint
133130
acquisition,
134131
kw...
135132
)
133+
# println("🟢 Press Ctrl+C to quit.")
134+
#try while(true)
135+
#sleep(0.5)
136+
#yield()
137+
#end
138+
#catch exception
139+
#end
140+
#println("End of application")
136141
return 0
137142
end
138143

139-
140-
141-
142-
143144
end

0 commit comments

Comments
 (0)