AGirs
GirsUtils.cpp
Go to the documentation of this file.
1 #include "GirsUtils.h"
2 
3 //#ifdef FREEMEM
4 // Ref: http://playground.arduino.cc/Code/AvailableMemory#.U0EnzKogTzs
5 unsigned long GirsUtils::freeRam () {
6 #if ARDUINO
7  extern int __heap_start, *__brkval;
8  int v;
9  return (unsigned long) &v - (__brkval == 0 ? (unsigned long) &__heap_start : (unsigned long) __brkval);
10 #else
11  return 99999999999L;
12 #endif
13 };
14 //#endif
15 
16 //#ifdef RESET
17 // TODO: This is somewhat suspect. Use at your own risk.
18 // Works at least on atmega386 and atmega2560,
19 
20 // Restarts program from beginning but does not reset the peripherals and registers
22 #ifdef ARDUINO
23 #if defined(ARDUINO_AVR_LEONARDO) | defined(ARDUINO_AVR_MICRO) | defined(ARDUINO_ARCH_SAMD)
24 #warning RESET not working on this platform, generating empty function
25 #else
26  asm volatile(" jmp 0");
27 #endif
28 #else
29  std::cout << "Resetting, but not really :-)" << std::endl;
30 #endif
31 }
32 
33 #ifdef ARDUINO
34 String GirsUtils::ip2string(IPAddress ip) {
35  String result;
36  for (int i = 0; i < 4; i++) {
37  result.concat(String(ip[i], DEC));
38  if (i < 3)
39  result.concat(".");
40  }
41  return result;
42 }
43 #endif
static String ip2string(IPAddress ip)
Definition: GirsUtils.cpp:34
static void reset()
Definition: GirsUtils.cpp:21
static unsigned long freeRam()
Definition: GirsUtils.cpp:5