summaryrefslogtreecommitdiffstats
path: root/Meter.c
diff options
context:
space:
mode:
authorMichael F. Schönitzer <michael@schoenitzer.de>2021-02-26 22:17:03 +0100
committerMichael F. Schönitzer <michael@schoenitzer.de>2021-02-28 17:42:10 +0100
commit76350c0350e6bd0335668d79842339732b3823ee (patch)
tree78464c8e63076b28a9327682402fa419731d2a6c /Meter.c
parent12c2337939cbdee21c437c28646f128667a162de (diff)
Rescale graph when value of total is changed
Diffstat (limited to 'Meter.c')
-rw-r--r--Meter.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Meter.c b/Meter.c
index e42b29b9..e8bfaad0 100644
--- a/Meter.c
+++ b/Meter.c
@@ -334,7 +334,6 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
double value = 0.0;
for (uint8_t i = 0; i < this->curItems; i++)
value += this->values[i];
- value /= this->total;
data->values[nValues - 1] = value;
}
@@ -345,8 +344,10 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
}
for (; i < nValues - 1; i += 2, k++) {
int pix = GraphMeterMode_pixPerRow * GRAPH_HEIGHT;
- int v1 = CLAMP((int) lround(data->values[i] * pix), 1, pix);
- int v2 = CLAMP((int) lround(data->values[i + 1] * pix), 1, pix);
+ if (this->total < 1)
+ this->total = 1;
+ int v1 = CLAMP((int) lround(data->values[i] / this->total * pix), 1, pix);
+ int v2 = CLAMP((int) lround(data->values[i + 1] / this->total * pix), 1, pix);
int colorIdx = GRAPH_1;
for (int line = 0; line < GRAPH_HEIGHT; line++) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy