MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / pushCustomApp

Function pushCustomApp

src/DisplayManager.cpp:283–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void pushCustomApp(String name, int position)
284{
285 if (customApps.count(name) == 0)
286 {
287 int availableCallbackIndex = -1;
288
289 for (int i = 0; i < 20; ++i)
290 {
291 bool callbackUsed = false;
292
293 for (const auto &appPair : Apps)
294 {
295 if (appPair.second == customAppCallbacks[i])
296 {
297 callbackUsed = true;
298 break;
299 }
300 }
301
302 if (!callbackUsed)
303 {
304 availableCallbackIndex = i;
305 break;
306 }
307 }
308
309 if (availableCallbackIndex == -1)
310 {
311 if (DEBUG_MODE)
312 DEBUG_PRINTLN(F("Error adding custom app -> Maximum number of custom apps reached"));
313 return;
314 }
315
316 if (position < 0) // Insert at the end of the vector
317 {
318 Apps.push_back(std::make_pair(name, customAppCallbacks[availableCallbackIndex]));
319 }
320 else if (position < Apps.size()) // Insert at a specific position
321 {
322 Apps.insert(Apps.begin() + position, std::make_pair(name, customAppCallbacks[availableCallbackIndex]));
323 }
324 else // Invalid position, Insert at the end of the vector
325 {
326 Apps.push_back(std::make_pair(name, customAppCallbacks[availableCallbackIndex]));
327 }
328
329 ui->setApps(Apps); // Add Apps
330 DisplayManager.getInstance().setAutoTransition(true);
331 }
332}
333
334bool deleteCustomAppFile(const String &name)
335{

Callers 1

generateCustomPageMethod · 0.85

Calls 3

setAppsMethod · 0.80
setAutoTransitionMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected