Save 5KiB heap space from pcv; Separate configurator entries with tabs
This commit is contained in:
@@ -4,12 +4,43 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Switch OC Suite > Project Homepage | Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. Licensed under GPL v2.
|
||||
<title>Switch OC Suite | Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. Licensed under GPL v2.
|
||||
</title>
|
||||
<meta name="description"
|
||||
content="Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. Licensed under GPL v2.">
|
||||
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
|
||||
<style>
|
||||
nav[role="tab-control"] > button {
|
||||
border-radius: 0;
|
||||
border-left-width: calc(var(--border-width) / 2);
|
||||
border-right-width: calc(var(--border-width) / 2);
|
||||
}
|
||||
|
||||
nav[role="tab-control"] > button:first-child {
|
||||
border-top-left-radius: var(--border-radius);
|
||||
border-bottom-left-radius: var(--border-radius);
|
||||
border-left-width: var(--border-width);
|
||||
}
|
||||
|
||||
nav[role="tab-control"] > button:last-child {
|
||||
border-top-right-radius: var(--border-radius);
|
||||
border-bottom-right-radius: var(--border-radius);
|
||||
border-right-width: var(--border-width);
|
||||
}
|
||||
|
||||
nav[role="tab-control"] > button:not(.secondary) {
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
div.cust-element {
|
||||
margin: 1.5rem 0 1.5rem 0;
|
||||
}
|
||||
|
||||
div.cust-element > blockquote {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div#download_btn_grid > a {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
@@ -50,7 +81,7 @@
|
||||
<header>
|
||||
<hgroup>
|
||||
<h2>Read Me</h2>
|
||||
<h3>DISCLAIMER: 🚨USE AT YOUR OWN RISK!🚨</h3>
|
||||
<h3>🚨DISCLAIMER: THIS IS PROVIDED AS IS. USE AT YOUR OWN RISK!🚨</h3>
|
||||
</hgroup>
|
||||
<li>
|
||||
Overclocking in general will shorten the lifespan of some
|
||||
@@ -337,15 +368,22 @@
|
||||
<header>
|
||||
<hgroup>
|
||||
<h2>Configurator</h2>
|
||||
<h3>Configure frequencies and voltages to suit your hardware and yourself.</h3>
|
||||
<h3>Configure frequencies and voltages to suit your hardware and preferences.</h3>
|
||||
</hgroup>
|
||||
</header>
|
||||
<form id="form">
|
||||
<label for="file">File loader.kip
|
||||
<input id="file" type="file">
|
||||
<small id="cust_rev"></small>
|
||||
</label>
|
||||
</form>
|
||||
<body>
|
||||
<nav role="tab-control">
|
||||
<button class="" id="tab_all" data-filter="0" disabled>Show All</button>
|
||||
<button class="outline secondary" id="tab_erista" data-filter="1" disabled>For Erista</button>
|
||||
<button class="outline secondary" id="tab_mariko" data-filter="2" disabled>For Mariko</button>
|
||||
</nav>
|
||||
<form id="form">
|
||||
<label for="file">
|
||||
<input id="file" type="file">
|
||||
<p id="cust_rev">Upload loader.kip here</p>
|
||||
</label>
|
||||
</form>
|
||||
</body>
|
||||
<footer>
|
||||
<div class="grid">
|
||||
<button id="load_default" role="button" disabled>Load Default</button>
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
/* Config: Cust */
|
||||
const CUST_REV = 3;
|
||||
var buffer: string | ArrayBuffer;
|
||||
var buffer: ArrayBuffer;
|
||||
|
||||
enum CustPlatform {
|
||||
Undefined = 0,
|
||||
Erista = 1,
|
||||
Mariko = 2,
|
||||
All = 3,
|
||||
};
|
||||
|
||||
class CustEntry {
|
||||
id: string;
|
||||
name: string;
|
||||
platform: CustPlatform;
|
||||
size: number;
|
||||
desc: string;
|
||||
defval: number;
|
||||
@@ -12,12 +20,13 @@ class CustEntry {
|
||||
max: number;
|
||||
step: number; // also as quotient
|
||||
zeroable: boolean;
|
||||
value: number | null;
|
||||
offset: number | null;
|
||||
value?: number;
|
||||
offset?: number;
|
||||
|
||||
constructor(id: string, name: string, size: number, desc: string, defval: number, minmax: [number, number] = [0, 1_000_000], step: number = 1, zeroable: boolean = true) {
|
||||
constructor(id: string, name: string, platform: CustPlatform, size: number, desc: string, defval: number, minmax: [number, number] = [0, 1_000_000], step: number = 1, zeroable: boolean = true) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.platform = platform;
|
||||
this.size = size;
|
||||
this.desc = desc;
|
||||
this.defval = defval;
|
||||
@@ -25,14 +34,12 @@ class CustEntry {
|
||||
this.max = minmax[1];
|
||||
this.step = step;
|
||||
this.zeroable = zeroable;
|
||||
this.value = null;
|
||||
this.offset = null;
|
||||
};
|
||||
|
||||
validate(): boolean {
|
||||
let tip = new ErrorToolTip(this.id);
|
||||
tip.clear();
|
||||
if (Number.isNaN(this.value) || this.value === null) {
|
||||
if (Number.isNaN(this.value) || !this.value) {
|
||||
tip.setMsg(`Invalid value: Not a number`);
|
||||
tip.show();
|
||||
return false;
|
||||
@@ -52,24 +59,28 @@ class CustEntry {
|
||||
return true;
|
||||
};
|
||||
|
||||
update() {
|
||||
this.value = Number((document.getElementById(this.id) as HTMLInputElement).value);
|
||||
}
|
||||
|
||||
getInputElement(): HTMLInputElement | null {
|
||||
return document.getElementById(this.id) as HTMLInputElement;
|
||||
}
|
||||
|
||||
createForm() {
|
||||
updateValueFromElement() {
|
||||
this.value = Number(this.getInputElement()!.value);
|
||||
}
|
||||
|
||||
isAvailableFor(platform: CustPlatform): boolean {
|
||||
return platform === CustPlatform.Undefined || this.platform === platform || this.platform === CustPlatform.All;
|
||||
}
|
||||
|
||||
createElement() {
|
||||
let form = document.getElementById("form")!;
|
||||
let input = this.getInputElement();
|
||||
if (!input) {
|
||||
let grid = document.createElement("div");
|
||||
grid.classList.add("grid");
|
||||
grid.classList.add("grid", "cust-element");
|
||||
|
||||
// Label and input
|
||||
input = document.createElement("input");
|
||||
input.min = String(this.min);
|
||||
input.min = String(this.zeroable ? 0 : this.min);
|
||||
input.max = String(this.max);
|
||||
input.id = this.id;
|
||||
input.type = "number";
|
||||
@@ -82,32 +93,49 @@ class CustEntry {
|
||||
|
||||
// Description in blockquote style
|
||||
let desc = document.createElement("blockquote");
|
||||
desc.style["margin-top"] = "0";
|
||||
desc.innerHTML = this.desc;
|
||||
desc.setAttribute("for", this.id);
|
||||
grid.appendChild(desc);
|
||||
|
||||
grid.style["margin-top"] = "3rem";
|
||||
form.appendChild(grid);
|
||||
|
||||
let tooltip = new ErrorToolTip(this.id);
|
||||
tooltip.addChangeListener();
|
||||
}
|
||||
input.value = String(this.value!);
|
||||
input.value = String(this.value);
|
||||
}
|
||||
|
||||
clearForm() {
|
||||
setElementDefaultValue() {
|
||||
(document.getElementById(this.id) as HTMLInputElement).value = String(this.defval);
|
||||
}
|
||||
|
||||
removeElement() {
|
||||
let input = this.getInputElement();
|
||||
if (input) {
|
||||
input.parentElement!.parentElement!.remove();
|
||||
}
|
||||
}
|
||||
|
||||
showElement() {
|
||||
let input = this.getInputElement();
|
||||
if (input) {
|
||||
input.parentElement!.parentElement!.style.removeProperty("display");
|
||||
}
|
||||
}
|
||||
|
||||
hideElement() {
|
||||
let input = this.getInputElement();
|
||||
if (input) {
|
||||
input.parentElement!.parentElement!.style.setProperty("display", "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"mtcConf",
|
||||
"DRAM Timing",
|
||||
CustPlatform.Mariko,
|
||||
2,
|
||||
"<li><b>0</b>: AUTO_ADJ_MARIKO_SAFE: Auto adjust timings for LPDDR4 ≤3733 Mbps specs, 8Gb density. (Default)</li>\
|
||||
<li><b>1</b>: AUTO_ADJ_MARIKO_4266: Auto adjust timings for LPDDR4X 4266 Mbps specs, 8Gb density.</li>\
|
||||
@@ -119,6 +147,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"marikoCpuMaxClock",
|
||||
"Mariko CPU Max Clock in kHz",
|
||||
CustPlatform.Mariko,
|
||||
4,
|
||||
"<li>System default: 1785000</li>\
|
||||
<li>2397000 might be unreachable for some SoCs.</li>",
|
||||
@@ -129,6 +158,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"marikoCpuBoostClock",
|
||||
"Mariko CPU Boost Clock in kHz",
|
||||
CustPlatform.Mariko,
|
||||
4,
|
||||
"<li>System default: 1785000</li>\
|
||||
<li>Boost clock will be applied when applications request higher CPU frequency for quicker loading.</li>\
|
||||
@@ -141,6 +171,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"marikoCpuMaxVolt",
|
||||
"Mariko CPU Max Voltage in mV",
|
||||
CustPlatform.Mariko,
|
||||
4,
|
||||
"<li>System default: 1120</li>\
|
||||
<li>Acceptable range: 1100 ≤ x ≤ 1300</li>",
|
||||
@@ -151,6 +182,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"marikoGpuMaxClock",
|
||||
"Mariko GPU Max Clock in kHz",
|
||||
CustPlatform.Mariko,
|
||||
4,
|
||||
"<li>System default: 921600</li>\
|
||||
<li>Tegra X1+ official maximum: 1267200</li>\
|
||||
@@ -162,6 +194,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"marikoEmcMaxClock",
|
||||
"Mariko RAM Max Clock in kHz",
|
||||
CustPlatform.Mariko,
|
||||
4,
|
||||
"<li>Values should be ≥ 1600000, and divided evenly by 3200.</li>\
|
||||
<li><b>WARNING:</b> RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM</li>",
|
||||
@@ -172,6 +205,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"marikoEmcVddqVolt",
|
||||
"EMC Vddq (Mariko Only) Voltage in uV",
|
||||
CustPlatform.Mariko,
|
||||
4,
|
||||
"<li>Acceptable range: 550000 ≤ x ≤ 650000</li>\
|
||||
<li>Value should be divided evenly by 5000</li>\
|
||||
@@ -185,6 +219,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"eristaCpuMaxVolt",
|
||||
"Erista CPU Max Voltage in mV",
|
||||
CustPlatform.Erista,
|
||||
4,
|
||||
"<li>Acceptable range: 1100 ≤ x ≤ 1300</li>",
|
||||
1235,
|
||||
@@ -194,6 +229,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"eristaEmcMaxClock",
|
||||
"Erista RAM Max Clock in kHz",
|
||||
CustPlatform.Erista,
|
||||
4,
|
||||
"<li>Values should be ≥ 1600000, and divided evenly by 3200.</li>\
|
||||
<li><b>WARNING:</b> RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM</li>",
|
||||
@@ -204,6 +240,7 @@ var CustTable: Array<CustEntry> = [
|
||||
new CustEntry(
|
||||
"commonEmcMemVolt",
|
||||
"EMC Vddq (Erista Only) & RAM Vdd2 Voltage in uV",
|
||||
CustPlatform.All,
|
||||
4,
|
||||
"<li>Acceptable range: 1100000 ≤ x ≤ 1250000, and it should be divided evenly by 12500.</li>\
|
||||
<li>Erista Default (HOS): 1125000 (bootloader: 1100000)</li>\
|
||||
@@ -275,9 +312,9 @@ function SaveCust(buffer) {
|
||||
let view = new DataView(buffer);
|
||||
let storage = {};
|
||||
|
||||
for (let i of CustTable) {
|
||||
i.update();
|
||||
if (!i.validate() || i.value === null) {
|
||||
CustTable.forEach(i => {
|
||||
i.updateValueFromElement();
|
||||
if (!i.validate() || !i.value) {
|
||||
document.getElementById(i.id)!.focus();
|
||||
throw new Error(`Invalid ${i.name}`);
|
||||
}
|
||||
@@ -297,7 +334,7 @@ function SaveCust(buffer) {
|
||||
throw new Error(`Unknown size at ${i.name}`);
|
||||
}
|
||||
storage[i.id] = i.value;
|
||||
}
|
||||
});
|
||||
|
||||
storage["custRev"] = CUST_REV;
|
||||
localStorage.setItem("last_saved", JSON.stringify(storage));
|
||||
@@ -320,40 +357,34 @@ function LastSaved() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function LoadLastSaved() {
|
||||
if (LastSaved()) {
|
||||
let storage = localStorage.getItem("last_saved");
|
||||
let sObj = JSON.parse(storage!);
|
||||
for (let key in sObj) {
|
||||
if (key == "custRev") {
|
||||
continue;
|
||||
}
|
||||
(document.getElementById(key) as HTMLInputElement).value = sObj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
function CustNavTabsInit() {
|
||||
const custNavTabs = Array.from(document.querySelectorAll(`nav[role="tab-control"] > button`)) as HTMLElement[];
|
||||
custNavTabs.forEach(i => {
|
||||
i.removeAttribute("disabled");
|
||||
let platform = Number(i.getAttribute("data-filter")!) as CustPlatform;
|
||||
i.addEventListener('click', (_evt) => {
|
||||
const unfocusedClasses = ["outline", "secondary"];
|
||||
i.classList.remove(...unfocusedClasses);
|
||||
custNavTabs.filter(j => j != i).forEach(k => k.classList.add(...unfocusedClasses));
|
||||
|
||||
function LoadDefault() {
|
||||
for (let i of CustTable) {
|
||||
(document.getElementById(i.id) as HTMLInputElement).value = String(i.defval);
|
||||
}
|
||||
}
|
||||
|
||||
function ClearHTMLForm() {
|
||||
for (let i of CustTable) {
|
||||
i.clearForm();
|
||||
}
|
||||
CustTable.forEach(e => {
|
||||
if (e.isAvailableFor(platform)) {
|
||||
e.showElement();
|
||||
} else {
|
||||
e.hideElement();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function UpdateHTMLForm() {
|
||||
for (let i of CustTable) {
|
||||
i.createForm();
|
||||
}
|
||||
CustTable.forEach(i => i.createElement());
|
||||
|
||||
let default_btn = document.getElementById("load_default")!;
|
||||
default_btn.removeAttribute("disabled");
|
||||
default_btn.addEventListener('click', () => {
|
||||
LoadDefault();
|
||||
CustTable.forEach(i => i.setElementDefaultValue());
|
||||
});
|
||||
|
||||
let last_btn = document.getElementById("load_saved")!;
|
||||
@@ -361,7 +392,10 @@ function UpdateHTMLForm() {
|
||||
last_btn.style.removeProperty("display");
|
||||
last_btn.removeAttribute("disabled");
|
||||
last_btn.addEventListener('click', () => {
|
||||
LoadLastSaved();
|
||||
// Load last saved from localStorage
|
||||
JSON.parse(localStorage.getItem("last_saved")!)
|
||||
.filter((key: string) => key != "custRev")
|
||||
.forEach((key: string) => (document.getElementById(key) as HTMLInputElement).value = key);
|
||||
});
|
||||
} else {
|
||||
last_btn.style.setProperty("display", "none");
|
||||
@@ -379,17 +413,17 @@ function UpdateHTMLForm() {
|
||||
});
|
||||
}
|
||||
|
||||
function ParseCust(magicOffset, buffer) {
|
||||
function ParseCust(magicOffset: number, buffer: ArrayBuffer) {
|
||||
let view = new DataView(buffer);
|
||||
let offset = magicOffset + 4;
|
||||
let rev = view.getUint16(offset, true);
|
||||
offset += 2;
|
||||
if (rev != CUST_REV) {
|
||||
throw new Error(`Unsupported custRev, expected: ${CUST_REV}, got ${rev}`);
|
||||
}
|
||||
document.getElementById("cust_rev")!.innerHTML = `Cust V${CUST_REV} is loaded.`;
|
||||
|
||||
offset += 2;
|
||||
for (let i of CustTable) {
|
||||
CustTable.forEach(i => {
|
||||
i.offset = offset;
|
||||
switch (i.size) {
|
||||
case 2:
|
||||
@@ -404,7 +438,7 @@ function ParseCust(magicOffset, buffer) {
|
||||
}
|
||||
offset += i.size;
|
||||
i.validate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const fileInput = document.getElementById("file") as HTMLInputElement;
|
||||
@@ -413,11 +447,12 @@ fileInput.addEventListener('change', (event) => {
|
||||
reader.readAsArrayBuffer((event.target as HTMLInputElement).files![0]);
|
||||
reader.onloadend = (progEvent) => {
|
||||
if (progEvent.target!.readyState === FileReader.DONE) {
|
||||
buffer = progEvent.target!.result!;
|
||||
buffer = (progEvent.target!.result!) as ArrayBuffer;
|
||||
try {
|
||||
let offset = FindMagicOffset(buffer);
|
||||
ClearHTMLForm();
|
||||
CustTable.forEach(i => i.removeElement());
|
||||
ParseCust(offset, buffer);
|
||||
CustNavTabsInit();
|
||||
UpdateHTMLForm();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -426,7 +461,7 @@ fileInput.addEventListener('change', (event) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
/* GitHub Release fetch */
|
||||
type ReleaseInfo = {
|
||||
@@ -453,7 +488,7 @@ async function fetchRelease(): Promise<ReleaseInfo | void> {
|
||||
|
||||
const resultFromSuite = await responseFromSuite.json();
|
||||
const latestVerFromSuite = resultFromSuite.tag_name;
|
||||
const correspondingVerFromAMS = latestVerFromSuite.split(".").slice(0, 3).join(".");
|
||||
const amsVer = latestVerFromSuite.split(".").slice(0, 3).join(".");
|
||||
|
||||
const loaderKip = resultFromSuite.assets.filter((obj) => {
|
||||
return obj.name.endsWith("loader.kip");
|
||||
@@ -461,7 +496,7 @@ async function fetchRelease(): Promise<ReleaseInfo | void> {
|
||||
const sdOut = resultFromSuite.assets.filter((obj) => {
|
||||
return obj.name.endsWith(".zip");
|
||||
})[0];
|
||||
const amsReleaseUrl = `https://github.com/Atmosphere-NX/Atmosphere/releases/tags/${correspondingVerFromAMS}`;
|
||||
const amsReleaseUrl = `https://github.com/Atmosphere-NX/Atmosphere/releases/tags/${amsVer}`;
|
||||
|
||||
let info: ReleaseInfo = {
|
||||
OCSuiteVer: latestVerFromSuite,
|
||||
@@ -469,7 +504,7 @@ async function fetchRelease(): Promise<ReleaseInfo | void> {
|
||||
LoaderKipTime: loaderKip.updated_at,
|
||||
SdOutZipUrl: sdOut.browser_download_url,
|
||||
SdOutZipTime: sdOut.updated_at,
|
||||
AMSVer: correspondingVerFromAMS,
|
||||
AMSVer: amsVer,
|
||||
AMSUrl: amsReleaseUrl
|
||||
};
|
||||
return info;
|
||||
|
||||
Reference in New Issue
Block a user