# bluepill-client-library

> remote driver for bluepill board

Latest version **1.1.0** (published 2020-04-18) · beerware license · 0 weekly downloads

## Install

```sh
npm install bluepill-client-library
pnpm add bluepill-client-library
yarn add bluepill-client-library
bun add bluepill-client-library
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-04-18 |
| First published | 2018-11-12 |
| Weekly downloads | 0 |
| License | beerware |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | 8.4.0 |
| Dependencies | 3 |
| Unpacked size | 53.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | tB |
| Maintainers | tblabs |

## Links

- npm: https://www.npmjs.com/package/bluepill-client-library
- npm.io page: https://npm.io/package/bluepill-client-library

## Dependencies (3)

- [jasmine-core](https://npm.io/package/jasmine-core.md) ^2.6.1
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.1.1
- [@types/socket.io-client](https://npm.io/package/@types/socket.io-client.md) ^1.4.32

## Recent versions

- 1.1.0 (latest) — 2020-04-18
- 1.0.8 — 2018-11-15
- 1.0.7 — 2018-11-15
- 1.0.6 — 2018-11-15
- 1.0.5 — 2018-11-13
- 1.0.4 — 2018-11-12
- 1.0.3 — 2018-11-12
- 1.0.2 — 2018-11-12
- 1.0.1 — 2018-11-12
- 1.0.0 — 2018-11-12

## README

TODO
- all events callbacks should be streams or events emitters/Rx cause now we can attach only one action to each event
- remove RTC?
- remove `/bin` from import (copy bin files level up during publishing?)

# BluePill.Client.Lib

It is a client for a `BluePill development board` in a form of library.  
It is distributed as a node package with TypeScript definition file.  

## Install

`npm i bluepill-client-library`

## Import

`import { BluePillSocketConnector, BluePillBoard } from 'bluepill-client-library/bin';` // TODO: remove `/bin`

## Usage

```
const connectionString = 'http://localhost:3000';
const connector = new BluePillSocketConnector(connectionString);
const board = new BLuePillBoard(connector);

board.Input1.OnPress.subscribe(() =>
{
    board.Output1.Toggle();
});
```

# Connectors

Board Connector is a class implementing IBoardConnector interface. This interface contains only two methods: Send and OnUpdate.  

## Standalone usage

```
const connector = new BoardSocketConnector('http://localhost:3000');
connector.Set(12, 1234);
connector.OnUpdate = (addr, stateChange) => console.log(addr, stateChange);
```

# Board

## IO types and their properties

| Type              | Setters    | Getters                           | Methods               | Events                                                |
| ----------------- | ---------- | --------------------------------- | --------------------- | ----------------------------------------------------- |
| DigitalInput      | *none*     | Value, MaxValue                   | *none*                | OnChange, OnRising, OnFalling, OnPress, OnLongPress   |
| AdcInput          | *none*     | Value, MaxValue                   | *none*                | OnChange, OnRising, OnFalling                         |
| DigitalOutput     | Value      | Value, MaxValue                   | On(), Off(), Toggle() | OnChange                                              |
| PwmOutput         | Value      | Value, MaxValue                   | *none*                | OnChange                                              |
| Clock (RTC)       | Value      | Value, MaxValue                   | *none*                | OnChange                                              |
| Display           | Value, Dot | Value, Dot, MaxValue, MaxDotValue | *none*                | OnValueChange                                         |

## How to run example?

Connect board to PC with USB or Serial Port. Determine it's port.  
Start board's [Daemon](https://github.com/tBlabs/BluePill.Daemon) with appropriate params (host port and usb/serial port).  
You are ready now to start board client.

There is few sample apps:
- sample.app.ts

You can start any of them with `node bin/SampleApps/sample.app.js`.

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