From b0880d6effe0fa69fa16460de8b77f35fd75930f Mon Sep 17 00:00:00 2001
From: euquiq <31453004+euquiq@users.noreply.github.com>
Date: Mon, 29 Jun 2020 18:01:15 -0300
Subject: [PATCH] Nicer debug -> temperature graph
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Lowered the scale -10 ºC so it accomodates less than zero temperatures, present sometimes when cold starting the system.

Added 1 char for temperature label length.

Adjusted the max2837 sensor value -> ºC temp result, by normalizing the conversion to correctly display the standard 25ºC, mentioned in Datasheet.
---
 firmware/application/apps/ui_debug.cpp | 2 +-
 firmware/application/apps/ui_debug.hpp | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/firmware/application/apps/ui_debug.cpp b/firmware/application/apps/ui_debug.cpp
index 6d81f620..8622911c 100644
--- a/firmware/application/apps/ui_debug.cpp
+++ b/firmware/application/apps/ui_debug.cpp
@@ -121,7 +121,7 @@ void TemperatureWidget::paint(Painter& painter) {
 }
 
 TemperatureWidget::temperature_t TemperatureWidget::temperature(const sample_t sensor_value) const {
-	return -45 + sensor_value * 5;
+	return -35 + sensor_value * 4;  //max2837 datasheet temp 25ºC has sensor value: 15
 }
 
 std::string TemperatureWidget::temperature_str(const temperature_t temperature) const {
diff --git a/firmware/application/apps/ui_debug.hpp b/firmware/application/apps/ui_debug.hpp
index 65899698..1e3d6003 100644
--- a/firmware/application/apps/ui_debug.hpp
+++ b/firmware/application/apps/ui_debug.hpp
@@ -101,10 +101,10 @@ private:
 
 	std::string temperature_str(const temperature_t temperature) const;
 
-	static constexpr temperature_t display_temp_min = 0;
+	static constexpr temperature_t display_temp_min = -10;  //Accomodate negative values, present in cold startup cases
 	static constexpr temperature_t display_temp_scale = 3;
 	static constexpr int bar_width = 1;
-	static constexpr int temp_len = 3;
+	static constexpr int temp_len = 4; //Now scale shows up to 4 chars ("-10C")
 };
 
 class TemperatureView : public View {
-- 
GitLab