29 #if defined(NEOPIXEBUS_NO_STL)
64 uint8_t hi = (value >> 8);
65 uint16_t lo = (value & 0x00ff);
66 uint8_t hiResult = _table[hi];
67 uint16_t lowResult = 0;
72 lowResult = (lo + _hints[hi].
pos * 256) / _hints[hi].count;
82 if (hiResult == _table[hi - 1])
85 lowResult = (lo >> 1) | 0x80;
89 uint8_t delta = _table[hi + 1] - hiResult;
94 lowResult = (lo >> 1);
104 lowResult = delta * lo;
110 return (
static_cast<uint16_t
>(hiResult) << 8) + lowResult;
122 for (uint16_t entry = 0; entry < 256; entry++)
124 _table[entry] =
static_cast<uint8_t
>(255.0f * calc(entry / 255.0f) + 0.5f);
137 uint16_t entryStart = 0;
138 uint16_t entryEnd = 0;
139 uint16_t entryLastTriplet = 0;
141 while (entryStart < 255)
143 uint8_t value = _table[entryStart];
145 while (value == _table[entryEnd] && entryEnd < 255)
150 if (entryEnd == entryStart)
157 uint8_t count = entryEnd - entryStart;
164 entryLastTriplet = entryEnd;
168 while (entryStart != entryEnd)
170 hints[entryStart].
count = count;
171 hints[entryStart].
pos = pos;
177 _hintsCount = entryLastTriplet;
189 Serial.println(
"8 bit:");
190 for (uint16_t entry = 0; entry < 256; entry++)
196 Serial.print(_table[entry]);
202 Serial.print(
"16 bit: hintsCount = ");
203 Serial.println(_hintsCount);
206 for (uint8_t hint = 0; hint < _hintsCount; hint++)
213 Serial.print(_hints[hint].pos);
215 Serial.print(_hints[hint].count);
223 static uint8_t _table[256];
224 static NeoGamma16LowHint* _hints;
225 static uint8_t _hintsCount;
std::function< float(float unitValue)> GammaCalcFunction
Definition: NeoGammaDynamicTableMethod.h:38
Definition: NeoGammaDynamicTableMethod.h:43
static void Initialize(GammaCalcFunction calc, bool optimize16Bit=false)
Definition: NeoGammaDynamicTableMethod.h:113
static void SerialDumpTables()
Definition: NeoGammaDynamicTableMethod.h:186
static uint16_t Correct(uint16_t value)
Definition: NeoGammaDynamicTableMethod.h:57
static uint8_t Correct(uint8_t value)
Definition: NeoGammaDynamicTableMethod.h:52
Definition: NeoGammaDynamicTableMethod.h:46
uint8_t pos
Definition: NeoGammaDynamicTableMethod.h:47
uint8_t count
Definition: NeoGammaDynamicTableMethod.h:48