Facility Control

 View Only
  • 1.  Changing button colours from feedback

    Posted 11-03-2019 20:24

    Currently, I am trying to figure out if it is possible to have the colour of a button change based on feedback from an Arduino node MCU. 



  • 2.  RE: Changing button colours from feedback

    Posted 11-04-2019 16:06

    To change the color of a button, you need to set its style. 

    Let's assume feedback you get from the Arduino is a string, you can then set the style of your button (e.g. coloredButton) based on the string value to color red like this:

     ogscript.setStyle('coloredButton', 'bg#ff0000');

    The following example grid allows you to choose the color you want to assign to the button using a drop down list provided by a local parameter:

    <abs contexttype="opengear" id="_top" keepalive="false">
    <meta>
    <params>
    <param access="1" constrainttype="STRING_CHOICE" maxlength="0" name="msgParam" oid="msgParam" type="STRING" value="blue" widget="combo">
    <constraint>green</constraint>
    <constraint>red</constraint>
    <constraint>blue</constraint>
    </param>
    </params>
    </meta>
    <param expand="true" height="78" left="305" oid="msgParam" top="101" width="253">
    <task tasktype="ogscript">var text = params.getValue('msgParam', 0);
    switch (text){
    case 'green':
    ogscript.setStyle('coloredButton', 'bg#009933');
    break;
    case 'red':
    ogscript.setStyle('coloredButton', 'bg#ff0000');
    break;
    case 'blue':
    ogscript.setStyle('coloredButton', 'bg#0099ff');
    break;
    }</task>
    </param>
    <button buttontype="push" height="79" id="coloredButton" left="81" name="Colored Button" top="104" width="148"/>
    </abs>

    #DashBoard