Enable fresh new inputs.

This commit is contained in:
Quentin Decaunes 2019-03-19 21:31:16 +01:00
parent 74e0429a49
commit 4f5839f98a
2 changed files with 42 additions and 10 deletions

View File

@ -48,6 +48,7 @@ function applyRyzenSettings() {
case "--tctl-temp=": case "--tctl-temp=":
case "--max-fclk-frequency=": case "--max-fclk-frequency=":
case "--min-fclk-frequency=": case "--min-fclk-frequency=":
case "--stapm-time=":
value = value; value = value;
break; break;

View File

@ -175,7 +175,7 @@ function appendLog(message) {
* Will save the latest used settings. * Will save the latest used settings.
*/ */
function saveLatestUsedSettings() { function saveLatestUsedSettings() {
var inputs = document.querySelectorAll('#controller-tab input'); var inputs = document.querySelectorAll('#controller-tab input, #experimental-tab input');
var latest_controller_tabs_settings = {}; var latest_controller_tabs_settings = {};
inputs.forEach(element => { inputs.forEach(element => {
let id = element.id; let id = element.id;
@ -217,6 +217,22 @@ function loadLatestUsedSettings() {
function registerEventListenerForSettingsInput() { function registerEventListenerForSettingsInput() {
const settings = require('electron-settings'); const settings = require('electron-settings');
var checkbox_toggle_options = document.querySelectorAll('#controller-tab input[id^=apply_]');
const hideOptionBasedOnInput = function (input) {
if (input.checked) {
input.parentElement.parentElement.nextElementSibling.removeAttribute('hidden');
} else {
input.parentElement.parentElement.nextElementSibling.setAttribute('hidden', '');
}
}
Array.from(checkbox_toggle_options).forEach(input => {
hideOptionBasedOnInput(input);
input.addEventListener('change', function(event) {
hideOptionBasedOnInput(input);
});
});
var apply_last_settings_on_launch = document.getElementById('apply_last_settings_on_launch'); var apply_last_settings_on_launch = document.getElementById('apply_last_settings_on_launch');
apply_last_settings_on_launch.addEventListener('change', function() { apply_last_settings_on_launch.addEventListener('change', function() {
settings.set('settings', { settings.set('settings', {
@ -326,17 +342,32 @@ function recreateShortcut() {
*/ */
function getCurrentSettings(keyType) { function getCurrentSettings(keyType) {
if (keyType === "ryzenadjArgs") { if (keyType === "ryzenadjArgs") {
return { const optionToId = {
"--stapm-limit=": document.getElementById('stapm_limit_w').value, "--stapm-time=": 'stapm_time_ms',
"--fast-limit=": document.getElementById('ppt_fast_limit_w').value, "--stapm-limit=": 'stapm_limit_w',
"--slow-limit=": document.getElementById('ppt_slow_limit_w').value, "--fast-limit=": 'ppt_fast_limit_w',
"--tctl-temp=": document.getElementById('temperature_limit_c').value, "--slow-limit=": 'ppt_slow_limit_w',
"--vrmmax-current=": document.getElementById('vrm_current_m_a').value, "--tctl-temp=": 'temperature_limit_c',
"--min-fclk-frequency=": document.getElementById('min_fclk_frequency').value, "--vrmmax-current=": 'vrm_current_m_a',
"--max-fclk-frequency=": document.getElementById('max_fclk_frequency').value, "--min-fclk-frequency=": 'min_fclk_frequency',
"--max-fclk-frequency=": 'max_fclk_frequency',
}; };
var settingsToBeUsed = {};
for (const option in optionToId) {
if (optionToId.hasOwnProperty(option)) {
const elementId = optionToId[option];
if (document.getElementById('apply_' + elementId).checked) {
settingsToBeUsed[option] = document.getElementById(elementId).value;
}
}
}
appendLog('getCurrentSettings(): ' + JSON.stringify(settingsToBeUsed));
return settingsToBeUsed;
} else { } else {
var inputs = document.querySelectorAll('#controller-tab input'); var inputs = document.querySelectorAll('#controller-tab input, #experimental-tab input');
var currentSettings = {}; var currentSettings = {};
inputs.forEach(element => { inputs.forEach(element => {
let id = element.id; let id = element.id;