# MASTER18 output calibration patch

# CONTROLLER 1
# B1.1: [Cancel] Load saved calibration
# B1.2: [Defaults] Load default calibration
# B1.3: [Fast] Push too increase knob effectiveness
# B1.4: [Save] Save
# E1.1: [Output] Select output 1 ... 8
# E1.2: [Ref] Select 0V or 8V output reference
# E1.3: [+/-] Display current calibration
# E1.4: [State] Show current status

[e4]

# ---------------------------------------------------------
# LEDs
# Let the four diagnostic LEDs do some animation
# ---------------------------------------------------------

[lfo]
    square = R1
    pulsewidth = 0.3
    level = 0.8

[lfo]
    phase = 0.25
    square = R2
    pulsewidth = 0.3
    level = 0.6

[lfo]
    phase = 0.5
    square = R3
    pulsewidth = 0.3
    level = 0.4

[lfo]
    phase = 0.75
    square = R4
    pulsewidth = 0.3
    level = 0.2


# ---------------------------------------------------------
# Calibration
# Handle the encoders and the buttons
# ---------------------------------------------------------

[encoder]
    encoder = 1
    discrete = 8
    color = _UNCAL_LED + 0.2
    output = _CHANNEL

[encoder]
    encoder = 2
    discrete = 2
    output = _REFPOINT

[encoder]
    encoder = 3
    override = _CAL
    rangemode = 1
    negativecolor = 0.8
    color = 1.3
    movementticks = B1.3 * -5 + 6
    movedup = _UP
    moveddown = _DOWN

[outputcalibrator]
    output = _CHANNEL + 1
    referencepoint = _REFPOINT
    save = B1.4
    cancel = B1.1
    loaddefaults = B1.2
    nudgeup = _UP
    nudgedown = _DOWN
    dirty = _DIRTY
    calibration = _CAL
    uncalibrated = _UNCAL

[compare]
    input = _UNCAL
    compare = 0
    precision = 0
    ifequal = 0.3
    else = 0
    output = _UNCAL_LED

[lfo]
    level = _DIRTY * 0.2 + _UNCAL_LED
    hz = -5 * _UNCAL_LED + 2.5
    square = _DIRTY_PULSE
    pulsewidth = 0.1

[burst]
    trigger = B1.4
    hz = 10
    count = 5
    output = G1

[copy]
    input = G1
    output = _SAVED_PULSE

[mixer]
    input1 = 0.2 * _DIRTY
    input2 = _DIRTY_PULSE
    input3 = _SAVED_PULSE
    output = L1.4

# ---------------------------------------------------------
# Voltage output
# Output either 0V or the high reference voltage all outputs
# ---------------------------------------------------------


[copy]
    input = 5V
    output = _UPPER_VOLTAGE

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O1

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O2

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O3

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O4

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O5

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O6

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O7

[copy]
    input = _REFPOINT * _UPPER_VOLTAGE
    output = O8
