Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

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

0 notes on commit ad39293

Please sign in to comment.
Something went wrong with that request. Please try again.