Replace millis with esp timer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <ap_service.h>
|
||||
#include "esp_timer.h"
|
||||
#include <string>
|
||||
|
||||
static const char *TAG = "APService";
|
||||
@@ -37,14 +38,14 @@ APNetworkStatus APService::getAPNetworkStatus() {
|
||||
}
|
||||
|
||||
void APService::reconfigureAP() {
|
||||
_lastManaged = millis() - MANAGE_NETWORK_DELAY;
|
||||
_lastManaged = esp_timer_get_time() / 1000 - MANAGE_NETWORK_DELAY;
|
||||
_reconfigureAp = true;
|
||||
_recoveryMode = false;
|
||||
}
|
||||
|
||||
void APService::recoveryMode() {
|
||||
ESP_LOGI(TAG, "Recovery Mode needed");
|
||||
_lastManaged = millis() - MANAGE_NETWORK_DELAY;
|
||||
_lastManaged = esp_timer_get_time() / 1000 - MANAGE_NETWORK_DELAY;
|
||||
_recoveryMode = true;
|
||||
_reconfigureAp = true;
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ void MotionService::handleGestures(const gesture_t ges) {
|
||||
bool MotionService::update(Peripherals *peripherals) {
|
||||
handleGestures(peripherals->takeGesture());
|
||||
if (!state) return false;
|
||||
unsigned long now = millis();
|
||||
float dt = (now - lastUpdate) / 1000.0f;
|
||||
int64_t now = esp_timer_get_time();
|
||||
float dt = (now - lastUpdate) / 1000000.0f; // Convert microseconds to seconds
|
||||
lastUpdate = now;
|
||||
state->updateImuOffsets(peripherals->angleY(), peripherals->angleX());
|
||||
state->step(body_state, dt);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "system_service.h"
|
||||
#include "esp_timer.h"
|
||||
#include <string>
|
||||
|
||||
namespace system_service {
|
||||
@@ -108,11 +109,11 @@ void status(JsonObject &root) {
|
||||
root["fs_used"] = ESP_FS.usedBytes();
|
||||
root["core_temp"] = temperatureRead();
|
||||
root["cpu_reset_reason"] = resetReason(esp_reset_reason());
|
||||
root["uptime"] = millis() / 1000;
|
||||
root["uptime"] = esp_timer_get_time() / 1000000;
|
||||
}
|
||||
|
||||
void metrics(JsonObject &root) {
|
||||
root["uptime"] = millis() / 1000;
|
||||
root["uptime"] = esp_timer_get_time() / 1000000;
|
||||
root["free_heap"] = ESP.getFreeHeap();
|
||||
root["total_heap"] = ESP.getHeapSize();
|
||||
root["min_free_heap"] = ESP.getMinFreeHeap();
|
||||
|
||||
Reference in New Issue
Block a user