Pat Object

Top  Previous  Next


The pat object allows you to "play" signal patterns on up to five LED pairs, each pair consisting of a green and red LED.

The channel to work with is selected through the property. The first channel (channel 0) is the primary channel of your system. It utilizes green and red status LEDs that are present on all external devices, boards, and some modules offered by Tibbo. All modules have SG and SR I/O lines that are meant for controlling external status LEDs. Note that when the Tibbo BASIC/C application is not running, green and red status LEDs are used to display various status information.

The remaining four channels (channel 1-4) are identical in function, but use regular I/O lines of Tibbo devices. Moreover, pat.greenmap and pat.redmap properties allow you to flexibly map the green and red LED control lines of each channel to any I/O lines of the device.

The pattern you play can be up to 16 steps long. Each "step" can be either "-" (both LEDs off), "R" (red LED on), "G" (green LED on), or "B" (both LEDs on). You can also define whether the pattern will only execute once or loop and play indefinitely. Additionally, you can make the pattern play at a normal, double, or quadruple speed.

You load the new pattern to play with the method. If the pattern is looped it will continue playing until you change it. If the pattern is not looped it will play once and then the on_pat event will be generated. When the event handler is entered, the property will be automatically set to the channel number for which the event was generated.

LED patterns offer a convenient way to tell the user what your system is doing. You can devise different patterns for different states of your device.

Here is a simple example in which we keep the green LED on at all times, except when the button is pressed, after which the green LED is turned off and the red LED blinks three times fast. Additionally, both green and red LEDs blink 4 times on startup. In this example we work on channel 0:


Sub On_sys_init 'not really necessary since 0 is the default value for this property"B-B-B-B-",PL_PAT_CANINT)

End Sub


Sub On_button_pressed"*R-R-R-",PL_PAT_CANINT)

End Sub


Sub On_pat

    If Then 'not really necessary since we are not using any other channels"~G",PL_PAT_CANINT)

  End If

End Sub


In the above example, the power-up pattern is loaded inside the on_sys_init event handler. This is not a looped pattern, so once it finishes playing the on_pat event is generated and the "permanent" pattern "green LED on" is loaded inside this event's handler. This new pattern is looped (notice "~"). When the button is pressed, a fast pattern (notice "*") is loaded. This one makes the red LED blink three times. Again, this is not a looped pattern, so after it finishes playing the on_pat event is generated and the "permanent green" pattern is loaded again.