This commit is contained in:
Vitor de Miranda Henrique
2016-12-09 14:21:42 -08:00
parent 3acb80b074
commit ef7cf35c4b
2 changed files with 5 additions and 4 deletions

View File

@@ -96,10 +96,11 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
def getEnclosureTemperature(self):
return str(self.enclosureCurrentTemperature)
@octoprint.plugin.BlueprintPlugin.route("/handleIO", methods=["GET"])
def handleIO(self):
@octoprint.plugin.BlueprintPlugin.route("/setIO", methods=["GET"])
def setIO(self):
io = flask.request.values["pin"]
if flask.request.values["value"] == "on":
value = flask.request.values["status"]
if value == "on":
os.system("gpio -g write "+str(self._settings.get_int([io]))+" 0")
else:
os.system("gpio -g write "+str(self._settings.get_int([io]))+" 1")

View File

@@ -82,7 +82,7 @@ $(function() {
$.ajax({
type: "GET",
dataType: "json",
data: {"io": data[0], "status": data[1]},
data: {"pin": data[0], "status": data[1]},
url: "/plugin/enclosure/handleIO",
async: false
});