Skip to content

Commit

Permalink
Fix Gray samsonmking#1 not displaying correct
Browse files Browse the repository at this point in the history
* Port color mapping example from waveshare python examples
* Add simple 4 gray example
* Restore prettier in package.json
  • Loading branch information
samsonmking committed Nov 27, 2020
1 parent 173b7e4 commit e9ad317
Show file tree
Hide file tree
Showing 10 changed files with 1,848 additions and 67 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ init();
**Additional Configuration Options**

```js
const {devices, init} = require('epaperjs');
const { devices, init } = require('epaperjs');
init(devices.waveshare4in2, {
webPort: 3000, // WebServer Port
websocketPort: 8080, // WebSocket API Port
staticDirectory: 'static', // Directory to serve frontend from
url: `http://localhost:3000/index.html` // Initial URL to load
webPort: 3000, // WebServer Port
websocketPort: 8080, // WebSocket API Port
staticDirectory: 'static', // Directory to serve frontend from
url: `http://localhost:3000/index.html`, // Initial URL to load
});
```

Expand Down Expand Up @@ -132,15 +132,16 @@ sudo apt-get install -y build-essential chromium-browser

**Node.js**\
Install ePaper.js
``` bash

```bash
npm install -S epaperjs
```

## Supported Hardware

| Device | Supprted Display Modes |
| ------------------------------------------------------------------ | ---------------------- |
| [Waveshare 4.2"](https://www.waveshare.com/4.2inch-e-Paper.htm) | Black / White |
| [Waveshare 4.2"](https://www.waveshare.com/4.2inch-e-Paper.htm) | Black / White, 4 Gray |
| [Waveshare 7.5" v2](https://www.waveshare.com/7.5inch-e-Paper.htm) | Black / White |

### Adding Support For Additional Displays
Expand All @@ -150,9 +151,10 @@ It's easy to extend ePaper.js to support additional Waveshare devices. Displays
If you would like to request support for another display, please open an issue with the title 'Add support for <Device Make \ Model>'. If you're a developer and have extended support yourself, put up a pull request!

## Feature Backlog
- [x] Add support for portrait or landscape display (rotate 90 deg)
- [ ] Add support for remaining Waveshare SPI ePaper displays
- [x] Implement 4 Color Grayscale
- [ ] Implement Red / White / Black Color Mode
- [ ] Implement Yellow / White / Black Color Mode
- [ ] Implement Partial Refresh

- [x] Add support for portrait or landscape display (rotate 90 deg)
- [ ] Add support for remaining Waveshare SPI ePaper displays
- [x] Implement 4 Color Grayscale
- [ ] Implement Red / White / Black Color Mode
- [ ] Implement Yellow / White / Black Color Mode
- [ ] Implement Partial Refresh
26 changes: 13 additions & 13 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const waveshare4in2Horizontal = {
},
init: function () {
this.driver.init();
}
},
};

const waveshare4in2Vertical = {
Expand All @@ -21,37 +21,37 @@ const waveshare4in2Vertical = {
driver: waveshare4In2Driver,
displayPNG: async function (imgContents) {
const buffer = await image.convertPNGto1BitBWRotated(imgContents);
this.driver.display(buffer)
this.driver.display(buffer);
},
init: function () {
this.driver.init();
}
},
};

const waveshare4in2HorizontalGray = {
height: 300,
width: 400,
driver: waveshare4In2Driver,
displayPNG: async function (imgContents) {
const buffer = await image.convertPNGto1Bit4Grey(imgContents);
this.driver.display_4GrayDisplay(buffer)
const buffer = await image.convertPNGto4Grey(imgContents);
this.driver.display_4GrayDisplay(buffer);
},
init: function () {
this.driver.init_4Gray();
}
},
};

const waveshare4in2VerticalGray = {
height: 400,
width: 300,
driver: waveshare4In2Driver,
displayPNG: async function (imgContents, color_depth) {
const buffer = await image.convertPNGto1Bit4GreyRotated(imgContents);
this.driver.display_4GrayDisplay(buffer)
const buffer = await image.convertPNGto4GreyRotated(imgContents);
this.driver.display_4GrayDisplay(buffer);
},
init: function () {
this.driver.init_4Gray();
}
},
};

const waveshare7in5v2Horizontal = {
Expand All @@ -64,7 +64,7 @@ const waveshare7in5v2Horizontal = {
},
init: function () {
this.driver.init();
}
},
};

const waveshare7in2v2Vertical = {
Expand All @@ -77,7 +77,7 @@ const waveshare7in2v2Vertical = {
},
init: function () {
this.driver.init();
}
},
};

const devices = {
Expand All @@ -90,7 +90,7 @@ const devices = {
// default waveshare7in5v2 kept for backwards compatibility with releaes 1.1.0
waveshare7in5v2: waveshare7in5v2Horizontal,
waveshare7in5v2Horizontal,
waveshare7in2v2Vertical
}
waveshare7in2v2Vertical,
};

module.exports = devices;
3 changes: 3 additions & 0 deletions examples/4gray/4gray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { init, devices } = require('epaperjs');

init(devices.waveshare4in2HorizontalGray);
15 changes: 15 additions & 0 deletions examples/4gray/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Example 4 Color Gray for ePaper.js

## Colors

| Color | HEX Code |
| -------------- | --------- |
| Gray 0 (White) | `#FFFFFF` |
| Gray 1 | `#C0C0C0` |
| Gray 2 | `#808080` |
| Gray 3 (Black) | `#000000` |

## Setup

1. `npm install`
2. `npm run start`
Loading

0 comments on commit e9ad317

Please sign in to comment.