Chapter 11 - RGB Lighting

The little extract below from w3schools offers a useful explanation about RGB...

RGB Colors
RGB color values are supported in all browsers.
An RGB color value is specified with: rgb( RED , GREEN , BLUE ).
Each parameter defines the intensity of the color as an integer between 0 and 255.

Example
Color RGB Color
  rgb(255,0,0) Red
  rgb(0,255,0) Green
  rgb(0,0,255) Blue


Note: The 3 individual RGB values can also be combined into a 24bit RGB colour value, as explained in the following w3schools extract...

Hexadecimal Colors
Hexadecimal color values are also supported in all browsers.
A hexadecimal color is specified with: #RRGGBB.
RR (red), GG (green) and BB (blue) are hexadecimal integers between 00 and FF specifying the intensity of the color (ie: from 0 to 255).
For example, #0000FF is displayed as blue, because the blue component is set to its highest value (FF) and the others are set to 00.


In Annex, hex numbers are prefixed with &h (not #), so the example above would be &h0000FF
Hex numbers have their corresponding decimal equivalent and vice versa, so &hFF in Annex is equivalent to 255.

Two Annex RGB instructions that can be used for RGB LED lighting are...
  SonoffB1.rgb  R, G, B
  Neo.Pixel  led_pos,  R, G, B

Both those instructions can optionally accept a single 24bit combined colour value instead of the 3 individual 8bit R,G,B values.
Annex offers a convenient function which can take the three R,G,B values and combines them into a 24bit value...
   Neo.RGB( R, G, B )     "'returns the 3 supplied R,G,B colours merged into a single 24bit RGB color value, useful for the NEO.PIXEL function and web page colors etc"

Although prefixed "NEO" it's actually a numeric function that can be used to combine any 3 individual 8bit numbers into a single 24bit number.


So that gives us enough info to make Annex really shine...