79148089

Date: 2024-11-01 13:11:16
Score: 1
Natty:
Report link

There is no support for dictionaries in C, so you'll have to either implement a dictionary yourself or borrow someone else's implementation.

Since the names of the image already have an identifier, you can put the raw image data in an nested array like this:

static uint8_t image_data[][] PROGMEM = {
    {/* wsymbol_0001_sunny */}, 
    {/* wsymbol_0002_sunny_intervals */}, 
    {/* ... */}
}
char *symbols[] = {
    "wsymbol_0001_sunny",
    "wsymbol_0002_sunny_intervals",
    "wsymbol_0003_white_cloud"
};

Then you can access an image by its name like this:

image_data[atoi(symbols[1]+8)-1];

This will break if the number in the name of the image is not the correct index of the image data. If you want a proper dictionary then you have to use something like this: https://stackoverflow.com/a/4384446

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Tom