From 9b58eb29a26f5c38d703a9819452fa843fa69fec Mon Sep 17 00:00:00 2001 From: Asbelos Date: Fri, 24 Jul 2020 13:46:23 +0100 Subject: [PATCH] Low memory watermark freememory was returning wrong values --- CVReader.ino | 19 +++++++------------ freeMemory.h | 2 -- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CVReader.ino b/CVReader.ino index 9c378ec..1251286 100644 --- a/CVReader.ino +++ b/CVReader.ino @@ -71,14 +71,7 @@ DCCEXParser serialParser; // Try monitoring the memory #include "freeMemory.h" -// TODO: this should be automated instead of ifdef -#if defined(ARDUINO_AVR_MEGA2560) -int minMemory=32767; -#elif defined(ARDUINO_AVR_UNO) -int minMemory=2048; -#else -#error CANNOT COMPILE - Unkown board, can not determine amount of RAM available. -#endif +int ramLowWatermark=32767; // This figure gets overwritten dynamically in loop() void setup() { @@ -130,10 +123,12 @@ void loop() { WifiInterface::loop(Serial1); #endif - // Your additional code e.g. Report any decrease in memory + // Your additional code + + // OPtionally report any decrease in memory (will automatically trigger on first call) int freeNow=freeMemory(); - if (freeNow(sbrk(0)); -#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151) - return &top - __brkval; #else // __arm__ return __brkval ? &top - __brkval : &top - __malloc_heap_start; #endif // __arm__