Controls Configuration

Collecting user input is done through controls. Controls currently supported are button, switch and potentiometer types. These range of controls can solve the majority of a systems user input needs.

To add a control to MudPi you will put a control configuration object in the controls array. The minimum required options in a control config are type, pin, and key.

{
    "workers":[{
        "type":"control",
        "controls": [
            {
                "type":"Button",
                "pin": 2,
                "key":"button_1"
            }
        ]
    }]
}

Settings

OptionTypeRequiredDescription
type[String]YesType of control. Options: button, switch, potentiometer
pin[Integer]YesGPIO pin number on raspberry pi the control is connected to.
key[String]YesKey to store value under in redis. Alphanumeric with underscores only. Must be valid redis key.
name[String]NoName of the control. Mainly just a friendly display value. If a name is not provided it will use the key capitolized and underscores replaced with spaces.

Control Types

There are a number of controls supported by default with MudPi for both the raspberry pi and arduino. The main limitation of the pi is digital GPIO only, that is why we use the arduinos. You can find details about each control type under the controls section in the docs.

TypeReturnsDescription
Button[Boolean]Triggers on button press and released. Continues to fire events while pressed.
Switch[Boolean]Triggers on state change only once.
Potentiometer[Integer] 0 - 1024Triggers on state changed and sends current state in event. Has value buffer of 3 before triggering change event. (Works on Arduino Only)