|
|
(5 intermediate revisions by the same user not shown) |
Line 17: |
Line 17: |
| ==Component Source Code== | | ==Component Source Code== |
| | | |
− | Please click here to download the component source project: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_RGB_LED.fcfx FC_Comp_Source_RGB_LED.fcfx] | + | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_RGB_LED.fcfx FC_Comp_Source_RGB_LED.fcfx] |
| | | |
| Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_RGB_LED.fcfx FC_Comp_Source_RGB_LED.fcfx] | | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_RGB_LED.fcfx FC_Comp_Source_RGB_LED.fcfx] |
| | | |
| ==Detailed description== | | ==Detailed description== |
| + | |
| + | |
| + | |
| + | |
| | | |
| | | |
Line 46: |
Line 50: |
| | | |
| ==Examples== | | ==Examples== |
| + | |
| + | |
| + | |
| + | |
| | | |
| | | |
Line 114: |
Line 122: |
| Each LED colour channel can be set from 0 (minimum) to the rollover value - 1 (maximum). Therefore with a colour channel bit size of 8 there are theoretically 16777216 colours available 2^(8*3). With a colour bit size of 4 the available number of colours that can be generated drops to 4096, 2^(4*3). | | Each LED colour channel can be set from 0 (minimum) to the rollover value - 1 (maximum). Therefore with a colour channel bit size of 8 there are theoretically 16777216 colours available 2^(8*3). With a colour bit size of 4 the available number of colours that can be generated drops to 4096, 2^(4*3). |
| | | |
− | ==Macro reference==
| |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Disable'''
| |
− | |-
| |
− | | colspan="2" | Disables the RGB LED. It will no longer respond to color changes.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Enable'''
| |
− | |-
| |
− | | colspan="2" | Enables the RGB LED. This must be done before the LED can be lit or the color changed.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Tick'''
| |
− | |-
| |
− | | colspan="2" | Call this macro at regular intervals to illuminate the LED with the chosen color. Turns each pin on and off to generate a simple PWM signal for each color - when done rapidly, this gives the illusion of the chosen color.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetColor'''
| |
− | |-
| |
− | | colspan="2" | Set the target color for the LED. Each of the Red, Blue and Green channels can be set to any value from 0 (off) to 255 (full brightness).
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | red
| |
− | |-
| |
− | | colspan="2" | Red component of RGB LED local to this macro
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | green
| |
− | |-
| |
− | | colspan="2" | Green component of RGB LED local to this macro
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | blue
| |
− | |-
| |
− | | colspan="2" | Blue component of RGB LED local to this macro
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
| | | |
| + | ==Macro reference== |
| | | |
− | ==Property reference== | + | ===Disable=== |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Pin Connections
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | Red
| |
− | |-
| |
− | | colspan="2" | Pin that the red LED is connected to.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | Green
| |
− | |-
| |
− | | colspan="2" | Pin that the green LED is connected to.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | Blue
| |
− | |-
| |
− | | colspan="2" | Pin tha the Blue pin is connected to.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Misc
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Polarity
| |
− | |-
| |
− | | colspan="2" | Active High: Use for common cathode LEDs - Pin true = LED On. Active Low: Use for common anode LEDs - Pin false = LED On.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Color bit size
| |
− | |-
| |
− | | colspan="2" | Color bit depth. Sets the resolution of the virtual PWM signals driving the LEDs. Lower values mean that the 'Tick' macro can be called less often, but reduced the number of colours that can be created.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
| |
− | | width="90%" | Rollover value
| |
− | |-
| |
− | | colspan="2" | The number of unique colours each R/G/B channel can output. Range: 0 to (Rollover Value - 1).
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-17-icon.png]]
| |
− | | width="90%" | Target
| |
− | |-
| |
− | | colspan="2" | Create custom LED shapes by pointing this property at any object on your panel. This also works with groups of objects - all children of the group will change color.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Shape
| |
− | |-
| |
− | | colspan="2" | Choose a simple shape for the LED when there is no 'Target' selected.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Width
| |
− | |-
| |
− | | colspan="2" | Width of the LED shape.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Height
| |
− | |-
| |
− | | colspan="2" | Height of the LED shape.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Depth
| |
− | |-
| |
− | | colspan="2" | Depth of the LED shape.
| |
− | |}==Macro reference==
| |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 274: |
Line 148: |
| | | |
| | | |
| + | ===Enable=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 287: |
Line 162: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===SetColor=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Tick'''
| |
− | |-
| |
− | | colspan="2" | Call this macro at regular intervals to illuminate the LED with the chosen color. Turns each pin on and off to generate a simple PWM signal for each color - when done rapidly, this gives the illusion of the chosen color.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 328: |
Line 191: |
| | | |
| | | |
− | | + | ===Tick=== |
− | | |
− | ==Property reference== | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Pin Connections
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | Red
| |
− | |-
| |
− | | colspan="2" | Pin that the red LED is connected to.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | Green
| |
− | |-
| |
− | | colspan="2" | Pin that the green LED is connected to.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | Blue
| |
− | |-
| |
− | | colspan="2" | Pin tha the Blue pin is connected to.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Misc
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Polarity
| |
− | |-
| |
− | | colspan="2" | Active High: Use for common cathode LEDs - Pin true = LED On. Active Low: Use for common anode LEDs - Pin false = LED On.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Color bit size
| |
− | |-
| |
− | | colspan="2" | Color bit depth. Sets the resolution of the virtual PWM signals driving the LEDs. Lower values mean that the 'Tick' macro can be called less often, but reduced the number of colours that can be created.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
| |
− | | width="90%" | Rollover value
| |
− | |-
| |
− | | colspan="2" | The number of unique colours each R/G/B channel can output. Range: 0 to (Rollover Value - 1).
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-17-icon.png]]
| |
− | | width="90%" | Target
| |
− | |-
| |
− | | colspan="2" | Create custom LED shapes by pointing this property at any object on your panel. This also works with groups of objects - all children of the group will change color.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Shape
| |
− | |-
| |
− | | colspan="2" | Choose a simple shape for the LED when there is no 'Target' selected.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Width
| |
− | |-
| |
− | | colspan="2" | Width of the LED shape.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Height
| |
− | |-
| |
− | | colspan="2" | Height of the LED shape.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-15-icon.png]]
| |
− | | width="90%" | Depth
| |
− | |-
| |
− | | colspan="2" | Depth of the LED shape.
| |
− | |}==Macro reference==
| |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Disable'''
| |
− | |-
| |
− | | colspan="2" | Disables the RGB LED. It will no longer respond to color changes.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Enable'''
| |
− | |-
| |
− | | colspan="2" | Enables the RGB LED. This must be done before the LED can be lit or the color changed.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 443: |
Line 203: |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
− |
| |
− |
| |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetColor'''
| |
− | |-
| |
− | | colspan="2" | Set the target color for the LED. Each of the Red, Blue and Green channels can be set to any value from 0 (off) to 255 (full brightness).
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | red
| |
− | |-
| |
− | | colspan="2" | Red component of RGB LED local to this macro
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | green
| |
− | |-
| |
− | | colspan="2" | Green component of RGB LED local to this macro
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | blue
| |
− | |-
| |
− | | colspan="2" | Blue component of RGB LED local to this macro
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− |
| |
− |
| |
| | | |
| | | |
Author
|
Matrix Ltd
|
Version
|
1.3
|
Category
|
LED
|
LED (Generic, RGB) component
An LED with red, green and blue elements that can be mixed together to produce almost any colour at any brightness.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_RGB_LED.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_RGB_LED.fcfx
Detailed description
No detailed description exists yet for this component
Examples
Tricolour LEDs generally have four pins and come in both common anode and common cathode configurations and must be wired to suit. The RGBLED component has a property allowing you to configure which LED type your using.
An active high LED will light when the microcontroller pin is outputting a logic 1 and be off when the microcontroller pin is outputting a logic 0 or in input mode.
An active low LED will light when the microcontroller pin is outputting a logic 0 and be off when the microcontroller pin is outputting a logic 1 or in input mode.
Six pin tricolour LEDs can simply be treated as three individual standards LEDs.
The series resistor acts to protect each individual LED from damage due to excess current. The value of resistor used can be changed based on the brightness of the LED and power consumption. Usually the three colour LEDs have different characteristics from each other so a different protection resistor should be provided for each LED to balance the LEDs output.
This LED Calculator tool is a good resource for calculating the correct LED series protection resistor.
LED Resistor Calculator Tool
This example for the RGB LED uses three analogue sliders to set the output colour of the LED.
RGB LED Example
The LED Colour is output to the LED using the Timer interrupt which calls the RGB LED Tick function.
The RGB LED properties include a setting for "Colour Bit Size" which sets the period for the LED colour PWM. The "Rollover Value" property shows the number of interrupts required for each PWM period so the timer interrupt should be running fast enough to allow the LED to output several periods per second. Persistence of vision can normally no longer detect any flickering light above approx 24Hz.
For a constant none flickering LED you can work out the minimum interrupt frequency like this.
30Hz * Rollover Value = Minimum interrupt frequency
30Hz * 256 = 7680Hz
60Hz * 64 = 3840Hz
Each LED colour channel can be set from 0 (minimum) to the rollover value - 1 (maximum). Therefore with a colour channel bit size of 8 there are theoretically 16777216 colours available 2^(8*3). With a colour bit size of 4 the available number of colours that can be generated drops to 4096, 2^(4*3).
Macro reference
Disable
|
Disable
|
Disables the RGB LED. It will no longer respond to color changes.
|
- VOID
|
Return
|
Enable
|
Enable
|
Enables the RGB LED. This must be done before the LED can be lit or the color changed.
|
- VOID
|
Return
|
SetColor
|
SetColor
|
Set the target color for the LED. Each of the Red, Blue and Green channels can be set to any value from 0 (off) to 255 (full brightness).
|
- BYTE
|
red
|
Red component of RGB LED local to this macro
|
- BYTE
|
green
|
Green component of RGB LED local to this macro
|
- BYTE
|
blue
|
Blue component of RGB LED local to this macro
|
- VOID
|
Return
|
Tick
|
Tick
|
Call this macro at regular intervals to illuminate the LED with the chosen color. Turns each pin on and off to generate a simple PWM signal for each color - when done rapidly, this gives the illusion of the chosen color.
|
- VOID
|
Return
|
Property reference
|
Properties
|
|
Pin Connections
|
|
Red
|
Pin that the red LED is connected to.
|
|
Green
|
Pin that the green LED is connected to.
|
|
Blue
|
Pin tha the Blue pin is connected to.
|
|
Misc
|
|
Polarity
|
Active High: Use for common cathode LEDs - Pin true = LED On. Active Low: Use for common anode LEDs - Pin false = LED On.
|
|
Color bit size
|
Color bit depth. Sets the resolution of the virtual PWM signals driving the LEDs. Lower values mean that the 'Tick' macro can be called less often, but reduced the number of colours that can be created.
|
|
Rollover value
|
The number of unique colours each R/G/B channel can output. Range: 0 to (Rollover Value - 1).
|
|
Simulation
|
|
Target
|
Create custom LED shapes by pointing this property at any object on your panel. This also works with groups of objects - all children of the group will change color.
|
|
Shape
|
Choose a simple shape for the LED when there is no 'Target' selected.
|
|
Width
|
Width of the LED shape.
|
|
Height
|
Height of the LED shape.
|
|
Depth
|
Depth of the LED shape.
|