########################################
# Camera Settings Control
########################################

[gcode_shell_command v4l2-ctl]
command: v4l2-ctl
timeout: 5.0
verbose: True

[gcode_macro CAM_SETTINGS]
description: Show current camera settings
gcode:
    RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 -l"

[gcode_macro CAM_BRIGHTNESS]
description: min=50 / max=160
gcode:
    {% set brightness = params.BRIGHTNESS|default(100) %}
    RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl brightness="{brightness}

[gcode_macro CAM_CONTRAST]
description: min=50 / max=160
gcode:
    {% set contrast = params.CONTRAST|default(50) %}
    RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl contrast="{contrast}

[gcode_macro CAM_SATURATION]
description: min=50 / max=160
gcode:
    {% set saturation = params.SATURATION|default(56) %}
    RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl saturation="{saturation}

[gcode_macro CAM_HUE]
description: min=50 / max=160
gcode:
    {% set hue = params.HUE|default(50) %}
    RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl hue="{hue}

[gcode_macro CAM_WHITE_BALANCE_TEMPERATURE_AUTO]
description: disable=0 / enable=1
gcode:
    {% set white_balance_temperature_auto = params.WHITE_BALANCE_TEMPERATURE_AUTO|default(1) %}
    RUN_SHELL_COMMAND CMD=v4l2-ctl PARAMS="-d /dev/video4 --set-ctrl white_balance_temperature_auto="{white_balance_temperature_auto}
