Full final version (non table version)

HSV color space
Please read some documents on the web about the HSV color space to properly
understand how it works

Here's a small explanation of HSV:
 - Hue is an angle from 0 to 378 degrees where color components are 
   placed 120 degrees apart (red=0, green=120 and blue=240)
 - Saturation is a value between 0 and 100. It represents the distance from
   the center of the cone to the outside surface.
   It works like an additive constant to the RGB triplet.
 - Value is the luminance or B/W intensity. It works like a multiplicative
   constant to the RGB triplet.


Hue can be represented as these graphics
(conversion from Hue to RGB assuming saturation and value at maximum)

 |red
 |--------                               --------
 |        \                             /
 |         \                           /
 |          \                         /
 |            \                     /
 |             \                   /
 |              \_________________/
 --------+-------+-------+-------+-------+-------+-
        60     120     180     240     300     360 

 |green
 |       ----------------
 |      /                \
 |     /                  \
 |    /                    \
 |  /                        \
 | /                          \
 |/                            \__________________
 --------+-------+-------+-------+-------+-------+-
        60     120     180     240     300     360 

 |blue
 |                        ----------------
 |                       /                \
 |                      /                  \
 |                     /                    \
 |                   /                        \
 |                  /                          \
 |_________________/                            \
 --------+-------+-------+-------+-------+-------+-
        60     120     180     240     300     360 


---- Keys ----------------------------------------------------------
--------------------------------------------------------------------
key 1-9  preselected colors along the 360 of Hue
key 0    starts rotating colors (10 seconds per color)

ch+      manual advance color (H)
ch-      manual recede color (H)

VOL+     increase saturation (S)
VOL-     decrease saturation (S)

TV/VCR   increase value (V)
MUTE     decrease value (V)

POWER    Fades-out and fades-in brightness like power off/on (V)

---- Startup and features ------------------------------------------
--------------------------------------------------------------------
The circuit starts Off.
The first color to light is YELLOW, auto-rotating mode is active, saturation is
at 12.5% and brightness at maximum.

To enable auto-rotating mode you must press key 0 and it will keep changing
colors (hue only) at every second and will take aproximatly 5 minutes to run the
full spectrum which has 378 hue values.

A special note: Once the circuit is in rotating mode (key 0 pressed), changes to
saturation and value will keep the circuit in auto-rotation mode. Any other key
will stop auto-rotation mode and stay at the selected color.

Power button doesn't change the rotate mode.

This version uses a function to calculate the hue curves with 360 points prior
to adjust saturation and value. It does not use any kind of table like the
previous version. The result is smoother transitions between colors.

pin 7 (GPIO0) may be used to know if the circuit is On or Off.

---- Hex files -----------------------------------------------------
--------------------------------------------------------------------
There are two hex files:

 - powerpicrgb-sirc.hex file runs on any Power Pic RGB board.
                        It has the PWM active at 1 to drive the mosfets.
                        If the board doesn't have an infrared receiver, it will
                        run always in rotating mode.

 - picrgb-sirc.hex file runs in the Pic RGB (smd) board.
                        It has the PWM active at 0 to drive the common anode
                        LED directly.
                        It will probably run always in rotating mode unless someone
                        adds an infrared receiver.

Both files are compiled for pic 12F675 using the Hitech picc compiler.

It is easy to compile to another pic like the 12F629, just remove the ANSEL line
in the InitPic function and recompile. That should be enough.

2009/10 Joao Figueiredo
