Skip to content

Commit

Permalink
Add Autocalibrate command to chamtool
Browse files Browse the repository at this point in the history
Signed-off-by: cacke-r <cresch@gmx.de>
  • Loading branch information
cacke-r committed Feb 23, 2022
1 parent 94aeb3c commit 5f8d0ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Software/ChamTool/Chameleon/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Device:
COMMAND_GREEN_LED = "LEDGREEN"
COMMAND_RED_LED = "LEDRED"
COMMAND_THRESHOLD = "THRESHOLD"
COMMAND_AUTOCALIBRATE = "AUTOCALIBRATE"
COMMAND_UPGRADE = "upgrade"

STATUS_CODE_OK = 100
Expand Down Expand Up @@ -277,6 +278,9 @@ def cmdThreshold(self, value):
else:
return self.getSetCmd(self.COMMAND_THRESHOLD, value)

def cmdAutoCalibrate(self):
return self.returnCmd(self.COMMAND_AUTOCALIBRATE)

def cmdUpgrade(self):
# Execute command
cmdLine = self.COMMAND_UPGRADE + self.LINE_ENDING
Expand Down
14 changes: 14 additions & 0 deletions Software/ChamTool/chamtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ def cmdThreshold(chameleon, arg):
else:
return "Setting threshold failed: {}".format(arg, result['statusText'])

def cmdAutoCalibrate(chameleon, arg):

if (len(arg) == 0):
result = chameleon.cmdAutoCalibrate()
if (result['statusCode'] in chameleon.STATUS_CODES_SUCCESS):
return "Autocalibration successfully executed {}".format(result['statusText'])
else:
return "Error during autocalibration: {}".format(result['statusText'])

else:
return "Command failed - No Parameter expected ! {}".format(arg)

def cmdUpgrade(chameleon, arg):
if(chameleon.cmdUpgrade() == 0):
print ("Device changed into Upgrade Mode")
Expand Down Expand Up @@ -223,6 +235,7 @@ def main():
cmdArgGroup.add_argument("-gl", "--gled", dest="gled", action=CmdListAction, metavar="FUNCTION", nargs='?', help="retrieve or set the current green led function")
cmdArgGroup.add_argument("-rl", "--rled", dest="rled", action=CmdListAction, metavar="FUNCTION", nargs='?', help="retrieve or set the current red led function")
cmdArgGroup.add_argument("-th", "--threshold", dest="threshold", action=CmdListAction, nargs='?', help="retrieve or set the threshold")
cmdArgGroup.add_argument("-ac", "--autocalibrate", dest="auto_calib", action=CmdListAction, nargs=0, help="Send AutoCalibration command")
cmdArgGroup.add_argument("-ug", "--upgrade", dest="upgrade", action=CmdListAction, nargs=0, help="set the micro Controller to upgrade mode")

args = argParser.parse_args()
Expand Down Expand Up @@ -257,6 +270,7 @@ def main():
"gled" : cmdGreenLED,
"rled" : cmdRedLED,
"threshold" : cmdThreshold,
"auto_calib": cmdAutoCalibrate,
"upgrade" : cmdUpgrade,
}

Expand Down

0 comments on commit 5f8d0ec

Please sign in to comment.