function SetBlackSunProtection($option)
{
    if ($option < 0) {
        $option = 0;
    }
    if ($option > 127) {
        $option = 127;
    }
    SetRegisterValue(102, $option + 8192);
    return $option;
}
            SetRegisterValue(77, $regs[0]);
            $registers[77] = strtoupper(dechex($regs[0]));
            SetRegisterValue(78, $regs[1]);
            $registers[78] = strtoupper(dechex($regs[1]));
        }
        if (isset($_POST["blacksunapply"]) && $_POST["blacksunapply"] == "on") {
            $alert .= "Register 102 set to: " . $_POST["blacksun"] + 8192 . "<br>\n";
            $registers[102] = dechex(SetBlackSunProtection($_POST["blacksun"]) + 8192);
        }
        if (isset($_POST["Vtfl3enapply"]) && $_POST["Vtfl3enapply"] == "on" || isset($_POST["Vtfl2enapply"]) && $_POST["Vtfl2enapply"] == "on" || isset($_POST["Vtfl3apply"]) && $_POST["Vtfl3apply"] == "on" || isset($_POST["Vtfl2apply"]) && $_POST["Vtfl2apply"] == "on") {
            $Vtfl3en = $_POST["Vtfl3en"];
            $Vtfl2en = $_POST["Vtfl2en"];
            $Vtfl3 = $_POST["Vtfl3"];
            $Vtfl2 = $_POST["Vtfl2"];
            $tmpreg = $Vtfl3en * pow(2, 13) + $Vtfl3 * pow(2, 7) + $Vtfl2en * pow(2, 6) + $Vtfl2;
            SetRegisterValue(106, $tmpreg);
            $registers[106] = strtoupper(dechex($tmpreg));
        }
        if (isset($_POST["gainapply"]) && $_POST["gainapply"] == "on") {
            $temp = SetGain($_POST["gain"]);
            if ($temp >= 0) {
                $registers[115] = $temp;
                $alert .= "Register 115 set to: " . $temp . "<br>\n";
            }
        }
        // Print Notice Alert
        echo "<div class=\"alert alert-success\">";
        echo $alert;
        echo "</div>";
    }
}