Click here to Skip to main content
15,885,546 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 137.1K   1.4K   25  
Simulating and Controlling GE Color Effects Lights with Arduino
#ifndef _GECOLOREFFECTSBULB_H

#define _GECOLOREFFECTSBULB_H

class NonDisplayableBulb
{
	protected:
		short _colour; // the bulbs colour
		byte _brightness; // the bulbs brightness

	public:
		#if defined(PC) || defined(RASPBERRY)
			NonDisplayableBulb() {};
		#endif
		void Construct(short colour, byte brightness);
		byte Brightness();
		void SetBrightness(byte brightness);
		short Colour();
		void SetColour(short colourrgb);
		void SetChanged();
		void ClearChanged();
		bool IsChanged();
		static byte Red(short colour);
		static byte Green(short colour);
		static byte Blue(short colour);
};

// A bulb
class Bulb : public NonDisplayableBulb
{
	private:
		byte _string; // output pin for this bulb
		byte _address; // the bulbs address

		static byte GetBit(short i);
		static byte GetBit2(byte i);
		void PopulateOneBulbBits();
		static void PopulateMultiBulbBits(Bulb* bulbs[]);
		static byte GetParallelBit(short bit, byte one);

	public:
		#if defined(PC) || defined(RASPBERRY)
			Bulb() {};
		#endif
		byte Address() { return _address; }
		void Construct(byte string, byte address, short colour, byte brightness);
		void Display();
		static void DisplayParallel(Bulb* bulbs[]);
		static byte RandomBrightness();
		static short RandomColour();
		static byte RandomBulb(byte bulbs);
		byte String() { return _string; }
};

#endif // _GECOLOREFFECTSBULB_H

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