# epaper

> Library for display content on a Waveshare 4.3 inch e-Paper screen

Latest version **1.0.4** (published 2017-03-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install epaper
pnpm add epaper
yarn add epaper
bun add epaper
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-03-19 |
| First published | 2017-02-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Eric Erickson |
| Maintainers | steamedcotton |

## Links

- npm: https://www.npmjs.com/package/epaper
- Repository: https://github.com/steamedcotton/epaper
- Homepage: https://github.com/steamedcotton/epaper#readme
- Issues: https://github.com/steamedcotton/epaper/issues
- npm.io page: https://npm.io/package/epaper

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.7
- [serialport](https://npm.io/package/serialport.md) ^4.0.7

## Recent versions

- 1.0.4 (latest) — 2017-03-19
- 1.0.2 — 2017-02-20
- 1.0.1 — 2017-02-19
- 1.0.0 — 2017-02-19

## README

# epaper

**Coming soon: support for displaying images (from SD card)**

Node.js library for the 4.3 Inch E-Paper display by Waveshare

![e-paper Display Sample](/docs/images/sampleDisplay.png)

## Install

This project uses [serialport](https://www.npmjs.com/package/serialport), before you install this libary, please have a look at this section of the serialport readme: https://www.npmjs.com/package/serialport#installation-instructions

**Installing epaper module:**

```bash
npm install epaper
```


## Sample Code

Assuming you have the e-paper displayed connected to `/dev/cu.usbserial`:

```javascript
const Display = require('epaper').Display;
const display = new Display('/dev/cu.usbserial', true);
 
display.handshake()
    .then(() => display.setColor(Display.BLACK, Display.WHITE))
    .then(display.clear)
    .then(() => display.setFont(Display.ASCII64))
    .then(() => display.displayString('Hello World!', 50, 100))
    .then(() => display.setFont(Display.ASCII48))
    .then(() => display.displayString('github.com/steamedcotton', 50, 180))
    .then(() => display.drawCircle(75, 350, 50))
    .then(() => display.drawFilledCircle(75, 350, 25))
    .then(() => display.drawTriangle(150, 300, 150, 400, 200, 400))
    .then(() => display.drawFillTriangle(150, 300, 200, 300, 200, 400))
    .then(() => display.drawRect(250, 300, 350, 400))
    .then(() => display.drawFilledRect(375, 300, 475, 400))
    .then(() => display.drawLine(50, 420, 475, 420))
    .then(display.update)
    .catch((err) => console.log('Error:', err));
```

## Methods

### Utilities

#### Handshake

After the epaper has powered up, you can send the handshake command to make sure whether the terminal is ready and able to receive commands or data.

```javascript
handshake()
```

#### Clear

Clears the screen using the background color

```javascript
clear()
```

#### Update

Used to refresh and update the display (clears then displays).  All the commands sent in the session will be displayed.

```javascript
update()
```

#### Set Color

Sets the foreground and background color of the drawing.   The foreground color is used in the display the basic drawings and text.  The background color is used for the cleared screen.

```javascript
setColor(<FORGROUND COLOR>, <BACKGROUND COLOR>)
```

**Colors**

The colors can be referenced as static variables on the Display object.

* `Display.WHITE`
* `Display.GRAY`
* `Display.DARK_GRAY`
* `Display.BLACK`

### Draw

#### Pixel

```javascript
drawPixel(<X -> Int>, <Y -> Int>)
```

#### Line

Draws a line with the 2 given points (X1, Y1 > X2, Y2).

```javascript
drawLine(<X1 -> Int>, <Y1 -> Int>, <X2 -> Int>, <Y2 -> Int>)
```

#### Rectangle

Draws a rectangle with the two given points (opposite corners)

```javascript
drawRect(<X1 -> Int>, <Y1 -> Int>, <X2 -> Int>, <Y2 -> Int>)
```

**Filled Rectangle**

```javascript
drawFilledRect(<X1 -> Int>, <Y1 -> Int>, <X2 -> Int>, <Y2 -> Int>)
```


#### Circle

Draws a circle with the given point (X, Y) being the center and the third parameter being the radius.

```javascript
drawCircle(<X1 -> Int>, <Y1 -> Int>, <RADIUS -> Int>) 
```

**Filled Circle**

```javascript
drawFilledCircle(<X1 -> Int>, <Y1 -> Int>, <RADIUS -> Int>) 
```

#### Trangle

Draws a triangle using the three points given. 

```javascript
drawTrangle(<X1 -> Int>, <Y1 -> Int>, <X2 -> Int>, <Y2 -> Int>, <X3 -> Int>, <Y3 -> Int>) 
```

**Filled Triangle**

```javascript
drawFilledTriangle(<X1 -> Int>, <Y1 -> Int>, <X2 -> Int>, <Y2 -> Int>, <X3 -> Int>, <Y3 -> Int>) 
```

### Text

#### Set Font

```javascript
setFont(<FONT>)
```

**Fonts**

The fonts can be referenced as static varibles on the Display object.

English:
* `ASCII32`
* `ASCII48`
* `ASCII64`

Chinese
* `GBK32`
* `GBK48`
* `GBK64`

### Display Text

Displays a provided string at the given location using the current forground color and font.  Maximum lentgh is 1020 bytes.

```javascript
displayText(<X -> Int>, <Y -> Int>, <Text -> Sting>);
```

## Resources

* Waveshare product website: http://www.waveshare.com/4.3inch-e-paper.htm
* E-paper product manual: http://www.waveshare.com/wiki/4.3inch_e-Paper#How_to_work_with_PC

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