Browse Source

add logic to settings to hide useless options depending on display type, and respect i18n

pull/1339/head
you69man 1 year ago
parent
commit
c9c4f20ec3
  1. 56
      src/web/html/setup.html
  2. 52
      src/web/lang.json

56
src/web/html/setup.html

@ -287,18 +287,20 @@
<div class="col-4 col-sm-9"><input type="checkbox" name="disp_pwr"/></div>
</div>
<div id="screenSaver"></div>
<div class="row mb-3">
<div class="row mb-3" id="luminanceOption">
<div class="col-12 col-sm-3 my-2">{#DISP_LUMINANCE}</div>
<div class="col-12 col-sm-9"><input type="number" name="disp_cont" min="0" max="255"></select></div>
</div>
<p class="des">{#DISP_PINOUT}</p>
<div id="dispPins"></div>
<div id="pirPin"></div>
<p class="des">Graph options</p>
<div id="graphSize"></div>
<div class="row mb-3">
<div class="col-12 col-sm-3 my-2">Show ratio (0-100 %)</div>
<div class="col-12 col-sm-9"><input type="number" name="disp_graph_ratio" min="0" max="100"></select></div>
<div id="graphOptions">
<p class="des">{#GRAPH_OPTIONS}</p>
<div id="graphSize"></div>
<div class="row mb-3">
<div class="col-12 col-sm-3 my-2">{#GRAPH_SHOW_RATIO}</div>
<div class="col-12 col-sm-9"><input type="number" name="disp_graph_ratio" min="0" max="100"></select></div>
</div>
</div>
</fieldset>
</div>
@ -1095,12 +1097,12 @@
document.getElementsByName("disp_graph_ratio")[0].value = obj["disp_graph_ratio"];
var opts2 = [[0, "Line 1 - 2"], [1, "Line 2 - 3"], [2, "Line 1 - 3"], [3, "Line 2 - 4"], [4, "Line 1 - 4"]];
var opts2 = [[0, "{#GRAPH_LINES_1_2}"], [1, "{#GRAPH_LINES_2_3}"], [2, "{#GRAPH_LINES_1_3}"], [3, "{#GRAPH_LINES_2_4}"], [4, "{#GRAPH_LINES_1_4}"]];
var graph_size_sel = sel("disp_graph_size", opts2, obj["disp_graph_size"]);
graph_size_sel.id = 'disp_graph_size';
document.getElementById("graphSize").append(
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-12 col-sm-3 my-2"}, "Graph size"),
ml("div", {class: "col-12 col-sm-3 my-2"}, "{#GRAPH_POSITION}"),
ml("div", {class: "col-12 col-sm-9"}, graph_size_sel)
])
);
@ -1113,14 +1115,14 @@
// It depends on fix pin array (see var pins)
// var pins = [['clock', 'disp_clk'], ['data', 'disp_data'], ['cs', 'disp_cs'], ['dc', 'disp_dc'], ['reset', 'disp_rst']];
const pinMap = new Map([
[0, [0,0,0,0,0,0]], //none
[1, [1,1,0,0,0,0]], //SSD1306_128X64
[2, [1,1,0,0,0,0]], //SH1106_128X64
[3, [1,1,1,1,0,0]], //PCD8544_84X48 /nokia5110
[4, [1,1,0,0,0,0]], //SSD1306_128X32
[5, [1,1,0,0,0,0]], //SSD1306_128x64
[6, [1,1,0,0,0,0]], //SSD1309_128x64
[10, [1,1,1,1,1,1]] //ePaper
[0, [0,0,0,0,0,0]], //none
[1, [1,1,0,0,0,0]], //SSD1306_128X64
[2, [1,1,0,0,0,0]], //SH1106_128X64
[3, [1,1,1,1,0,0]], //PCD8544_84X48 /nokia5110
[4, [1,1,0,0,0,0]], //SSD1306_128X32
[5, [1,1,0,0,0,0]], //SSD1306_64X48
[6, [1,1,0,0,0,0]], //SSD1309_128x64
[10, [1,1,1,1,1,1]] //ePaper
])
for(var i = 0; i < pins.length; i++) {
var cl = document.getElementById("row_" + pins[i][1]).classList;
@ -1132,14 +1134,22 @@
}
}
var screenSaver = document.getElementById("disp_screensaver").value;
const optionsMap = new Map([ // options: [Graph, Luminance, Screensaver]
[0, [0,0,0]], //none
[1, [1,1,1]], //SSD1306_128X64
[2, [1,1,1]], //SH1106_128X64
[3, [1,1,0]], //PCD8544_84X48 /nokia5110
[4, [0,1,1]], //SSD1306_128X32
[5, [0,1,1]], //SSD1306_64X48
[6, [1,1,1]], //SSD1309_128x64
[10, [0,0,0]] //ePaper
])
if (2==screenSaver) { // show pir pin only for motion screensaver
setHide("pirPin", false);
}
else { // no pir pin for all others
setHide("pirPin", true);
}
var screenSaver = document.getElementById("disp_screensaver").value;
setHide("graphOptions", !optionsMap.get(dispType)[0]);
setHide("luminanceOption", !optionsMap.get(dispType)[1]);
setHide("screenSaver", !optionsMap.get(dispType)[2]);
setHide("pirPin", !(optionsMap.get(dispType)[2] && (screenSaver==2))); // show pir pin only for motion screensaver
}
function tick() {

52
src/web/lang.json

@ -301,7 +301,7 @@
{
"token": "NTP_SET_SYS_TIME",
"en": "set system time",
"de": "Systemzeit setzten"
"de": "Systemzeit setzen"
},
{
"token": "BTN_FROM_BROWSER",
@ -311,7 +311,7 @@
{
"token": "BTN_SYNC_NTP",
"en": "sync NTP",
"de": "NTP syncchronisieren"
"de": "NTP synchronisieren"
},
{
"token": "NTP_SYS_TIME",
@ -366,7 +366,7 @@
{
"token": "DISP_OFF_INV",
"en": "Turn off while inverters are offline",
"de": "schalte das Display aus, w&auml;hrend die Wechselrichter aus sind"
"de": "Schalte das Display aus, w&auml;hrend die Wechselrichter aus sind"
},
{
"token": "DISP_LUMINANCE",
@ -378,6 +378,46 @@
"en": "Pinout",
"de": "Anschlusseinstellungen"
},
{
"token": "GRAPH_OPTIONS",
"en": "Graph options",
"de": "Graph Einstellungen"
},
{
"token": "GRAPH_SHOW_RATIO",
"en": "Graph show ratio (0-100%)",
"de": "Graph Anzeigeverh&auml;ltnis (0-100%)"
},
{
"token": "GRAPH_POSITION",
"en": "Graph pos (from/to)",
"de": "Graph Position (von/bis)"
},
{
"token": "GRAPH_LINES_1_2",
"en": "Line 1-2",
"de": "Zeile 1-2"
},
{
"token": "GRAPH_LINES_2_3",
"en": "Line 2-3",
"de": "Zeile 2-3"
},
{
"token": "GRAPH_LINES_1_3",
"en": "Line 1-3",
"de": "Zeile 1-3"
},
{
"token": "GRAPH_LINES_2_4",
"en": "Line 2-4",
"de": "Zeile 2-4"
},
{
"token": "GRAPH_LINES_1_4",
"en": "Line 1-4",
"de": "Zeile 1-4"
},
{
"token": "BTN_REBOOT_SUCCESSFUL_SAVE",
"en": "Reboot device after successful save",
@ -476,7 +516,7 @@
{
"token": "NTP_SYNCED_AT",
"en": "synced at",
"de": "syncchronisiert um"
"de": "synchronisiert um"
},
{
"token": "NTP_DIFF",
@ -491,7 +531,7 @@
{
"token": "IMPORT_UPLOAD_STARTED",
"en": "upload started",
"de": "hochladen gestartet"
"de": "Hochladen gestartet"
},
{
"token": "INV_EDIT",
@ -681,7 +721,7 @@
{
"token": "DISP_SCREENSAVER",
"en": "Screensaver (OLED only)",
"de": "Bildschrimschoner (nur OLED)"
"de": "Bildschirmschoner (nur OLED)"
},
{
"token": "NETWORK_PLEASE_SELECT",

Loading…
Cancel
Save