From 32f9365ee36f9e8a4c92745180c2231a6bf5f423 Mon Sep 17 00:00:00 2001 From: hg Date: Tue, 3 Mar 2015 21:56:18 +0100 Subject: [PATCH] negative numbers are displayed correctly too --- src/display.cpp | 1 + src/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 4b73a15..ac7e201 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -117,6 +117,7 @@ void dispSet(uint8_t unit, int16_t value) { dispSetError(); } else { uint8_t neg = (value < 0) ? 1 : 0; + value = (value < 0) ? -1 * value : value; // value = abs(value); uint8_t digit3 = value / 1000; diff --git a/src/main.cpp b/src/main.cpp index f63d130..97fb3a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,8 +35,8 @@ int main() { spiInit(); dispInit(); - dispSet(0, 12); - dispSet(1, 437); + dispSet(0, -12); + dispSet(1, -990); __enable_interrupt();