Skip to content

Commit

Permalink
update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
semuadmin committed Dec 5, 2024
1 parent 4744348 commit 8818e9e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
5 changes: 3 additions & 2 deletions pygpsclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"Spectrum": false,
"System Monitor": false,
"Scatter Plot": false,
"checkforupdate_b": 0,
"mapupdateinterval_n": 60,
"defaultport_s": "USB",
"mqapikey_s": "<======= YOUR MQ API KEY ======>",
Expand Down Expand Up @@ -110,8 +111,8 @@
"spartndecode_b": 0,
"spartnkey_s": "abcd1234abcd1234abcd1234abcd1234",
"spartnbasedate_n": -1,
"checkforupdate_b": 0,
"scattersettings_d": {
"maxpoints_n": 2000,
"scatterautorange_b": 1,
"scattercenter_s": "Average",
"scatterinterval_n": 1,
Expand All @@ -122,7 +123,7 @@
"chartsettings_d": {
"numchn_n": 4,
"timrng_n": "240",
"datpnt_n": "2000",
"maxpoints_n": "2000",
"0": {
"id_s": "NAV-PVT",
"name_s": "hAcc",
Expand Down
20 changes: 10 additions & 10 deletions src/pygpsclient/chart_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __init__(self, app, *args, **kwargs):
self._mintim = 1e20
self._maxtim = 0
self._timrange = StringVar()
self._datapoints = StringVar()
self._maxpoints = StringVar()
for chn in range(self._num_chans):
self._data_id[chn] = StringVar()
self._data_name[chn] = StringVar()
Expand Down Expand Up @@ -219,7 +219,7 @@ def _body(self):
fg=LBLCOL,
bg=BGCOL,
)
self._lbl_datapoints = Label(
self._lbl_maxpoints = Label(
self,
text="Max Points/Chan",
fg=LBLCOL,
Expand Down Expand Up @@ -298,11 +298,11 @@ def _body(self):
fg=LBLCOL,
readonlybackground=BGCOL,
)
self._spn_datapoints = Spinbox(
self._spn_maxpoints = Spinbox(
self,
values=DPTRANGE,
wrap=True,
textvariable=self._datapoints,
textvariable=self._maxpoints,
state=READONLY,
repeatdelay=RPTDELAY,
repeatinterval=RPTDELAY,
Expand Down Expand Up @@ -330,8 +330,8 @@ def _do_layout(self):
self._spn_maxy[chn].grid(column=4, row=2 + chn, sticky=(W, E))
self._lbl_timrange.grid(column=5, row=1, sticky=(W, E))
self._spn_timrange.grid(column=5, row=2, sticky=(W, E))
self._lbl_datapoints.grid(column=5, row=3, sticky=(W, E))
self._spn_datapoints.grid(column=5, row=4, sticky=(W, E))
self._lbl_maxpoints.grid(column=5, row=3, sticky=(W, E))
self._spn_maxpoints.grid(column=5, row=4, sticky=(W, E))

def _attach_events(self):
"""
Expand All @@ -343,7 +343,7 @@ def _attach_events(self):
self._can_chartview.bind("<Double-Button-2>", self._on_clipboard)
self._can_chartview.bind("<Double-Button-3>", self._on_clipboard)
self._timrange.trace_add("write", self._on_save_settings)
self._datapoints.trace_add("write", self._on_save_settings)
self._maxpoints.trace_add("write", self._on_save_settings)
for chn in range(self._num_chans):
self._data_id[chn].trace_add("write", self._on_save_settings)
self._data_name[chn].trace_add("write", self._on_save_settings)
Expand All @@ -357,7 +357,7 @@ def reset(self):
"""

self._timrange.set(self.chartsettings.get("timrng_n", TIMRANGE[3])) # 60s
self._datapoints.set(self.chartsettings.get("datpnt_n", DPTRANGE[2])) # 5000
self._maxpoints.set(self.chartsettings.get("maxpoints_n", DPTRANGE[2])) # 5000
for chn in range(self._num_chans):
cst = self.chartsettings.get(str(chn), {})
self._data_id[chn].set(cst.get("id_s", ""))
Expand Down Expand Up @@ -429,7 +429,7 @@ def update_data(self, parsed_data: object):
"""

try:
maxpoints = int(self._datapoints.get())
maxpoints = int(self._maxpoints.get())
except ValueError:
maxpoints = DPTRANGE[2] # 5000

Expand Down Expand Up @@ -710,7 +710,7 @@ def _on_save_settings(self, var, index, mode): # pylint: disable=unused-argumen
cst = {}
cst["numchn_n"] = self._num_chans
cst["timrng_n"] = self._timrange.get()
cst["datpnt_n"] = self._datapoints.get()
cst["maxpoints_n"] = self._maxpoints.get()
for chn in range(self._num_chans):
cst[chn] = {}
cst[chn]["id_s"] = self._data_id[chn].get()
Expand Down
7 changes: 4 additions & 3 deletions src/pygpsclient/scatter_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def __init__(self, app, *args, **kwargs):

self.width = kwargs.get("width", def_w)
self.height = kwargs.get("height", def_h)
# self._font = font.Font(size=max(int(self.height / 40), 10))
self._font = self.__app.font_sm
self._fonth = fontheight(self._font)
self._points = []
Expand All @@ -125,6 +124,7 @@ def __init__(self, app, *args, **kwargs):
self._scale = IntVar()
self._reflat = StringVar()
self._reflon = StringVar()
self._maxpoints = config.get("maxpoints_n", MAXPOINTS)
reflat = config.get("scatterlat_f", 0.0)
reflon = config.get("scatterlon_f", 0.0)
self._reflat.set("Reference Lat" if reflat == 0.0 else reflat)
Expand Down Expand Up @@ -312,6 +312,7 @@ def _on_save_settings(self, var, index, mode): # pylint: disable=unused-argumen
"""

sst = {}
sst["maxpoints_n"] = self._maxpoints
sst["scatterautorange_b"] = self._autorange.get()
sst["scattercenter_s"] = self._centermode.get()
sst["scatterinterval_n"] = self._interval.get()
Expand Down Expand Up @@ -394,7 +395,7 @@ def _draw_stats(self, lbl_font: object):
)
y += fh
np = len(self._points)
pts = f"Pts: {np} {'!' if np >= MAXPOINTS else ''}"
pts = f"Pts: {np} {'!' if np >= self._maxpoints else ''}"
self.canvas.create_text(
5, y, text=pts, fill=PNTCOL, font=lbl_font, anchor=NW, tags=AVG
)
Expand Down Expand Up @@ -522,7 +523,7 @@ def update_frame(self):
return # Don't repeat exactly the last point.

self._points.append(pos)
if len(self._points) > MAXPOINTS:
if len(self._points) > self._maxpoints:
self._cull_points()

self._set_average()
Expand Down

0 comments on commit 8818e9e

Please sign in to comment.