** Function: loopVersions ** Where you choose which version to install/download ** **********************************************************************/
| 1069 | ** Where you choose which version to install/download ** |
| 1070 | **********************************************************************/ |
| 1071 | void loopVersions(String _fid) { |
| 1072 | JsonDocument item = getVersionInfo(_fid); |
| 1073 | |
| 1074 | int versionIndex = 0; |
| 1075 | const char *name = item["name"]; |
| 1076 | const char *author = item["author"]; |
| 1077 | const char *fid = item["fid"]; |
| 1078 | const bool star = item["star"].as<bool>(); |
| 1079 | JsonArray versions = item["versions"]; |
| 1080 | bool redraw = true; |
| 1081 | |
| 1082 | LongPressTmp = launcherMillis(); |
| 1083 | while (1) { |
| 1084 | if (returnToMenu) break; // Stops the loop to get back to Main menu |
| 1085 | |
| 1086 | JsonObject Version = versions[versionIndex]; |
| 1087 | const char *version = Version["version"]; |
| 1088 | const char *published_at = Version["published_at"]; |
| 1089 | const char *file = Version["file"]; |
| 1090 | bool spiffs = Version["s"].as<bool>(); |
| 1091 | bool fat = Version["f"].as<bool>(); |
| 1092 | bool fat2 = Version["f2"].as<bool>(); |
| 1093 | bool nb = Version["nb"].as<bool>(); |
| 1094 | uint32_t app_size = Version["as"].as<uint32_t>(); |
| 1095 | uint32_t app_offset = Version["ao"].as<uint32_t>(); |
| 1096 | uint32_t spiffs_size = Version["ss"].as<uint32_t>(); |
| 1097 | uint32_t spiffs_offset = Version["so"].as<uint32_t>(); |
| 1098 | uint32_t FAT_size[2] = { |
| 1099 | 0, |
| 1100 | 0, |
| 1101 | }; |
| 1102 | uint32_t FAT_offset[2] = { |
| 1103 | 0, |
| 1104 | 0, |
| 1105 | }; |
| 1106 | if (fat) { |
| 1107 | FAT_size[0] = Version["fs"].as<uint32_t>(); |
| 1108 | FAT_offset[0] = Version["fo"].as<uint32_t>(); |
| 1109 | } |
| 1110 | if (fat2) { |
| 1111 | FAT_size[1] = Version["fs2"].as<uint32_t>(); |
| 1112 | FAT_offset[1] = Version["fo2"].as<uint32_t>(); |
| 1113 | } |
| 1114 | if (redraw) { |
| 1115 | displayCurrentVersion( |
| 1116 | String(name), String(author), String(version), String(published_at), versionIndex, versions |
| 1117 | ); |
| 1118 | redraw = false; |
| 1119 | tft->display(false); |
| 1120 | } |
| 1121 | /* DW Btn to next item */ |
| 1122 | if (check(NextPress)) { |
| 1123 | versionIndex++; |
| 1124 | if (versionIndex > versions.size() - 1) versionIndex = 0; |
| 1125 | redraw = true; |
| 1126 | } |
| 1127 | |
| 1128 | /* UP Btn go back to FW menu and ´<´ go to previous version item */ |
no test coverage detected