MCPcopy Create free account
hub / github.com/SlimeVR/SlimeVR-Tracker-ESP / loop

Function loop

src/main.cpp:155–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155void loop() {
156 tpsCounter.update();
157 globalTimer.tick();
158 SerialCommands::update();
159 OTA::otaUpdate();
160 networkManager.update();
161
162#if DEBUG_MEASURE_SENSOR_TIME_TAKEN
163 sensorMeasurer.before();
164#endif
165 sensorManager.update();
166#if DEBUG_MEASURE_SENSOR_TIME_TAKEN
167 sensorMeasurer.after();
168#endif
169
170 battery.Loop();
171 ledManager.update();
172 I2CSCAN::update();
173#ifdef TARGET_LOOPTIME_MICROS
174 long elapsed = (micros() - loopTime);
175 if (elapsed < TARGET_LOOPTIME_MICROS) {
176 long sleepus = TARGET_LOOPTIME_MICROS - elapsed - 100; // µs to sleep
177 long sleepms = sleepus / 1000; // ms to sleep
178 if (sleepms > 0) // if >= 1 ms
179 {
180 delay(sleepms); // sleep ms = save power
181 sleepus -= sleepms * 1000;
182 }
183 if (sleepus > 100) {
184 delayMicroseconds(sleepus);
185 }
186 }
187 loopTime = micros();
188#endif
189#if defined(PRINT_STATE_EVERY_MS) && PRINT_STATE_EVERY_MS > 0
190 unsigned long now = millis();
191 if (lastStatePrint + PRINT_STATE_EVERY_MS < now) {
192 lastStatePrint = now;
193 SerialCommands::printState();
194 }
195#endif
196}

Callers

nothing calls this directly

Calls 7

printStateFunction · 0.85
beforeMethod · 0.80
afterMethod · 0.80
LoopMethod · 0.80
updateFunction · 0.50
updateMethod · 0.45
tickMethod · 0.45

Tested by

no test coverage detected