gpiopwm

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

README

GPIO PWM activity

This activity allows you control PWM pins of a Raspberry Pi.

WARNING: The GPIO PWM activity requires that flogo runs as root.

Installation

Flogo Web
Start

Start a container of Flogo Web UI :

docker run --name flogo -it -d -p 3303:3303 -e FLOGO_NO_ENGINE_RECREATION=false flogo/flogo-docker eula-accept

The environment variable FLOGO_NO_ENGINE_RECREATION=false allows to force import of installed contributions.

Installation of the activity

To install the activity into the started container :

docker exec -it flogo sh -c 'cd /tmp/flogo-web/build/server/local/engines/flogo-web && flogo install github.com/square-it/flogo-contrib-activities/gpiopwm'

Restart the container

docker restart flogo
Flogo CLI
flogo install github.com/square-it/flogo-contrib-activities/gpiopwm

Schema

Inputs and Outputs:

{
 "inputs":[
    {
      "name": "pinNumber",
      "type": "int",
      "required": true,
      "allowed": [12, 13, 18, 19, 40, 41, 45]
    },
    {
      "name": "pwmFrequency",
      "type": "int",
      "required": true
    },
    {
      "name": "dutyLength",
      "type": "uint32",
      "required": true
    },
    {
      "name": "cycleLength",
      "type": "uint32",
      "required": true
    }
  ],
  "outputs": [
  ]
 }

Settings

Setting Required Description
pinNumber True The index of the pin of the GPIO header to modify
pwmFrequency True The frequency (in Hz) of the PWM
dutyLength True The duty part of the duty cycle
cycleLength True The cycle part of the duty cycle

See https://godoc.org/github.com/stianeikeland/go-rpio#SetDutyCycle for more details about Duty and Cycle.

Outputs

Output Description

Examples

Activate PWM with 1ms duty and 50Hz frequency on pin 12
{
  "id": "gpiopwm_1",
  "name": "GPIO PWM",
  "description": "Perform PWM control on Raspberry GPIO. Requires root access.",
  "activity": {
    "ref": "github.com/square-it/flogo-contrib-activities/command",
    "input": {
      "pinNumber": 12,
      "pwmFrequency": 50,
      "dutyLength": 100,
      "cycleLength": 2000
    },
    "output": {
    }
  }
}
Disable PWM on pin 12 (set dutyLength to 0)
{
  "id": "gpiopwm_1",
  "name": "GPIO PWM",
  "description": "Perform PWM control on Raspberry GPIO. Requires root access.",
  "activity": {
    "ref": "github.com/square-it/flogo-contrib-activities/command",
    "input": {
      "pinNumber": 12,
      "pwmFrequency": 50,
      "dutyLength": 0,
      "cycleLength": 2000
    },
    "output": {
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewActivity

func NewActivity(metadata *activity.Metadata) activity.Activity

NewActivity creates a new activity

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

func (*Activity) Eval

func (a *Activity) Eval(context activity.Context) (done bool, err error)

Enable PWM, then set Frequency and DutyCycle on the given GPIO pin

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

Metadata implements activity.Activity.Metadata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL