mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
* Add rough calls to ADC2 [untested] * Using dual ADC injected modes * Start both ADCs * Move some IRQ's to ram exec * Stabilize PID a bit more * Add in ideas for tip type selection * Add tiptype formula / settings struct * Add function ids to the settings menu * Rough tip selection * Rough out new cal routine for simple tips * Hardware test is fairly close for first pass * Add Simple calibration case [UNTESTED] This adds the calibration option that uses boiling water to the calibration menu. This is untested, and may need gain adjustments before use. * Simple Cal Roughly working * Rough out advanced cal
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
function saveToFile(txt, filename){
|
|
var a = document.createElement('a');
|
|
a.setAttribute("style", "display: none");
|
|
document.body.appendChild(a);
|
|
a.setAttribute('href', 'data:application/json;charset=utf-8,'+encodeURIComponent(txt));
|
|
a.setAttribute('download', filename);
|
|
a.click();
|
|
document.body.removeChild(a);
|
|
}
|
|
|
|
function saveJSON(obj, filename){
|
|
var txt = JSON.stringify(obj,"", "\t");
|
|
saveToFile(txt, filename);
|
|
}
|
|
|
|
function showJSON(obj, filename) {
|
|
var txt = JSON.stringify(obj,"", "\t");
|
|
var a = window.open("", "_blank").document;
|
|
a.write("<PLAINTEXT>");
|
|
a.write(txt);
|
|
a.title = filename;
|
|
}
|
|
|
|
function startsWith(str, prefix) {
|
|
return str.substring(0, prefix.length) == prefix;
|
|
}
|
|
|
|
function endsWith(str, suffix) {
|
|
return str.substring(str.length-suffix.length) == suffix;
|
|
}
|
|
|
|
function isDefined(obj) {
|
|
return typeof obj !== 'undefined';
|
|
}
|
|
|
|
function isNumber(obj) {
|
|
return isDefined(obj) && obj != null;
|
|
}
|
|
|
|
function isDefinedNN(obj) {
|
|
return isDefined(obj) && obj != null;
|
|
}
|
|
|
|
function padLeft(str, chr, maxLen) {
|
|
str = str.toString();
|
|
return str.length < maxLen ? padLeft(chr + str, chr, maxLen) : str;
|
|
}
|
|
|
|
// sourceArray contains a list of objects that have a property "id". This methods makes a map using the "id" as a key, and the owning object as a value.
|
|
function copyArrayToMap(sourceArray, map) {
|
|
if (!isDefined(map)) {
|
|
map = {};
|
|
}
|
|
var len = sourceArray.length;
|
|
for (var i = 0; i<len; i++) {
|
|
var v = sourceArray[i];
|
|
map[v.id] = v;
|
|
}
|
|
return map;
|
|
}
|
|
|
|
function checkTranslationFile(fileName) {
|
|
return startsWith(fileName, "translation_") && endsWith(fileName, ".json") || confirm("Are you sure that you want to use "+fileName+" instead of a translation_*.json file?");
|
|
}
|
|
|
|
function xunescape(str) {
|
|
return str.replace(/\\/g, "");
|
|
}
|