From 8d4e32e841afe23e7e71423a12e0941a50c99a14 Mon Sep 17 00:00:00 2001 From: Quentin Decaunes Date: Wed, 27 Feb 2019 21:04:28 +0100 Subject: [PATCH] Added basical ryzenadj value management and execution. --- index.html | 3 ++- js/settings.js | 68 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 460aca3..77a01b3 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@
  • -
    + +
  • diff --git a/js/settings.js b/js/settings.js index 7453264..3f577fd 100644 --- a/js/settings.js +++ b/js/settings.js @@ -17,10 +17,64 @@ ready(function(){ } } }); -/* -stapm_limit_w_range -ppt_fast_limit_w_range -ppt_slow_limit_w_range -temperature_limit_c_range -vrm_current_m_a_range -*/ + +function getCurrentWorkingDirectory() { + return require('electron').remote.app.getAppPath(); +} + +function decimalToHexString(number) { + if (number < 0) + { + number = 0xFFFFFFFF + number + 1; + } + + return number.toString(16).toUpperCase(); +} + +function applyRyzenSettings(e) { + const settings = { + "--stapm-limit=": document.getElementById('stapm_limit_w').value, + "--fast-limit=": document.getElementById('ppt_fast_limit_w').value, + "--slow-limit=": document.getElementById('ppt_slow_limit_w').value, + "--tctl-temp=": document.getElementById('temperature_limit_c').value, + "--vrmmax-current=": document.getElementById('vrm_current_m_a').value, + }; + console.log(settings); + + const child = require('child_process').execFile; + const executablePath = getCurrentWorkingDirectory() + "\\bin\\ryzenadj.exe"; + + var parameters = []; + for (const option in settings) { + if (settings.hasOwnProperty(option)) { + let value = settings[option]; + + switch (option) { + case "--stapm-limit=": + case "--fast-limit=": + case "--slow-limit=": + value = value * 1000; + break; + + case "--tctl-temp=": + value = value; + break; + + case "--vrmmax-current=": + value = '0x' + decimalToHexString(value * 1000); + break; + + default: + break; + } + + parameters.push('' + option + value); + } + } + + child(executablePath, parameters, function(err, data) { + console.log(err) + console.log(data.toString()); + }); + +}