You are here: Using External Control Systems with HAL > Integrating Stardraw Control Systems > Exploring the Stardraw Example Application > Levels

Levels

The end user of the Stardraw example application controls the lounge volume with the vertical slider Volume control. This control is the Advanced Slider from the Controls palette in the Stardraw Toolbox, oriented vertically, and is named LoungeVolumeControl.

Lounge Volume Level

Control Range and Display Scale

The HAL system uses a range of 0 to 1000 for level control values, corresponding to 0.0 to 100.0%. The Stardraw application’s Advanced Slider must be configured to match this range in order to work correctly. To see this, click on the Volume slider control (named LoungeVolumeControl) and view the Properties for this control on the right side of the Stardraw window. In the Behavior section, the Maximum is 1000 while the Minimum is 0. These settings cause the slider control to have a range of 0 to 1000 when interacting with the HAL1 example driver, matching HAL system level control behavior.

Changing the Maximum to 1000 also affects the slider’s scale that the end user sees on the Stardraw form. In addition, the Advanced Slider control provides warning and danger zones, that color the scale for those zones brown and red respectively. For this example, we want a simple scale for the slider, displaying a range from 0 to 100 in ten steps and in a uniform black color. To see how the application achieves this, look at the LoungeVolumeControl’s Properties again and click + symbol next to the Labels property in the Appearance section. This property contains the set of labels that the control displays for its visible scale. We’ve also changed the LabelsCount to 11, matching the number of strings in the Labels array. To keep the color uniform black, we’ve also set the DangerValue and WarningValue properties to 1001, so they fall outside the range of the control.

Current Level Value

Now that you understand the Advanced Slider’s range and appearance, we can move on to the control events and associated actions. When the end user changes the volume level slider, Stardraw generates a ValueChange event. Each time this happens the application executes a specific action which sets the LoungeVolumeLevel property in the HAL1 driver to the current value of the form’s LoungeVolumeControl. This in turn causes the driver to send a ‘set level’ message containing the new value to the Halogen/HAL Control Server, updating the HAL example configuration’s Lounge Level Control. To see how the application associates the action with the event, double click on the slider control to bring up the Actions dialog for that control:

As with the toggle controls, the Halogen/HAL Control Server can also update the Stardraw application whenever the Lounge Level Control changes. Each time the level control in Halogen/HAL changes, the Control Server sends a ‘set level’ message containing the new value. When the Stardraw HAL1 driver receives this message, it generates an OnLoungeVolumeLevelChanged event. The example Stardraw application has this event mapped to an action that sets the LoungeVolumeControl’s Value to the driver’s LoungeVolumeLevel property, which updates the value of the slider. To see this in the Actions dialog, use the drop down arrow for the event to navigate to Devices -> HAL1 (1) -> Control Port -> OnLoungeVolumeChanged. The Actions dialog that appears is: