1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Harald Barth
923b031d06 Gittag 2024-08-07 21:14:07 +02:00
Harald Barth
7e29011d63 looptimer test 1 2024-08-07 21:13:44 +02:00
2 changed files with 30 additions and 1 deletions

View File

@ -141,44 +141,73 @@ void setup()
CommandDistributor::broadcastPower(); CommandDistributor::broadcastPower();
} }
void looptimer(unsigned long timeout, const FSH* message)
{
static unsigned long lasttimestamp = 0;
unsigned long now = micros();
if (timeout != 0) {
unsigned long diff = now - lasttimestamp;
if (diff > timeout) {
DIAG(message);
DIAG(F("DeltaT=%L"), diff);
lasttimestamp = micros();
return;
}
}
lasttimestamp = now;
}
void loop() void loop()
{ {
// The main sketch has responsibilities during loop() // The main sketch has responsibilities during loop()
// Responsibility 1: Handle DCC background processes // Responsibility 1: Handle DCC background processes
// (loco reminders and power checks) // (loco reminders and power checks)
looptimer(0, F(""));
DCC::loop(); DCC::loop();
looptimer(5000, F("DCC")); // got warnings up to 3884 during prog track read
// Responsibility 2: handle any incoming commands on USB connection // Responsibility 2: handle any incoming commands on USB connection
SerialManager::loop(); SerialManager::loop();
looptimer(2000, F("Serial")); // got warnings up to 1900 during start
// Responsibility 3: Optionally handle any incoming WiFi traffic // Responsibility 3: Optionally handle any incoming WiFi traffic
#ifndef ARDUINO_ARCH_ESP32 #ifndef ARDUINO_ARCH_ESP32
#if WIFI_ON #if WIFI_ON
WifiInterface::loop(); WifiInterface::loop();
looptimer(9000, F("Wifi")); // got warnings up to 8000
#endif //WIFI_ON #endif //WIFI_ON
#else //ARDUINO_ARCH_ESP32 #else //ARDUINO_ARCH_ESP32
#ifndef WIFI_TASK_ON_CORE0 #ifndef WIFI_TASK_ON_CORE0
WifiESP::loop(); WifiESP::loop();
looptimer(1000, F("WifiESP"));
#endif #endif
#endif //ARDUINO_ARCH_ESP32 #endif //ARDUINO_ARCH_ESP32
#if ETHERNET_ON #if ETHERNET_ON
EthernetInterface::loop(); EthernetInterface::loop();
looptimer(10000, F("Ethernet"));
#endif #endif
RMFT::loop(); // ignored if no automation RMFT::loop(); // ignored if no automation
looptimer(1000, F("RMFT"));
#if defined(LCN_SERIAL) #if defined(LCN_SERIAL)
LCN::loop(); LCN::loop();
looptimer(1000, F("LCN"));
#endif #endif
// Display refresh // Display refresh
DisplayInterface::loop(); DisplayInterface::loop();
looptimer(2000, F("Display")); // got warnings around 1150
// Handle/update IO devices. // Handle/update IO devices.
IODevice::loop(); IODevice::loop();
looptimer(1000, F("IODevice"));
Sensor::checkAll(); // Update and print changes Sensor::checkAll(); // Update and print changes
looptimer(1000, F("Sensor"));
// Report any decrease in memory (will automatically trigger on first call) // Report any decrease in memory (will automatically trigger on first call)
static int ramLowWatermark = __INT_MAX__; // replaced on first loop static int ramLowWatermark = __INT_MAX__; // replaced on first loop

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-202406182019Z" #define GITHUB_SHA "devel-fozzie-202408071912Z"