mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-08-18 10:22:31 +02:00
Fix crash with reboot
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
|
||||||
|
static inline int64_t gwMonotonicUs(){
|
||||||
|
TickType_t ticks=xTaskGetTickCount();
|
||||||
|
return ((int64_t)ticks) * ((int64_t)portTICK_PERIOD_MS) * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
class TimeAverage{
|
class TimeAverage{
|
||||||
double factor=0.3;
|
double factor=0.3;
|
||||||
double current=0;
|
double current=0;
|
||||||
@@ -70,7 +78,7 @@ class TimeMonitor{
|
|||||||
}
|
}
|
||||||
void reset(){
|
void reset(){
|
||||||
if (last != 0 && start != 0) loop->add(last-start);
|
if (last != 0 && start != 0) loop->add(last-start);
|
||||||
start=esp_timer_get_time();
|
start=gwMonotonicUs();
|
||||||
for (size_t i=0;i<len;i++) current[i]=0;
|
for (size_t i=0;i<len;i++) current[i]=0;
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
@@ -114,7 +122,7 @@ class TimeMonitor{
|
|||||||
for (size_t i=0;i<index;i++){
|
for (size_t i=0;i<index;i++){
|
||||||
if (current[i] != 0) sv=current[i];
|
if (current[i] != 0) sv=current[i];
|
||||||
}
|
}
|
||||||
int64_t now=esp_timer_get_time();
|
int64_t now=gwMonotonicUs();
|
||||||
last=now;
|
last=now;
|
||||||
current[index]=now;
|
current[index]=now;
|
||||||
int64_t currentv=now-sv;
|
int64_t currentv=now-sv;
|
||||||
|
|||||||
+1
-1
@@ -767,7 +767,7 @@ void loopFunction(void *){
|
|||||||
//if(Serial1.available()) {}
|
//if(Serial1.available()) {}
|
||||||
//if(Serial.available()) {}
|
//if(Serial.available()) {}
|
||||||
//if(Serial2.available()) {}
|
//if(Serial2.available()) {}
|
||||||
//delay(1);
|
vTaskDelay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const String USERPREFIX="/api/user/";
|
const String USERPREFIX="/api/user/";
|
||||||
|
|||||||
Reference in New Issue
Block a user