Click here to Skip to main content
15,883,531 members
Articles / Internet of Things / Arduino

Simulating and controlling GE Color Effects Lights with Arduino

Rate me:
Please Sign up or sign in to vote.
4.80/5 (13 votes)
27 Nov 2012CPOL13 min read 137K   1.4K   25  
Simulating and Controlling GE Color Effects Lights with Arduino
// Errors are 4.x

#include "global.h"

#if defined(PC) || defined(RASPBERRY)
#else
	#if defined(ARDUINO) && ARDUINO >= 100
	#else

		#define TRACEMEMORY 1

		// need to provide my own new
		void * operator new(size_t size)
		{
			#ifdef TRACEMEMORY
			_platform->WriteMessage("About to allocate %d bytes.", size);
			#endif

			// allocate the memory
			void* p = malloc(size);

			// if it did not work
			if (p == NULL)
			{
				// report an error
				_platform->Error(4);
			}

			// initialise the memory
			memset(p, 0, size);

			#ifdef TRACEMEMORY
			_platform->WriteMessage("Allocating %d bytes at address %xd.", size, p);
			#endif

			// return the memory
			return p;
		}


		// need to provide my own delete
		void operator delete(void * ptr)
		{
			// release the memory
			if (ptr != NULL)
			{
				free(ptr);

				#ifdef TRACEMEMORY
				_platform->WriteMessage("Releasing memory at address %xd.", ptr);
				#endif
			}
		}
	#endif
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions