From ee1dc7bbea98328ab182ea5ca675949f8b92d047 Mon Sep 17 00:00:00 2001 From: eleksir Date: Sat, 17 Aug 2019 11:20:26 +0300 Subject: [PATCH] Adjusted brightness table, simplify display drawing algo. --- simpleclock.ino | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/simpleclock.ino b/simpleclock.ino index ecd31c6..ce9c2ce 100644 --- a/simpleclock.ino +++ b/simpleclock.ino @@ -248,15 +248,15 @@ void loop() } else if ((ambLight < 350) and (ambLight >= 310)) { Display.setBrightness(-3); } else if ((ambLight < 300) and (ambLight >= 260)) { - Display.setBrightness(-5); + Display.setBrightness(-6); } else if ((ambLight < 250) and (ambLight >= 210)) { - Display.setBrightness(-7); + Display.setBrightness(-10); } else if ((ambLight < 200) and (ambLight >= 160)) { - Display.setBrightness(-9); + Display.setBrightness(-14); } else if ((ambLight < 150) and (ambLight >= 110)) { - Display.setBrightness(-12); + Display.setBrightness(-18); } else if (ambLight < 100) { - Display.setBrightness(-15); + Display.setBrightness(-22); } } @@ -265,27 +265,14 @@ void loop() void updateTimeStr(uint8_t h, uint8_t m) { - char str[4]; - float d; - - // make blinking dot - if (h > 0) { - if (dot) { - Display.setNumber((h * 100 + m), 2); - } else { - Display.setNumber((h * 100 + m)); - } - } else { - /* 0 o'clock is an exception, we don't want to see "00.00", we - want see "0.00" or "0 00", so we have to use this "hack" */ - if (dot) { - d = float(m) / 100; - Display.setNumber(d, 2); - } else { - sprintf(str, "%2d%02d", h, m); - Display.setChars(str); - } + if (dot) { + char str[5]; + sprintf(str, "%2d.%02d", h, m); + Display.setChars(str); + } else { + char str[4]; + sprintf(str, "%2d%02d", h, m); + Display.setChars(str); } - } /* vim: set filetype=cpp: */