Skip to content

Commit

Permalink
fix overload on ohms and autoscaling trendline
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dombrowski authored and Michael Dombrowski committed Feb 21, 2016
1 parent 5f03bcd commit 21c3ccf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TODO:
Add more settings
Handle ovld on Ohms

DONE:
Make measurement updates non render-blocking
Make measurement updates non render-blocking
Handle ovld on Ohms
34 changes: 25 additions & 9 deletions dmm_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def create_main_panel(self):
# Top Block
self.hbox3 = wx.BoxSizer(wx.HORIZONTAL)
self.mainNum = wx.TextCtrl(self.panel, -1, "", size=(440, 90))
self.mainNum.SetFont(wx.Font(40, wx.DECORATIVE, wx.NORMAL, wx.NORMAL))
self.mainNum.SetFont(wx.Font(48, wx.DECORATIVE, wx.NORMAL, wx.NORMAL))
self.vbox6 = wx.BoxSizer(wx.VERTICAL)
self.hbox4 = wx.BoxSizer(wx.HORIZONTAL)
self.vbox6.Add(self.mainNum, border=5, flag=wx.ALL)
Expand Down Expand Up @@ -411,18 +411,31 @@ def draw_plot(self):
else:
xmin = int(self.xmin_control.manual_value())
if self.ymin_control.is_auto():
mins = min(self.data[xmin:xmax])
ymin = float(mins-(mins*.05))
if xmax == self.dataval.getlen() and xmin == 0:
mins = self.dataval.getmin()
else:
mins = min(self.data[xmin:xmax])
else:
ymin = float(self.ymin_control.manual_value())
if self.ymax_control.is_auto():
maxs = max(self.data[xmin:xmax])
ymax = float(maxs+(maxs*.05))
if xmax == self.dataval.getlen() and xmin == 0:
maxs = self.dataval.getmax()
else:
maxs = max(self.data[xmin:xmax])
ymax = float(maxs+((maxs-mins)*.05))
else:
ymax = float(self.ymax_control.manual_value())

if self.ymin_control.is_auto():
if maxs == mins:
ymin = float(mins-(mins*.05))
else:
ymin = float(mins-((maxs-mins)*.05))

self.axes.set_xbound(lower=xmin, upper=xmax)
self.axes.set_ybound(lower=ymin, upper=ymax)


if self.cb_grid.IsChecked():
self.axes.grid(True, color='gray')
self.histo.grid(True, color='gray')
Expand Down Expand Up @@ -492,9 +505,12 @@ def OnResult(self, event):
if event.datas is None:
print "killing"
else:
self.dataval.add(event.datas)
self.data.append(event.datas)
self.draw_plot()
if event.datas != 1.0000000E+38:
self.dataval.add(event.datas)
self.data.append(event.datas)
self.draw_plot()
else:
self.mainNum.SetValue("OVLD")
self.worker = None
if not self.paused and event.ids == self.id:
self.id = self.id + 1
Expand Down Expand Up @@ -552,7 +568,7 @@ def on_save_plot(self, event):
style=wx.SAVE)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
self.canvas.print_figure(path, dpi=self.dpi)
self.canvas.print_figure(path, dpi=100)
with open("output.csv", "wb") as f:
writer = csv.writer(f)
for row in self.data:
Expand Down
Binary file modified dmm_control.zip
Binary file not shown.

0 comments on commit 21c3ccf

Please sign in to comment.