@insmod what do you think? Should we merge it, and if so, at which stage?
Helpful post? Buy me a coffee.
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam
#if PLATFORM_W600 || PLATFORM_W800
#define TimeOut_t xTimeOutType
#endif
uint32_t getUptime(){
TimeOut_t myTimeout;
/*
// we use vTaskSetTimeOutState to get the number of xTicks (we could get them with xTaskGetTickCount(), too)
// but the number of overflows ("xNumOfOverflows") is private and hence not accessable else ...
void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )
{
configASSERT( pxTimeOut );
pxTimeOut->xOverflowCount = xNumOfOverflows;
pxTimeOut->xTimeOnEntering = xTickCount;
}
*/
vTaskSetTimeOutState( &myTimeout );
// for most platforms, ticks are ms, but we can't be sure (e.g. its not on W600/W800) so we use factor portTICK_RATE_MS to make sure we get ms
uint32_t my_secondsElapsed = (uint32_t)((((uint64_t) myTimeout.xOverflowCount << (sizeof(portTickType)*8) | myTimeout.xTimeOnEntering)*portTICK_RATE_MS ) / 1000 );
// this would set g_secondsElapsed
// g_secondsElapsed=my_secondsElapsed;
ADDLOG_DEBUG(LOG_FEATURE_RAW, "g_secondsElapsed=%i / my_secondsElapsed=%i (differs: %i)\r\n", g_secondsElapsed, my_secondsElapsed, (g_secondsElapsed - my_secondsElapsed));
return my_secondsElapsed;
}
diff --git a/src/user_main.c b/src/user_main.c
index a0ea6322..dbee5483 100644
--- a/src/user_main.c
+++ b/src/user_main.c
@@ -583,6 +583,11 @@ float g_wifi_temperature = 0;
static byte g_secondsSpentInLowMemoryWarning = 0;
void Main_OnEverySecond()
{
+#if PLATFORM_W600 || PLATFORM_W800
+#define TimeOut_t xTimeOutType
+#endif
+ TimeOut_t myTimeout; // to get uptime from xTicks
+
int newMQTTState;
const char* safe;
int i;
@@ -754,8 +759,9 @@ void Main_OnEverySecond()
}
}
}
-
- g_secondsElapsed++;
+// g_secondsElapsed++;
+ vTaskSetTimeOutState( &myTimeout );
+ g_secondsElapsed = (int)((((uint64_t) myTimeout.xOverflowCount << (sizeof(portTickType)*8) | myTimeout.xTimeOnEntering)*portTICK_RATE_MS ) / 1000 );
if (bSafeMode) {
safe = "[SAFE] ";
}
insmod wrote:For beken, did you try change edge directly in interrupt? E.g. gpio_int_enable to opposite edge.
p.kaczmarek2 wrote:The next step is "Counter" role from Tasmota. Should be very easy. Do anyone know how it works in TAS? Is it "on change", or "on rising", or "on falling"?
I guess we need :
- Counter_any
- Counter_h
- Counter_l ? or how should we name it?