By default the heartbeat LED flashes in blue colour once every 4s to signal that the system is alive. This can be overridden through the F1 starter kit command.
initialization: the module will be initialized once it is imported. after its initialization, it could be deinitialized by calling rgbled.deinit() and to initialize it again use rgbled.initialize()
initialization
rgbled.deinit()
rgbled.initialize()
rgbled.color() to set the LED color continuously. The color follows this hex formatting xxRRGGBB, in which the RR, GG and BB are representint the red, green and blue components of the color respectively and xx is a don’t care value.
rgbled.color()
xxRRGGBB
RR
GG
BB
red
green
blue
xx
# rgbled.heartbeat() example: import rgbled rgbled.heartbeat( False ) # stop the heartbeat service rgbled.color(0x00FF0000) # sets the LED color to red rgbled.color(0x0000FF00) # sets the LED color to green rgbled.color(0x000000FF) # sets the LED color to blue rgbled.color(0x00FFFF00) # sets the LED color to yellow
rgbled.heartbeat()
rgbled.heartbeat( <enable> )
rgbled.heartbeat( <color>, <cycle-time>, <blink-percentage> )
The description of each signature is as follows:
True
False
The description of the available argument are:
<enable>
<color>
<cycle-time>
<blink-percentage>
# rgbled.heartbeat() example: import rgbled rgbled.heartbeat() # check the status of the service # returns False rgbled.heartbeat( True ) # start the heartbeat service # start with the default configs rgbled.heartbeat() # check the status of the service # returns True # to set the blue color blinking for about 200 msec each one second. rgbled.heartbeat(0x000000FF, 1000, 20) # new config is set and service restarted rgbled.heartbeat() # check the status of the service # returns True rgbled.heartbeat( False ) # stop the heartbeat service # to set the red color blinking for about 10 msec each 50 ms. (very fast) rgbled.heartbeat(0x00FF0000, 50, 20) # new config is set and service started rgbled.heartbeat() # check the status of the service # returns True rgbled.heartbeat( True ) # start the heartbeat service # it will start with latest config (0x00FF0000, 50, 20) rgbled.heartbeat() # check the status of the service # returns True
rgbled.decoration()
where:
<blink-desc-list>
<blink-desc-tuple>
<color-value>
<duty-period>
<light-on-percent>
<loop-count>
# assume we want the following time light sequence # # ___ 50 ___ ___ 50 ___ __________ __________ # | G |__| G |_______| B |__| B |_________| R | Y | # |--------2 Sec-----|--------2 Sec-------|- 0.5 sec-|- 0.5 sec-| # # where G and R period are 50 msec # The sequence above shall be repeated and a one second color should be # off between each repetition # import rgbled rgbled.decoration([ (0x00001100, 100, 50, 2), # the first two G's pulses (0, 2000 - 200, 0, 1), # the light off between G's and B's pulses (0x00000011, 100, 50, 2), # the second two B's pulses (0, 2000 - 200, 0, 1), # the light off after b's pulses (0x00110000, 500, 100,1), # the R period (0x00111100, 500, 100,1), # the Y period (0, 1000, 0, 1) # the light off time before repeating ], True) # repeat the whole sequence again
Here is the expected result:
rgbled._color it is a class carrying the basic color definitions, it can be used directly in place of the color value.
rgbled._color
import rgbled rgbled.color( rgbled._color.RED ) rgbled.color( rgbled._color.GREEN ) rgbled.color( rgbled._color.BLUE ) rgbled.color( rgbled._color.YELLOW ) rgbled.color( rgbled._color.MAGENTA ) rgbled.color( rgbled._color.CYAN ) rgbled.color( rgbled._color.WHITE )