From d435f5bb5b3e76b605992c7f5eab4fe7ff070e83 Mon Sep 17 00:00:00 2001 From: Stefan Heinrichsen Date: Thu, 3 Dec 2020 19:51:46 +0100 Subject: [PATCH] Skalierung des Graphen angepasst (250=Pixel 0, 5000ppm=Pixel 16) --- src/ebk_co2ampel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ebk_co2ampel.cpp b/src/ebk_co2ampel.cpp index fda4a97..c04e729 100644 --- a/src/ebk_co2ampel.cpp +++ b/src/ebk_co2ampel.cpp @@ -183,8 +183,8 @@ void setup() { Serial.flush(); } -int calc_vpos_for_co2(int co2val, int display_height) { - return display_height - int((float(display_height) / 3000) * co2val); +int calc_vpos_for_co2(int co2val, int max_height) { + return int((float(max_height) / (5000-350)) * (co2val-350)); } void set_led_color(int co2) { @@ -269,8 +269,8 @@ void updateDisplayCO2(int co2) { for (int h = 1; h < 120; h = h + 1) { int curval = lastvals[h]; if (curval > 0) { - int vpos = calc_vpos_for_co2(lastvals[h], dheight); - int vpos_last = calc_vpos_for_co2(lastvals[h - 1], dheight); + int vpos = 63 - calc_vpos_for_co2(lastvals[h], 16); + int vpos_last = 63 - calc_vpos_for_co2(lastvals[h - 1], 16); display.drawLine(h - 1, vpos_last, h, vpos); } }