Permalink
Browse files

Added freeRAM() for determining amount of available heap/stack space …

…remaining.
  • Loading branch information...
1 parent c35044c commit ad392935bb59655cf2084023c99a0069368433fa @geekscape committed May 25, 2012
View
@@ -1,5 +1,3 @@
-#include "Arduino.h"
-
#include "AikoCommands.h"
namespace Aiko {
@@ -10,3 +8,5 @@ namespace Aiko {
#include "aiko_commands/AikoCommandNode.cpp"
}
}
+
+#include "aiko_commands/FreeRAM.cpp"
View
@@ -16,4 +16,6 @@ namespace Aiko {
}
}
+#include "aiko_commands/FreeRAM.h"
+
#endif
@@ -1,8 +1,12 @@
+unsigned long secondCounter = 0;
+
byte second = 0;
byte minute = 0;
byte hour = 0;
void clockHandler(void) {
+ secondCounter ++;
+
if ((++ second) == 60) {
second = 0;
if ((++ minute) == 60) {
@@ -1,5 +1,7 @@
-#ifndef AikoDeviceClock_h
-#define AikoDeviceClock_h
+#ifndef AikoCommandClock_h
+#define AikoCommandClock_h
+
+extern unsigned long secondCounter;
extern byte second;
extern byte minute;
@@ -1,5 +1,5 @@
-#ifndef AikoNode_h
-#define AikoNode_h
+#ifndef AikoCommandNode_h
+#define AikoCommandNode_h
#ifndef DEFAULT_NODE_NAME
#define DEFAULT_NODE_NAME "aiko_node"
@@ -0,0 +1,7 @@
+// http://jeelabs.org/2011/05/22/atmega-memory-use
+
+int freeRAM(void) {
+ extern int __heap_start, *__brkval;
+ int v;
+ return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
+}
View
@@ -0,0 +1,6 @@
+#ifndef AikoCommandFreeRAM_h
+#define AikoCommandFreeRAM_h
+
+int freeRAM(void);
+
+#endif

0 comments on commit ad39293

Please sign in to comment.