Skip to content

Commit

Permalink
Merge pull request #3 from y3rs1n14/addons
Browse files Browse the repository at this point in the history
pvvis: implement recent changes/requirements
  • Loading branch information
mr-petz committed Jul 4, 2023
2 parents bb7bff8 + 4a617d5 commit 2f3e84d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions www/ftui/components/pvvis/pvvis.component.css
Expand Up @@ -3,7 +3,7 @@
*
* based on papas version for FTU2
* by yersinia & mr_petz & docolli
* version 2022-11-30
* version 2023-07-04
*
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
*
Expand Down Expand Up @@ -313,7 +313,7 @@
#pvvis-own-cons-flow,
#pvvis-own-cons-circle {
stroke: var(--pvvis-color-grey, grey);
fill: none;
fill: transparent; /* none; */
display: none;
}
#pvvis-autarky-flow,
Expand Down
21 changes: 11 additions & 10 deletions www/ftui/components/pvvis/pvvis.component.js
Expand Up @@ -3,7 +3,7 @@
*
* based on papas version for FTUI2
* by yersinia & mr_petz & Shadow3561 & docolli
* version 2022-11-30
* version 2023-07-04
*
* Under MIT License (http://www.opensource.org/licenses/mit-license.php)
*
Expand Down Expand Up @@ -330,7 +330,8 @@ export class FtuiPvvis extends FtuiElement {
{ pct: 50, color: { r: 0x99, g: 0x99, b: 0 } },
{ pct: 100, color: { r: 0x00, g: 0x99, b: 0 } }
];
for (var i = 1; i < percentColors.length - 1; i++) { if (value < percentColors[i].pct) { break; } }
let i = 1;
for (i; i < percentColors.length - 1; i++) { if (value < percentColors[i].pct) { break; } }
const lower = percentColors[i - 1];
const upper = percentColors[i];
const range = upper.pct - lower.pct;
Expand Down Expand Up @@ -380,7 +381,7 @@ export class FtuiPvvis extends FtuiElement {
if ((this.doNotShowZero) && (houseConsume.toFixed() == 0)) {
this.shadowRoot.getElementById("home-consume-txt").innerHTML = '';
} else {
this.shadowRoot.getElementById("home-consume-txt").innerHTML = houseConsume.toFixed();
this.shadowRoot.getElementById("home-consume-txt").innerHTML = houseConsume; //.toFixed();
if (this.unitValue) { this.shadowRoot.getElementById("home-consume-txt").innerHTML += '<tspan class="pvvis-txt-unit-value">' + this.unitValue + '</tspan>'; }
}
}
Expand All @@ -393,7 +394,7 @@ export class FtuiPvvis extends FtuiElement {
}

calcSunOpacity() {
const sunOpacity = 0.2 + (0.8 * (Math.abs(this.produce) / this.pvmax));
let sunOpacity = 0.2 + (0.8 * (Math.abs(this.produce) / this.pvmax));
this.sun.style.opacity = sunOpacity.toFixed(3);
this.sun.classList.remove("pvvis-sun-inactive", "pvvis-sun-active");
if (Math.abs(this.produce) > 0) {
Expand All @@ -407,7 +408,7 @@ export class FtuiPvvis extends FtuiElement {
}

colorGrid() {
const consumption = this.receive + this.gridCharge - this.feed;
let consumption = this.receive + this.gridCharge - this.feed;
this.grid.classList.remove("pvvis-grid-feed", "pvvis-grid-consume", "pvvis-grid-neutral");
if (consumption > this.flowThreshold) { this.grid.classList.add("pvvis-grid-consume"); }
else if (consumption < -this.flowThreshold) { this.grid.classList.add("pvvis-grid-feed"); }
Expand Down Expand Up @@ -446,9 +447,9 @@ export class FtuiPvvis extends FtuiElement {
}

colorBat() {
const chargeval = this.charge + this.gridCharge - this.discharge;
let chargeval = this.charge + this.gridCharge - this.discharge;
let batRemaining;
const socdiv = (this.calcBatRemainSocNotPercent ? this.batmax : 100);
let socdiv = (this.calcBatRemainSocNotPercent ? this.batmax : 100);
this.battery.classList.remove("pvvis-battery-charge", "pvvis-battery-discharge", "pvvis-battery-neutral");
if (chargeval < 0) {
// discharge
Expand Down Expand Up @@ -476,8 +477,8 @@ export class FtuiPvvis extends FtuiElement {
//loadbar battery
const loadbarUpperLimit = 36; //px for y when 100% charged
const loadbarLowerLimit = 272; //px for y when 0% charged
const loadbarPosArea = loadbarLowerLimit - loadbarUpperLimit;
const loadbarPosY = (((socdiv - this.soc) * loadbarPosArea) / socdiv) + loadbarUpperLimit;
let loadbarPosArea = loadbarLowerLimit - loadbarUpperLimit;
let loadbarPosY = (((socdiv - this.soc) * loadbarPosArea) / socdiv) + loadbarUpperLimit;
this.shadowRoot.getElementById("pvvis-bat-load-bar").setAttribute("y", "" + loadbarPosY.toFixed() + "");
this.shadowRoot.getElementById("pvvis-bat-load-triangle").setAttribute("transform", "translate(0, " + (loadbarPosY - loadbarUpperLimit + 5).toFixed() + ")"); //5 =half height of bar (10)
}
Expand All @@ -499,7 +500,7 @@ export class FtuiPvvis extends FtuiElement {
if ((this.doNotShowZero) && (Math.round(src) == 0)) {
this.shadowRoot.getElementById(obj + "-txt").innerHTML = '';
} else {
this.shadowRoot.getElementById(obj + "-txt").innerHTML = src.toFixed();
this.shadowRoot.getElementById(obj + "-txt").innerHTML = src; //.toFixed();
if (this.unitValue) { this.shadowRoot.getElementById(obj + "-txt").innerHTML += '<tspan class="pvvis-txt-unit-value">' + this.unitValue + '</tspan>'; }
}
}
Expand Down

0 comments on commit 2f3e84d

Please sign in to comment.