From 4c7776655a88dc0dad2e63d1488096b693ad8bc3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Aug 2013 04:24:51 +0000 Subject: [PATCH] Replace some of the math in SetBrightness() with a simpler, but exactly equivalent, formula. Interestingly, this doesn't change the compiled code size--perhaps the compiler is smarter than I thought. At least it's easier to understand now. --- lib/Charliplexing.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Charliplexing.cpp b/lib/Charliplexing.cpp index 67d314b..3d601cf 100644 --- a/lib/Charliplexing.cpp +++ b/lib/Charliplexing.cpp @@ -445,12 +445,11 @@ void LedSign::SetBrightness(uint8_t brightness) #else // NOTE: Changing "scale" invalidates any tables above! const float scale = 1.8f; - const float delta = pow(max, 1.0f / scale) / (SHADES - 1); int counts[SHADES]; - counts[0] = 0; + counts[0] = 0.0f; for (i=1; i