From c92138f4b3f9e5716dbae41594389ed0bf0d802c Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 17 Dec 2015 12:14:28 -0800 Subject: [PATCH] Extract calculation of temperature from raw sensor value. --- firmware/application/ui_debug.cpp | 6 +++++- firmware/application/ui_debug.hpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/firmware/application/ui_debug.cpp b/firmware/application/ui_debug.cpp index 1622287f..b4355e45 100644 --- a/firmware/application/ui_debug.cpp +++ b/firmware/application/ui_debug.cpp @@ -76,7 +76,7 @@ void TemperatureWidget::paint(Painter& painter) { } if( !history.empty() ) { - const int32_t temp = -45 + history.back() * 5; + const int32_t temp = temperature(history.back()); const size_t temp_len = 3; painter.draw_string( { static_cast(rect.right() - (temp_len * 8)), rect.top() }, @@ -86,6 +86,10 @@ void TemperatureWidget::paint(Painter& painter) { } } +int32_t TemperatureWidget::temperature(const int32_t sensor_value) { + return -45 + sensor_value * 5 +} + /* TemperatureView *******************************************************/ TemperatureView::TemperatureView(NavigationView& nav) { diff --git a/firmware/application/ui_debug.hpp b/firmware/application/ui_debug.hpp index cfd7f7ad..2c83b6a8 100644 --- a/firmware/application/ui_debug.hpp +++ b/firmware/application/ui_debug.hpp @@ -93,6 +93,7 @@ public: void paint(Painter& painter) override; private: + int32_t temperature(const uint32_t sensor_value); }; class TemperatureView : public View {