Hi all! I am working on an Arduino ESP32 project. My goal is to have a display on a beer tap handle that shows the beer name and information. I have 41 images that relate to the beer color (SRM) based on a value in a JSON retrieved from my server.
Right now, my ESP32 gets the JSON of my active beers, and it loads all the text perfectly. Where I am stuck is getting the image to appear. I converted them all to .bin files, and I was going to use the SRM value to call the correct .bin file name from SPIFFS, but I had trouble getting the file system to play nice, so I am skipping past this method.
I have now added all the images to my assets and had SquareLine export/declare them, so all are declared as ui_img_nsrm#_png, where # represents the SRM value I want to call (so a beer with an SRM of 4 would use ui_img_nsrm4_png). Since I cannot find how to pass a variable name for lv_img_set_src based on a constructed string (I really wish I could just use JavaScript, hah), I figure I could perhaps have all the images and their data put into an array, then the SRM level could correspond to the index in the array, then that data could be used to show the correct image.
Is there a method to do this in Arduino?
Alternatively, I could update my JSON response to include a URL to the corresponding image (either .bin or .png). From there, my ESP32 could retrieve the file from that URL, then LVGL could render the image. Where I am stuck is how to get the image stored in a way for LVGL to then render. Does anyone have an example of this approach or an idea on how to tackle it?
My least preferred approach here is to have a very long switch where a case of the SRM number calls lv_img_set_src with the corresponding image since it would just be a very long switch.
Thanks for any help or ideas!