| 1071 | } |
| 1072 | |
| 1073 | void DisplayManager_::loadNativeApps() |
| 1074 | { |
| 1075 | // Define a helper function to check and update an app |
| 1076 | auto updateApp = [&](const String &name, AppCallback callback, bool show, size_t position) |
| 1077 | { |
| 1078 | auto it = std::find_if(Apps.begin(), Apps.end(), [&](const std::pair<String, AppCallback> &app) |
| 1079 | { return app.first == name; }); |
| 1080 | if (it != Apps.end()) |
| 1081 | { |
| 1082 | if (!show) |
| 1083 | { |
| 1084 | Apps.erase(it); |
| 1085 | } |
| 1086 | } |
| 1087 | else |
| 1088 | { |
| 1089 | if (show) |
| 1090 | { |
| 1091 | if (position >= Apps.size()) |
| 1092 | { |
| 1093 | Apps.push_back(std::make_pair(name, callback)); |
| 1094 | } |
| 1095 | else |
| 1096 | { |
| 1097 | Apps.insert(Apps.begin() + position, std::make_pair(name, callback)); |
| 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | }; |
| 1102 | |
| 1103 | updateApp("Time", TimeApp, SHOW_TIME, 0); |
| 1104 | updateApp("Date", DateApp, SHOW_DATE, 1); |
| 1105 | |
| 1106 | if (SENSOR_READING) |
| 1107 | { |
| 1108 | updateApp("Temperature", TempApp, SHOW_TEMP, 2); |
| 1109 | updateApp("Humidity", HumApp, SHOW_HUM, 3); |
| 1110 | } |
| 1111 | #ifdef ULANZI |
| 1112 | updateApp("Battery", BatApp, SHOW_BAT, 4); |
| 1113 | #endif |
| 1114 | |
| 1115 | ui->setApps(Apps); |
| 1116 | setAutoTransition(true); |
| 1117 | } |
| 1118 | |
| 1119 | void DisplayManager_::setup() |
| 1120 | { |
no test coverage detected