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 360 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 RED, auto-rotating mode is active,
saturation and brightness are at maximum.

To enable auto-rotating mode at any time you must press 0 on the 
remote control.
Auto-rotating mode will keep changing colors (hue only) at every 
second and takes aproximately 6 minutes to run the full spectrum 
which has 378 hue values.

To enable random mode press 0 again when in auto-rotating mode.
This will generate colors and fade between them using two effects:
  - "blow 255": old color->white->new color
  - "hue fast forward": old color ..... new color (as if someone is 
pressing PR+ or PR-)

A special note: Once the circuit is in auto-rotating mode or random mode
(key 0 pressed), changes to saturation and value will not affect the
circuit as it will remain in that mode. Any other key (PR+, PR-, 1..9) 
will stop auto-rotation or random modes and stay at the selected color.

Power button doesn't change the mode.

This version uses a function to calculate the hue curves with 378 points
prior to adjust saturation and value. It does not use any kind of table 
like the previous versions (V < 4.0). 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.
                        It will drive regular 5mm LEDs if they are connected from
                        the PIC pins to the ground (with a proper resistor).
                        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 12F683 using the Hitech picc compiler.

PICs 12F629 and 12F675 don't have enough flash memory to hold all this code.


2010/05 Joao Figueiredo
