I am reading a PNG file from a website:
String zoom = "5"; // Test Values
String xmap = "30"; // Need to be adjusted
String ymap = "30";
String serverPathMap = "http://tile.openweathermap.org/map/precipitation_new/" +
zoom + "/" + xmap + "/" + ymap + ".png?" + "APPID=" + openWeatherMapApiKey;
I'm using this to get the PNG file into the String JSONBuffer.
jsonBuffer = httpGETRequest(serverPathMap.c_str());
I verified the PNG file is correct by the correct received header. However, I need it in HEX formatted data.
This is an Example of the format of a file created directly by the compiler.
const LV_ATTRIBUTE_MEM_ALIGN uint8_t ui_img_clock_face_150x150_fixed_png_data = {
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, ...
I have the code set to have the website read every hour, or at the press of a button. Currently the PNG file is stored in a String "JSONBuffer". I can get the size easily by JSONBuffer.length();
I'm trying to display the image in a Squareline Studio Image placeholder:
//lv_image_set_src(ui_OpenWeatherMap, "Image from the Buffer");
ui_OpenWeatherMap //is the name of the image placeholder.
My question is, how to convert to my JSonBuffer to HEX. I have seen it done in python, but I'm not good enough in python to convert it into C++.
Any help would be greatly appreciated.
I have tried several things.
Displayes the entire buffer. Not in HEX
Serial.println("jsonBuffer: ");
Serial.println(jsonBuffer);
Only displays the 1st 10 or so HEX numbers.
snprintf(tempMap, bufferMapStringSize, "%s", jsonBuffer.c_str(), HEX);
Serial.println("jsonBuffer: ");
Serial.println(jsonBuffer);
Trying to insert the buffer directly doesn't work either.
lv_image_set_src(ui_OpenWeatherMap, jsonBuffer.c_str());
I have tried many other things as well.
lv_image_set_src()is actually expecting from you.0xFFto255-- that is, change the hexadecimal representation to the equivalent decimal representation -- without changing the compiled result.)