0

I have an array of colors for my tft screen:

const uint16_t colorTheme [] PROGMEM = {BLACK, WHITE, NAVY, CYAN, RED, GREEN, VERDEAQ, PINK, ORANGE, PURPLE, GRAY, YELLOW};

When I try to use colorTheme [EEPROM.read (2500)] I am returned with a value of any garbage, or a value of 0, and I checked it in read_eeprom and the value of EEPROM.read (2500) is equal to 4, and 4 in mine vector is cyan color, not black or 0 number, why does this go so wrong?

asked Apr 17, 2020 at 19:38

1 Answer 1

1

Your array is in PROGMEM, but you are accessing it as if it were in RAM.

You must use pgm_read_word() to access the data in your array.

pgm_read_word(&(colorTheme[EEPROM.read(x)]))

BTW - what Arduino board has more than 2kB of EEPROM?

answered Apr 17, 2020 at 19:42
1

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.