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 name.

{
    "workers":[{
        "type":"control",
        "controls": [
            {
                "type":"Button",
                "pin": 2,
                "name":"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.
name[String]YesName of the control. The name will be slugged and used as key to store in redis if a key is not specified.
key[String]NoKey to store value under in redis. Alphanumeric with underscores only. Must be valid redis key. If a key is not provided it will use the name converted to lowercase and spaces replaced with underscores.

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)