Skip to main content

Button Indicator

  1. Navigate to HSYCO Manager

  2. Create a new project or open an existing one

  1. Open the Home page

  1. Click "add"

  1. Add a "Button"

  1. Click "edit"

**7. Change the "ID" to "buttondummylight1". This is important because the ID is used later to change some attributes dynamically **

  1. Change the "Width" and "Height" of the button to enlarge it

  1. Align the button in the middle of the page by clicking "Align" and then "Center Vertically" and "Center Horizontally"

  1. Change the "Label" to "Dummy Light 1"

  1. Change the "Action" to "datapoint"

  1. Change the "Datapoint" to "dummy.light.1"

  1. Click "Save" to save the project

Tip: Done! Now we need some code to show the indicator when the button is pressed and to hide it when pressed again

  1. Go into "File Manager"

  1. Navigate into the "events" folder

  1. Click "New File"

  1. Give it a name ("indicator.txt" for example) and click "New File"

**18. Now copy the following code and save the file:

IO dummy.light.1 = 1 : UISET buttondummylight1.indicator = true, UISET buttondummylight1.indicatorlabel = "ON"
IO dummy.light.1 = 0 : UISET buttondummylight1.indicator = false

What this does is it changes the "Indicator" attribute to true and gives it a "Label" (to the button with ID buttondummylight1) when the dummy.light.1 datapoint is On, namely 1. Otherwise it hides the "Indicator"**

Tip: Now we can test the button and see the indicator!

  1. From the "Project Editor", click "Run" and then "Default" to launch the application

  1. Click the button

  1. As you can see, the light has turned on and the indicator is now shown with the "Label" ON

  1. Press the button again

  1. The light turns off and the indicator disappears