add white balance switch
This commit is contained in:
parent
ebdf7876ce
commit
594eeb5690
194
flows/main.json
194
flows/main.json
|
@ -1788,7 +1788,7 @@
|
|||
"payloadType": "str",
|
||||
"topic": "actuator/focus",
|
||||
"x": 190,
|
||||
"y": 640,
|
||||
"y": 740,
|
||||
"wires": [
|
||||
[
|
||||
"65ad39d.b6d4d48"
|
||||
|
@ -1814,7 +1814,7 @@
|
|||
"payloadType": "str",
|
||||
"topic": "actuator/focus",
|
||||
"x": 190,
|
||||
"y": 600,
|
||||
"y": 700,
|
||||
"wires": [
|
||||
[
|
||||
"65ad39d.b6d4d48"
|
||||
|
@ -3213,7 +3213,7 @@
|
|||
"repair": false,
|
||||
"outputs": 2,
|
||||
"x": 470,
|
||||
"y": 620,
|
||||
"y": 720,
|
||||
"wires": [
|
||||
[
|
||||
"62030521.88317c"
|
||||
|
@ -3237,8 +3237,8 @@
|
|||
"raw": false,
|
||||
"topic": "",
|
||||
"name": "",
|
||||
"x": 650,
|
||||
"y": 640,
|
||||
"x": 670,
|
||||
"y": 740,
|
||||
"wires": [
|
||||
[]
|
||||
]
|
||||
|
@ -3254,7 +3254,7 @@
|
|||
"initialize": "",
|
||||
"finalize": "",
|
||||
"x": 320,
|
||||
"y": 620,
|
||||
"y": 720,
|
||||
"wires": [
|
||||
[
|
||||
"1f7cea1d.fbe61e"
|
||||
|
@ -3279,11 +3279,11 @@
|
|||
"payload": "{\"action\":\"stop\"}",
|
||||
"payloadType": "json",
|
||||
"topic": "actuator/focus",
|
||||
"x": 180,
|
||||
"y": 680,
|
||||
"x": 170,
|
||||
"y": 580,
|
||||
"wires": [
|
||||
[
|
||||
"fd05f252.5a90c"
|
||||
"62030521.88317c"
|
||||
]
|
||||
]
|
||||
},
|
||||
|
@ -3296,21 +3296,8 @@
|
|||
"qos": "",
|
||||
"retain": "",
|
||||
"broker": "8dc3722c.06efa8",
|
||||
"x": 630,
|
||||
"y": 560,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "fd05f252.5a90c",
|
||||
"type": "mqtt out",
|
||||
"z": "bccd1f23.87219",
|
||||
"name": "",
|
||||
"topic": "",
|
||||
"qos": "",
|
||||
"retain": "",
|
||||
"broker": "8dc3722c.06efa8",
|
||||
"x": 630,
|
||||
"y": 680,
|
||||
"x": 650,
|
||||
"y": 620,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
|
@ -3352,7 +3339,7 @@
|
|||
"payloadType": "json",
|
||||
"topic": "actuator/focus",
|
||||
"x": 180,
|
||||
"y": 520,
|
||||
"y": 620,
|
||||
"wires": [
|
||||
[
|
||||
"62030521.88317c"
|
||||
|
@ -3378,7 +3365,7 @@
|
|||
"payloadType": "json",
|
||||
"topic": "actuator/focus",
|
||||
"x": 170,
|
||||
"y": 560,
|
||||
"y": 660,
|
||||
"wires": [
|
||||
[
|
||||
"62030521.88317c"
|
||||
|
@ -3575,8 +3562,8 @@
|
|||
"qos": "",
|
||||
"retain": "",
|
||||
"broker": "8dc3722c.06efa8",
|
||||
"x": 930,
|
||||
"y": 840,
|
||||
"x": 1010,
|
||||
"y": 940,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
|
@ -5133,23 +5120,10 @@
|
|||
"y": 180,
|
||||
"wires": [
|
||||
[
|
||||
"e2af9066.9c0178"
|
||||
"bdc8ce57.de1f08"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "e2af9066.9c0178",
|
||||
"type": "mqtt out",
|
||||
"z": "bccd1f23.87219",
|
||||
"name": "",
|
||||
"topic": "",
|
||||
"qos": "",
|
||||
"retain": "",
|
||||
"broker": "8dc3722c.06efa8",
|
||||
"x": 310,
|
||||
"y": 180,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "b402f719.55bc98",
|
||||
"type": "inject",
|
||||
|
@ -6135,11 +6109,12 @@
|
|||
"links": [
|
||||
"52af9ac0.60eb24"
|
||||
],
|
||||
"x": 875,
|
||||
"y": 420,
|
||||
"x": 835,
|
||||
"y": 460,
|
||||
"wires": [
|
||||
[
|
||||
"cc205a38.f86ea"
|
||||
"cc205a38.f86ea",
|
||||
"93478941.a80e18"
|
||||
]
|
||||
]
|
||||
},
|
||||
|
@ -6292,7 +6267,7 @@
|
|||
"y": 940,
|
||||
"wires": [
|
||||
[
|
||||
"45c83cd2.15aee4"
|
||||
"845e06e1.0d812"
|
||||
]
|
||||
]
|
||||
},
|
||||
|
@ -6310,23 +6285,10 @@
|
|||
"y": 1000,
|
||||
"wires": [
|
||||
[
|
||||
"45c83cd2.15aee4"
|
||||
"845e06e1.0d812"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "45c83cd2.15aee4",
|
||||
"type": "mqtt out",
|
||||
"z": "bccd1f23.87219",
|
||||
"name": "",
|
||||
"topic": "",
|
||||
"qos": "",
|
||||
"retain": "",
|
||||
"broker": "8dc3722c.06efa8",
|
||||
"x": 930,
|
||||
"y": 960,
|
||||
"wires": []
|
||||
},
|
||||
{
|
||||
"id": "5ca6cdb6.3a6684",
|
||||
"type": "inject",
|
||||
|
@ -6401,5 +6363,117 @@
|
|||
"7b699798.3d568"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "227b4b67.5a0f2c",
|
||||
"type": "exec",
|
||||
"z": "1371dec5.76e671",
|
||||
"command": "",
|
||||
"addpay": true,
|
||||
"append": "",
|
||||
"useSpawn": "false",
|
||||
"timer": "1",
|
||||
"oldrc": false,
|
||||
"name": "git user.email",
|
||||
"x": 1150,
|
||||
"y": 500,
|
||||
"wires": [
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "93478941.a80e18",
|
||||
"type": "template",
|
||||
"z": "1371dec5.76e671",
|
||||
"name": "git config",
|
||||
"field": "payload",
|
||||
"fieldType": "msg",
|
||||
"format": "handlebars",
|
||||
"syntax": "mustache",
|
||||
"template": "git config --global --replace-all user.email \"{{payload}}\"",
|
||||
"output": "str",
|
||||
"x": 980,
|
||||
"y": 500,
|
||||
"wires": [
|
||||
[
|
||||
"227b4b67.5a0f2c"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "daedda1b.9805b8",
|
||||
"type": "function",
|
||||
"z": "bccd1f23.87219",
|
||||
"name": "Encapsulate settings",
|
||||
"func": "msg.payload = {\n \"action\":\"settings\", \n \"settings\":{\"white_balance\":msg.payload}\n}\nmsg.topic = \"imager/image\"\nreturn msg;",
|
||||
"outputs": 1,
|
||||
"noerr": 0,
|
||||
"initialize": "",
|
||||
"finalize": "",
|
||||
"x": 720,
|
||||
"y": 1060,
|
||||
"wires": [
|
||||
[
|
||||
"845e06e1.0d812"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "82722a3c.846b3",
|
||||
"type": "inject",
|
||||
"z": "bccd1f23.87219",
|
||||
"name": "Default: OFF",
|
||||
"props": [
|
||||
{
|
||||
"p": "payload"
|
||||
}
|
||||
],
|
||||
"repeat": "",
|
||||
"crontab": "",
|
||||
"once": true,
|
||||
"onceDelay": "1",
|
||||
"topic": "",
|
||||
"payload": "false",
|
||||
"payloadType": "bool",
|
||||
"x": 110,
|
||||
"y": 1060,
|
||||
"wires": [
|
||||
[
|
||||
"60e44330.50bdec"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "60e44330.50bdec",
|
||||
"type": "ui_switch",
|
||||
"z": "bccd1f23.87219",
|
||||
"name": "AWB",
|
||||
"label": "Auto White Balance",
|
||||
"tooltip": "",
|
||||
"group": "8c38a81e.9897a8",
|
||||
"order": 5,
|
||||
"width": 0,
|
||||
"height": 0,
|
||||
"passthru": true,
|
||||
"decouple": "false",
|
||||
"topic": "imager/image",
|
||||
"style": "",
|
||||
"onvalue": "auto",
|
||||
"onvalueType": "str",
|
||||
"onicon": "",
|
||||
"oncolor": "",
|
||||
"offvalue": "off",
|
||||
"offvalueType": "str",
|
||||
"officon": "",
|
||||
"offcolor": "",
|
||||
"x": 410,
|
||||
"y": 1060,
|
||||
"wires": [
|
||||
[
|
||||
"daedda1b.9805b8"
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
|
@ -440,7 +440,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
if "white_balance_gain" in settings:
|
||||
if "red" in settings["white_balance_gain"]:
|
||||
logger.debug(
|
||||
f"Updating the camera white balance red gain to to {settings['white_balance_gain']}"
|
||||
f"Updating the camera white balance red gain to {settings['white_balance_gain']}"
|
||||
)
|
||||
self.__white_balance_gain = (
|
||||
settings["white_balance_gain"].get(
|
||||
|
@ -450,7 +450,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
)
|
||||
if "blue" in settings["white_balance_gain"]:
|
||||
logger.debug(
|
||||
f"Updating the camera white balance blue gain to to {settings['white_balance_gain']}"
|
||||
f"Updating the camera white balance blue gain to {settings['white_balance_gain']}"
|
||||
)
|
||||
self.__white_balance_gain = (
|
||||
self.__white_balance_gain[0],
|
||||
|
@ -459,7 +459,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
),
|
||||
)
|
||||
logger.debug(
|
||||
f"Updating the camera white balance gain to to {self.__white_balance_gain}"
|
||||
f"Updating the camera white balance gain to {self.__white_balance_gain}"
|
||||
)
|
||||
try:
|
||||
self.__camera.white_balance_gain = self.__white_balance_gain
|
||||
|
@ -475,6 +475,31 @@ class ImagerProcess(multiprocessing.Process):
|
|||
'{"status":"Error: White balance gain not valid"}',
|
||||
)
|
||||
return
|
||||
|
||||
if "white_balance" in settings:
|
||||
logger.debug(
|
||||
f"Updating the camera white balance mode to {settings['white_balance']}"
|
||||
)
|
||||
self.__white_balance = settings.get(
|
||||
"white_balance", self.__white_balance
|
||||
)
|
||||
logger.debug(
|
||||
f"Updating the camera white balance mode to {self.__white_balance}"
|
||||
)
|
||||
try:
|
||||
self.__camera.white_balance = self.__white_balance
|
||||
except TimeoutError as e:
|
||||
logger.error(
|
||||
"A timeout has occured when setting the white balance, trying again"
|
||||
)
|
||||
self.__camera.white_balance = self.__white_balance
|
||||
except ValueError as e:
|
||||
logger.error("The requested white balance is not valid!")
|
||||
self.imager_client.client.publish(
|
||||
"status/imager",
|
||||
f'{"status":"Error: White balance mode {self.__white_balance} is not valid"}',
|
||||
)
|
||||
return
|
||||
# Publish the status "Config updated" to via MQTT to Node-RED
|
||||
self.imager_client.client.publish(
|
||||
"status/imager", '{"status":"Camera settings updated"}'
|
||||
|
|
Loading…
Reference in a new issue