}
}
+
#ifdef DEBUG
void serial_debug()
{
Serial.print("Average loop time:");
Serial.println(avg_loop_time);
+ Serial.print("Free RAM:");
+ Serial.print( FreeRam() );
Serial.println();
}
#endif
return;
}
+#ifdef DEBUG
+/* The following code is taken from the
+ Arduino FAT16 Library by William Greiman
+ The code may or may-not survive in the long run,
+ depending on what licensing-terms we decide on.
+ The license will be open source, but the FAT16lib
+ is GPL v3, and I (fishy) am personally not so sure about that...
+
+ On the other hand... This code is a very "intuitive approach",
+ so contacting the author may give us the option of relicencing just this bit...
+*/
+static int FreeRam(void) {
+ extern int __bss_end;
+ extern int* __brkval;
+ int free_memory;
+ if (reinterpret_cast<int>(__brkval) == 0) {
+ // if no heap use from end of bss section
+ free_memory = reinterpret_cast<int>(&free_memory)
+ - reinterpret_cast<int>(&__bss_end);
+ } else {
+ // use from top of stack to heap
+ free_memory = reinterpret_cast<int>(&free_memory)
+ - reinterpret_cast<int>(__brkval);
+ }
+ return free_memory;
+}
+#endif