Change display ledtable location from RAM to flash

Change display ledtable location from RAM to flash
This commit is contained in:
Theo Arends 2019-08-16 17:29:19 +02:00
parent c61f2cc5ec
commit b5f290b4a2
1 changed files with 8 additions and 0 deletions

View File

@ -174,7 +174,11 @@ const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255
// from 11 bits (lower values) to 8 bits (upper values).
// We're using the fact that lower values are small and can fit within 8 bits
// To save flash space, the array is only 8 bits uint
#ifdef XFUNC_PTR_IN_ROM
const uint8_t _ledTable[] PROGMEM = {
#else
const uint8_t _ledTable[] = {
#endif
// 11 bits resolution
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, // 11 bits, 0..2047
2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, // 11 bits, 0..2047
@ -997,7 +1001,11 @@ uint16_t ledGamma(uint8_t v, uint16_t bits_out = 8) {
// bits_resolution: the resolution of _ledTable[v], between 8 and 11
uint32_t bits_resolution = 11 - (v / 64); // 8..11
int32_t bits_correction = bits_out - bits_resolution; // -3..3
#ifdef XFUNC_PTR_IN_ROM
uint32_t uncorrected_value = pgm_read_byte(_ledTable + v); // 0..255
#else
uint32_t uncorrected_value = _ledTable[v]; // 0..255
#endif
if (0 == bits_correction) {
// we already match the required resolution, no change
result = uncorrected_value;