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.
This commit is contained in:
root
2013-08-27 04:24:51 +00:00
parent b323909c49
commit 4c7776655a
+2 -3
View File
@@ -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<SHADES; i++)
counts[i] = pow(i * delta, scale) * brightnessPercent * fastPrescaler.relativeSpeed + 0.49999f;
counts[i] = C(pow(i / (float)(SHADES - 1), scale));
#endif
// Wait until the previous brightness request goes through