add white balance switch

This commit is contained in:
Romain Bazile 2020-11-27 18:39:09 +01:00
parent ebdf7876ce
commit 594eeb5690
2 changed files with 162 additions and 63 deletions

View file

@ -1788,7 +1788,7 @@
"payloadType": "str", "payloadType": "str",
"topic": "actuator/focus", "topic": "actuator/focus",
"x": 190, "x": 190,
"y": 640, "y": 740,
"wires": [ "wires": [
[ [
"65ad39d.b6d4d48" "65ad39d.b6d4d48"
@ -1814,7 +1814,7 @@
"payloadType": "str", "payloadType": "str",
"topic": "actuator/focus", "topic": "actuator/focus",
"x": 190, "x": 190,
"y": 600, "y": 700,
"wires": [ "wires": [
[ [
"65ad39d.b6d4d48" "65ad39d.b6d4d48"
@ -3213,7 +3213,7 @@
"repair": false, "repair": false,
"outputs": 2, "outputs": 2,
"x": 470, "x": 470,
"y": 620, "y": 720,
"wires": [ "wires": [
[ [
"62030521.88317c" "62030521.88317c"
@ -3237,8 +3237,8 @@
"raw": false, "raw": false,
"topic": "", "topic": "",
"name": "", "name": "",
"x": 650, "x": 670,
"y": 640, "y": 740,
"wires": [ "wires": [
[] []
] ]
@ -3254,7 +3254,7 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"x": 320, "x": 320,
"y": 620, "y": 720,
"wires": [ "wires": [
[ [
"1f7cea1d.fbe61e" "1f7cea1d.fbe61e"
@ -3279,11 +3279,11 @@
"payload": "{\"action\":\"stop\"}", "payload": "{\"action\":\"stop\"}",
"payloadType": "json", "payloadType": "json",
"topic": "actuator/focus", "topic": "actuator/focus",
"x": 180, "x": 170,
"y": 680, "y": 580,
"wires": [ "wires": [
[ [
"fd05f252.5a90c" "62030521.88317c"
] ]
] ]
}, },
@ -3296,21 +3296,8 @@
"qos": "", "qos": "",
"retain": "", "retain": "",
"broker": "8dc3722c.06efa8", "broker": "8dc3722c.06efa8",
"x": 630, "x": 650,
"y": 560, "y": 620,
"wires": []
},
{
"id": "fd05f252.5a90c",
"type": "mqtt out",
"z": "bccd1f23.87219",
"name": "",
"topic": "",
"qos": "",
"retain": "",
"broker": "8dc3722c.06efa8",
"x": 630,
"y": 680,
"wires": [] "wires": []
}, },
{ {
@ -3352,7 +3339,7 @@
"payloadType": "json", "payloadType": "json",
"topic": "actuator/focus", "topic": "actuator/focus",
"x": 180, "x": 180,
"y": 520, "y": 620,
"wires": [ "wires": [
[ [
"62030521.88317c" "62030521.88317c"
@ -3378,7 +3365,7 @@
"payloadType": "json", "payloadType": "json",
"topic": "actuator/focus", "topic": "actuator/focus",
"x": 170, "x": 170,
"y": 560, "y": 660,
"wires": [ "wires": [
[ [
"62030521.88317c" "62030521.88317c"
@ -3575,8 +3562,8 @@
"qos": "", "qos": "",
"retain": "", "retain": "",
"broker": "8dc3722c.06efa8", "broker": "8dc3722c.06efa8",
"x": 930, "x": 1010,
"y": 840, "y": 940,
"wires": [] "wires": []
}, },
{ {
@ -5133,23 +5120,10 @@
"y": 180, "y": 180,
"wires": [ "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", "id": "b402f719.55bc98",
"type": "inject", "type": "inject",
@ -6135,11 +6109,12 @@
"links": [ "links": [
"52af9ac0.60eb24" "52af9ac0.60eb24"
], ],
"x": 875, "x": 835,
"y": 420, "y": 460,
"wires": [ "wires": [
[ [
"cc205a38.f86ea" "cc205a38.f86ea",
"93478941.a80e18"
] ]
] ]
}, },
@ -6292,7 +6267,7 @@
"y": 940, "y": 940,
"wires": [ "wires": [
[ [
"45c83cd2.15aee4" "845e06e1.0d812"
] ]
] ]
}, },
@ -6310,23 +6285,10 @@
"y": 1000, "y": 1000,
"wires": [ "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", "id": "5ca6cdb6.3a6684",
"type": "inject", "type": "inject",
@ -6401,5 +6363,117 @@
"7b699798.3d568" "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"
]
]
} }
] ]

View file

@ -440,7 +440,7 @@ class ImagerProcess(multiprocessing.Process):
if "white_balance_gain" in settings: if "white_balance_gain" in settings:
if "red" in settings["white_balance_gain"]: if "red" in settings["white_balance_gain"]:
logger.debug( 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 = ( self.__white_balance_gain = (
settings["white_balance_gain"].get( settings["white_balance_gain"].get(
@ -450,7 +450,7 @@ class ImagerProcess(multiprocessing.Process):
) )
if "blue" in settings["white_balance_gain"]: if "blue" in settings["white_balance_gain"]:
logger.debug( 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 = (
self.__white_balance_gain[0], self.__white_balance_gain[0],
@ -459,7 +459,7 @@ class ImagerProcess(multiprocessing.Process):
), ),
) )
logger.debug( 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: try:
self.__camera.white_balance_gain = self.__white_balance_gain self.__camera.white_balance_gain = self.__white_balance_gain
@ -475,6 +475,31 @@ class ImagerProcess(multiprocessing.Process):
'{"status":"Error: White balance gain not valid"}', '{"status":"Error: White balance gain not valid"}',
) )
return 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 # Publish the status "Config updated" to via MQTT to Node-RED
self.imager_client.client.publish( self.imager_client.client.publish(
"status/imager", '{"status":"Camera settings updated"}' "status/imager", '{"status":"Camera settings updated"}'