Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorry, i wanted make a merge for the actual firmware (working with Chameleon Tiny) with your patch, done it in the wrong direction #2

Closed
wants to merge 12 commits into from
Closed
Next Next commit
Add Autocalibrate command to chamtool
Signed-off-by: cacke-r <cresch@gmx.de>
  • Loading branch information
cacke-r committed Feb 23, 2022
commit 5f8d0ec71c046a39f53e2245e21f98c9f4de94bc
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