LivingColors Class Reference

Class for interfacing with Philips LivingColors lamp. More...

#include <LivingColors.h>

Collaboration diagram for LivingColors:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 LivingColors (unsigned char pinCS=10, unsigned char pinSCK=13, unsigned char pinMOSI=11, unsigned char pinMISO=12)
 ~LivingColors ()
void init ()
unsigned char getMaxNumLamps ()
unsigned char getNumLamps ()
char addLamp (unsigned char *address)
bool getLamp (unsigned char index, unsigned char *address)
void learnLamps ()
void clearLamps ()
void setLampColourRGB (unsigned char index, unsigned char r, unsigned char g, unsigned char b)
void setLampColourHSV (unsigned char index, unsigned char h, unsigned char s, unsigned char v)
void turnLampOnRGB (unsigned char index, unsigned char r, unsigned char g, unsigned char b)
void turnLampOnHSV (unsigned char index, unsigned char h, unsigned char s, unsigned char v)
void turnLampOff (unsigned char index)

Protected Attributes

CC2500 m_cc2500
unsigned char m_sequence
unsigned char m_lamps [MAXLAMPS][10]
unsigned char m_maxNumLamps
unsigned char m_numLamps

Private Member Functions

void checkAddress (unsigned char *address)
void sendCommand (unsigned char index, unsigned char command, unsigned char h, unsigned char s, unsigned char v)
 LivingColors (const LivingColors &that)
LivingColorsoperator= (const LivingColors &that)


Detailed Description

Class for interfacing with Philips LivingColors lamp.

This class implements basic functions to communicate with the LivingColors lamp.


Constructor & Destructor Documentation

LivingColors::LivingColors ( unsigned char  pinCS = 10,
unsigned char  pinSCK = 13,
unsigned char  pinMOSI = 11,
unsigned char  pinMISO = 12 
)

Constructor.

Parameters:
[in] pinCS Pin number of slave select, default is 10.
[in] pinSCK Pin number of clock, default is 13 (Arduino standard).
[in] pinMOSI Pin number of master output slave input, default is 11 (Arduino standard).
[in] pinMISO Pin number of master input slave output, default is 12 (Arduino standard).

LivingColors::~LivingColors (  ) 

Destructor.

LivingColors::LivingColors ( const LivingColors that  )  [private]

Copy constructor, disabled.


Member Function Documentation

void LivingColors::init (  ) 

Initializes communication with the LivingColors lamp.

Here is the call graph for this function:

unsigned char LivingColors::getMaxNumLamps (  ) 

Returns the maximum number of storable lamps.

Returns:
Maximum number of lamps.

unsigned char LivingColors::getNumLamps (  ) 

Returns the number of currently known lamps.

Returns:
Number of known adresses.

char LivingColors::addLamp ( unsigned char *  address  ) 

Adds a lamp address to storage. Address must be 9 bytes long.

Parameters:
[in] address Array holding lamp address.
Returns:
Lamp index for address or -1 on failure.

bool LivingColors::getLamp ( unsigned char  index,
unsigned char *  address 
)

Saves the address of lamp with given index in supplied array. Only fills array when index and address are valid.

Parameters:
[in] index Lamp index, must be 0 <= index < getNumLamps().
[in] address Array for lamp address, must be at least 9 bytes long.
Returns:
True if array is filled with valid address, false otherwise.

void LivingColors::learnLamps (  ) 

Tries to learn lamp addresses by snooping the commands which are sent by the official remote. The learning time period is about 5 seconds; hold the official remote very close to the board and press some commands (e.g. change colour, off, on).

Here is the call graph for this function:

void LivingColors::clearLamps (  ) 

Clears all lamp addresses.

Here is the caller graph for this function:

void LivingColors::setLampColourRGB ( unsigned char  index,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Sets colour of lamp with given index. Updates colour only if lamp address is valid.

Parameters:
[in] index Lamp index, must be 0 <= index < getNumLamps().
[in] r Red value for lamp (0-255).
[in] g Green value for lamp (0-255).
[in] b Blue value for lamp (0-255).

Here is the call graph for this function:

void LivingColors::setLampColourHSV ( unsigned char  index,
unsigned char  h,
unsigned char  s,
unsigned char  v 
)

Sets colour of lamp with given index. Updates colour only if lamp address is valid.

Parameters:
[in] index Lamp index, must be 0 <= index < getNumLamps().
[in] h Hue value for lamp (0-255).
[in] s Saturation value for lamp (0-255).
[in] v Value value for lamp (0-255).

Here is the call graph for this function:

void LivingColors::turnLampOnRGB ( unsigned char  index,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Turns lamp with given index on and sets colour if lamp address is valid.

Parameters:
[in] index Lamp index, must be 0 <= index < getNumLamps().
[in] r Red value for lamp (0-255).
[in] g Green value for lamp (0-255).
[in] b Blue value for lamp (0-255).

Here is the call graph for this function:

void LivingColors::turnLampOnHSV ( unsigned char  index,
unsigned char  h,
unsigned char  s,
unsigned char  v 
)

Turns lamp with given index on and sets colour if lamp address is valid.

Parameters:
[in] index Lamp index, must be 0 <= index < getNumLamps().
[in] h Hue value for lamp (0-255).
[in] s Saturation value for lamp (0-255).
[in] v Value value for lamp (0-255).

Here is the call graph for this function:

void LivingColors::turnLampOff ( unsigned char  index  ) 

Turns lamp with given index off if lamp address is valid.

Parameters:
[in] index Lamp index, must be 0 <= index < getNumLamps();

Here is the call graph for this function:

void LivingColors::checkAddress ( unsigned char *  address  )  [private]

Checks if lamp address is already known, stores address if not known.

Parameters:
[in] address Lamp address to check, length must be at least 10 bytes.

Here is the caller graph for this function:

void LivingColors::sendCommand ( unsigned char  index,
unsigned char  command,
unsigned char  h,
unsigned char  s,
unsigned char  v 
) [private]

Sends command to lamp. Command can be on, off or set colour.

Parameters:
[in] index Lamp index, must be 0 <= index < getNumLamps().
[in] command Command to send (3 = set colour, 5 = on, 7 = off).
[in] h Hue value to sent (0-255), must be corrected for LivingColors.
[in] s Saturation value to sent (0-255).
[in] v Value to sent (0-255).

Here is the call graph for this function:

Here is the caller graph for this function:

LivingColors& LivingColors::operator= ( const LivingColors that  )  [private]

Assignment operator, disabled.


Member Data Documentation

CC2500 object to communicate with the LivingColors lamp.

unsigned char LivingColors::m_sequence [protected]

Sequence number which is used during communication with the LivingColors lamp. The sent sequence number must match the received sequence number.

unsigned char LivingColors::m_lamps[MAXLAMPS][10] [protected]

Address storage for lamps. The first byte indicates a valid address (0x01), the next 9 bytes are the lamp address.

A lamp address consists of a unique lamp identifier (first 4 bytes) and a unique remote identifier (last 5 bytes).

unsigned char LivingColors::m_maxNumLamps [protected]

Maximum number of lamps that can be controlled.

unsigned char LivingColors::m_numLamps [protected]

Number of stored lamp addresses.


The documentation for this class was generated from the following files:

Generated on Thu Feb 19 21:59:54 2009 for LivingColors by  doxygen 1.5.5