diff options
author | Andreas Auras <yak54@inkennet.de> | 2012-11-27 17:30:27 +0100 |
---|---|---|
committer | Andreas Auras <yak54@inkennet.de> | 2012-11-27 17:30:27 +0100 |
commit | 71b8d43543bd0a273707531a72dcb02809f58e3a (patch) | |
tree | c0b7aba1e8ce5ca8ed5fa62fdb7761fed73bc73d | |
parent | cb3e9afd627cdef3a92bace991b779deb342a976 (diff) | |
download | df10ch-atmolight-controller-71b8d43543bd0a273707531a72dcb02809f58e3a.tar.gz df10ch-atmolight-controller-71b8d43543bd0a273707531a72dcb02809f58e3a.tar.bz2 |
Added handling of weight limit.
-rw-r--r-- | df10ch_setup.py | 2 | ||||
-rw-r--r-- | df10ch_setup_pkg/areas_dlg.py | 12 | ||||
-rw-r--r-- | df10ch_setup_pkg/device_drv.py | 12 | ||||
-rw-r--r-- | df10ch_setup_pkg/layout_dlg.py | 13 |
4 files changed, 31 insertions, 8 deletions
diff --git a/df10ch_setup.py b/df10ch_setup.py index 34aba7a..5a5694d 100644 --- a/df10ch_setup.py +++ b/df10ch_setup.py @@ -35,7 +35,7 @@ from df10ch_setup_pkg.white_cal_dlg import WhiteCalDialog from df10ch_setup_pkg.bright_dlg import BrightDialog import df10ch_setup_pkg.device_drv -TITLE = "DF10CH Setup V4" +TITLE = "DF10CH Setup V5" print parser = OptionParser(version=TITLE) parser.add_option("-s", "--simulate", action="store", type="int", dest="simulate", default=0, help="Set simulated number of DF10CH controller's") diff --git a/df10ch_setup_pkg/areas_dlg.py b/df10ch_setup_pkg/areas_dlg.py index 11d59f0..890fd05 100644 --- a/df10ch_setup_pkg/areas_dlg.py +++ b/df10ch_setup_pkg/areas_dlg.py @@ -35,6 +35,7 @@ class AreasDialog: self.selectedArea = None self.selectCallbacks = list() self.edgeWeighting = -1 + self.weightLimit = 0 def cvX(self, x): return int((self.cvWidth * x) / self.aWidth) @@ -281,7 +282,7 @@ class AreasDialog: cv.itemconfigure(id, fill="", outline="#808080", width=3) cv.tag_bind(id, "<Button-1>", self.cbSelectArea) - def calcEdgeWeighting(self, edgeWeighting): + def calcEdgeWeighting(self, edgeWeighting, weightLimit): w = float(edgeWeighting) / 10.0 fHeight = float(self.aHeight - 1) fWidth = float(self.aWidth - 1) @@ -305,6 +306,8 @@ class AreasDialog: if self.sBottom and y >= centerY: weight = max(weight, wBottom) bright = int(255.0 * weight) + if bright < weightLimit: + bright = 0 px = self.cvX(x) px2 = self.cvX(x + 1) py = self.cvY(y) @@ -316,13 +319,14 @@ class AreasDialog: self.weightDraw.polygon([(px, py), (px2, py), (px2, py2), (px, py2)], fill=bright, outline=bBright) self.root.weightImg.paste(self.weightImg) self.edgeWeighting = edgeWeighting + self.weightLimit = weightLimit - def showEdgeWeighting(self, edgeWeighting, topWin): - if self.edgeWeighting != edgeWeighting: + def showEdgeWeighting(self, edgeWeighting, weightLimit, topWin): + if self.edgeWeighting != edgeWeighting or self.weightLimit != weightLimit: cursor = topWin["cursor"] topWin["cursor"] = "watch" self.root.update_idletasks() - self.calcEdgeWeighting(edgeWeighting) + self.calcEdgeWeighting(edgeWeighting, weightLimit) topWin["cursor"] = cursor if self.edgeWeighting == edgeWeighting: self.root.itemconfigure(self.weightImgId, state=NORMAL) diff --git a/df10ch_setup_pkg/device_drv.py b/df10ch_setup_pkg/device_drv.py index ddb22d0..c2f9dc4 100644 --- a/df10ch_setup_pkg/device_drv.py +++ b/df10ch_setup_pkg/device_drv.py @@ -233,7 +233,7 @@ def GetCommErrMsg(stat): CONFIG_VALID_ID = 0xA0A1 -CONFIG_VERSION = 0x0002 +CONFIG_VERSION = 0x0003 CONFIG_CLASS_VERSION = 0x0002 DEFAULT_GAMMA_VAL = 22 @@ -248,6 +248,10 @@ DEFAULT_EDGE_WEIGHTING = 60 MIN_EDGE_WEIGHTING = 10 MAX_EDGE_WEIGHTING = 200 +DEFAULT_WEIGHT_LIMIT = 12 +MIN_WEIGHT_LIMIT = 0 +MAX_WEIGHT_LIMIT = 255 + DEFAULT_ANALYZE_SIZE = 1 MIN_ANALYZE_SIZE = 0 MAX_ANALYZE_SIZE = 5 @@ -734,9 +738,10 @@ class ControllerConfig: self.numReqChannels = 0 self.analyzeSize = DEFAULT_ANALYZE_SIZE self.edgeWeighting = DEFAULT_EDGE_WEIGHTING + self.weightLimit = DEFAULT_WEIGHT_LIMIT self.overscan = DEFAULT_OVERSCAN - eedata = self.ctrl.read_ee_data(1, 8 + len(self.numAreas) + NCHANNELS * 6) + eedata = self.ctrl.read_ee_data(1, 9 + len(self.numAreas) + NCHANNELS * 6) #print "read eedata:", eedata configValidId = eedata[0] + eedata[1] * 256 if configValidId == CONFIG_VALID_ID: @@ -753,6 +758,8 @@ class ControllerConfig: self.overscan = max(min(eedata[p], MAX_OVERSCAN), MIN_OVERSCAN) self.analyzeSize = max(min(eedata[p + 1], MAX_ANALYZE_SIZE), MIN_ANALYZE_SIZE) self.edgeWeighting = max(min(eedata[p + 2], MAX_EDGE_WEIGHTING), MIN_EDGE_WEIGHTING) + if self.configVersion > 2: + self.weightLimit = max(min(eedata[p + 3], MAX_WEIGHT_LIMIT), MIN_WEIGHT_LIMIT) else: configVersionStr = "" self.version = "USB:{0:04X} PWM:{1:04X} CONFIG:{2}".format(self.ctrl.version, self.ctrl.get_pwm_version(), configVersionStr) @@ -828,6 +835,7 @@ class ControllerConfig: eedata.append(self.overscan) eedata.append(self.analyzeSize) eedata.append(self.edgeWeighting) + eedata.append(self.weightLimit) self.numReqChannels = 0 while len(pwmChannelMap) < NCHANNELS: diff --git a/df10ch_setup_pkg/layout_dlg.py b/df10ch_setup_pkg/layout_dlg.py index 7fc9ed7..94c530e 100644 --- a/df10ch_setup_pkg/layout_dlg.py +++ b/df10ch_setup_pkg/layout_dlg.py @@ -30,6 +30,7 @@ class LayoutDialog: def __init__(self, areasDlg, master=None, **args): self.areasDlg = areasDlg self.edgeWeighting = 0 + self.weightLimit = 0 self.analyzeSize = 0 self.overscan = 0 self.numAreas = [ 0 ] * device_drv.NumBaseAreas() @@ -103,6 +104,11 @@ class LayoutDialog: self.sbWeight = Spinbox(root, textvariable=self.varWeight, from_=device_drv.MIN_EDGE_WEIGHTING, to=device_drv.MAX_EDGE_WEIGHTING, increment=1, width=4) self.sbWeight.grid(row=4, column=7, padx=5, pady=5, sticky=W) + Label(root, text="Weight limit:").grid(row=5, column=6, sticky=E) + self.varWeightLimit = StringVar() + self.sbWeightLimit = Spinbox(root, textvariable=self.varWeightLimit, from_=device_drv.MIN_WEIGHT_LIMIT, to=device_drv.MAX_WEIGHT_LIMIT, increment=1, width=4) + self.sbWeightLimit.grid(row=5, column=7, padx=5, pady=5, sticky=W) + self.btShowEdgeWeighting = Button(root, text="Show edge weighting", command=self.cbShowEdgeWeighting) self.btShowEdgeWeighting.grid(row=6, column=0, columnspan=7, padx=20, pady=20, ipadx=5, sticky=E) @@ -114,7 +120,7 @@ class LayoutDialog: def cbShowEdgeWeighting(self): self.applyValues() - self.areasDlg.showEdgeWeighting(self.edgeWeighting, self.root.winfo_toplevel()) + self.areasDlg.showEdgeWeighting(self.edgeWeighting, self.weightLimit, self.root.winfo_toplevel()) def cbApply(self): self.applyValues() @@ -125,11 +131,13 @@ class LayoutDialog: self.overscan = int(self.varOverscan.get()) self.analyzeSize = int(self.varAnalyzeSize.get()) self.edgeWeighting = int(self.varWeight.get()) + self.weightLimit = int(self.varWeightLimit.get()) self.areasDlg.configAreas(self.numAreas, self.overscan, self.analyzeSize) def setLayoutFromConfig(self): self.analyzeSize = 0 self.edgeWeighting = 0 + self.weightLimit = 0 self.overscan = 0 self.numAreas = [ 0 ] * device_drv.NumBaseAreas() for ctrlId in device_drv.ConfigMap.keys(): @@ -137,6 +145,7 @@ class LayoutDialog: self.overscan = config.overscan self.analyzeSize = config.analyzeSize self.edgeWeighting = config.edgeWeighting + self.weightLimit = config.weightLimit for i in range(device_drv.NumBaseAreas()): if config.numAreas[i] > self.numAreas[i]: self.numAreas[i] = config.numAreas[i] @@ -145,6 +154,7 @@ class LayoutDialog: self.varOverscan.set(self.overscan) self.varAnalyzeSize.set(self.analyzeSize) self.varWeight.set(self.edgeWeighting) + self.varWeightLimit.set(self.weightLimit) self.areasDlg.configAreas(self.numAreas, self.overscan, self.analyzeSize) def setConfigFromLayout(self): @@ -153,6 +163,7 @@ class LayoutDialog: config.overscan = self.overscan config.analyzeSize = self.analyzeSize config.edgeWeighting = self.edgeWeighting + config.weightLimit = self.weightLimit for i in range(device_drv.NumBaseAreas()): config.numAreas[i] = self.numAreas[i] |