# cncjs-pendant-gpio

> Configurable gpio pendant for cncjs

Latest version **0.2.0** (published 2021-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install cncjs-pendant-gpio
pnpm add cncjs-pendant-gpio
yarn add cncjs-pendant-gpio
bun add cncjs-pendant-gpio
```

Provides the command `cncjs-pendant-gpio`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-09-12 |
| First published | 2021-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 8 |
| Unpacked size | 18.4 KB |
| Known vulnerabilities | 0 (+5 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ugly Donkey |
| Maintainers | uglydonkey |
| Keywords | cncjs, pendant, gpio, raspberry, pi |

## Links

- npm: https://www.npmjs.com/package/cncjs-pendant-gpio
- Repository: https://github.com/UglyDonkey/cncjs-pendant-gpio
- Issues: https://github.com/UglyDonkey/cncjs-pendant-gpio/issues
- npm.io page: https://npm.io/package/cncjs-pendant-gpio

## Dependencies (8)

- [onoff](https://npm.io/package/onoff.md) 6.0.3
- [tslib](https://npm.io/package/tslib.md) 1
- [lodash](https://npm.io/package/lodash.md) 4.17.21
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) 8.5.1
- [@oclif/config](https://npm.io/package/@oclif/config.md) 1
- [@oclif/command](https://npm.io/package/@oclif/command.md) 1
- [socket.io-client](https://npm.io/package/socket.io-client.md) 2.3.0
- [@oclif/plugin-help](https://npm.io/package/@oclif/plugin-help.md) 3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2021-09-12
- 0.1.3 — 2021-09-01
- 0.1.2 — 2021-08-31
- 0.1.1 — 2021-08-31
- 0.1.0 — 2021-08-31

## README

cncjs-pendant-gpio
==================

[![Version](https://img.shields.io/npm/v/cncjs-pendant-gpio.svg)](https://npmjs.org/package/cncjs-pendant-gpio)
[![Downloads/week](https://img.shields.io/npm/dw/cncjs-pendant-gpio.svg)](https://npmjs.org/package/cncjs-pendant-gpio)
[![License](https://img.shields.io/npm/l/cncjs-pendant-gpio.svg)](https://github.com/UglyDonkey/cncjs-pendant-gpio/blob/master/package.json)

Configurable gpio pendant for [cncjs](https://github.com/cncjs/cncjs)

* [Installation](#installation)
* [Usage](#usage)
* [Configuration](#configuration)

# Installation
```shell
npm install -g cncjs-pendant-gpio
```

# Usage
```shell
cncjs-pendant-gpio [PORT]
```
`PORT` - port of your controller. If not specified then pendant connect to first opened port. For more information please read [this](#port)

# Configuration

cncjs-pendant-gpio loads json configuration from `~/cncjs-pendant-gpio`

- [debounceTimeout](#debouncetimeout)
- [port](#port)
- [pin](#pin)
- [action](#action)

## Example
```json
{
  "pins": [{
    "type": "button", 
    "gpio": 4, 
    "edge": "rising", 
    "actions": [{
      "type": "log", 
      "message": "STOP"
    },{
      "type": "gcode",
      "gcode": "!"
    }]
  },{
    "type": "button",
    "gpio": 3,
    "edge": "rising",
    "actions": [{
      "type": "gcode",
      "gcode": "$H"
    }]
  }],
  "debounceTimeout": 20
}
```

## debounceTimeout
Default is 20 ms

## port
If not specified then pendant tracks ports and connect to first opened (you probably already did it in cncjs app). If you have only one controller connected it's probably enough for you. In case of multiple controllers you can use this field to select port witch should be used. You can also specify that in [command](#usage).

## pin
Every pin is described as an object. Field `type` defines type of pin.

### Available types

#### button
|field|description|default value|required|
|---|---|---|---|
|type|should be `"button"`|`"button"`|`true`|
|gpio|gpio pin number| |`true`|
|edge|`"rising"`, `"falling"`, `"both"`| |`true`|
|actions|array of [actions](#action)| |`true`|

## action
Every action is described as an object. Field `type` defines type of action.

### Available types

### log
Log message to standard output

|field|description|default value|required|
|---|---|---|---|
|type|should be `"log"`|`"log"`|`true`|
|message|whatever you want to see in logs| |`true`|

### gcode
Send gcode to controller

|field|description|default value|required|
|---|---|---|---|
|type|should be `"gcode"`|`"gcode"`|`true`|
|gcode|gcode command| |`true`|

---
_Source: https://npm.io/package/cncjs-pendant-gpio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
