GithubHelp home page GithubHelp logo

samsonmking / epaper.js Goto Github PK

View Code? Open in Web Editor NEW
761.0 761.0 47.0 13.95 MB

Node.js library for easily creating an ePaper display on a Raspberry PI using HTML and Javascript.

License: MIT License

C 85.57% C++ 3.32% Python 1.18% JavaScript 0.03% TypeScript 9.90%

epaper.js's People

Contributors

dependabot[bot] avatar eshaham avatar github-actions[bot] avatar jackcannon avatar markphelps avatar patrickdmiller avatar rshergold avatar samsonmking avatar schoes avatar webphax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

epaper.js's Issues

Run application as root

Im getting this error when running my epaper application as root. Looks like a puppeteer issue and there is a flag to pass in. Where would i add this flag? or is there another way to make this work?

pi@raspberrypi:~/epaper $ sudo node server.js
/***********************************/
Current environment: Raspbian
set wiringPi lib success !!!
/***********************************/
/home/pi/node_modules/puppeteer-core/lib/launcher/BrowserRunner.js:189
            reject(new Error([
                   ^

Error: Failed to launch the browser process!
dpkg-query: no packages found matching bluealsa
[0107/204416.647753:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/home/pi/node_modules/puppeteer-core/lib/launcher/BrowserRunner.js:189:20)
    at Interface.<anonymous> (/home/pi/node_modules/puppeteer-core/lib/launcher/BrowserRunner.js:179:65)

"Cannot find module '../dist/cli'" Error

I am trying to get it setup on my raspberry pi zero for the first time and am running into this error. Any helpful hints?

node:internal/modules/cjs/loader:959
throw err;
^

Error: Cannot find module '../dist/cli'
Require stack:

  • /home/pi/.nvm/versions/node/v16.17.1/lib/node_modules/@epaperjs/cli/bin/ejs-cli
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (/home/pi/.nvm/versions/node/v16.17.1/lib/node_modules/@epaperjs/cli/bin/ejs-cli:6:1)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/home/pi/.nvm/versions/node/v16.17.1/lib/node_modules/@epaperjs/cli/bin/ejs-cli'
    ]
    }

How to change pins?

I have a 4in2 and I use pin 26 for BUSY and 5 for DC.

How can I change that in this library?

Add support for NVIDIA Jetson / Jetson Nano

For the C-code examples provided by e-Paper, the build command for the NVidia JETSON is make JETSON. So for example, the Jetson target for the 4.2in B/W display would be make EPD=_4in2 JETSON.

I have the epd command working on the Jetson with a 4.2in ePaper display connected directly to the 40-pin header. Instructions for this setup are provided by e-Paper at the following links:

https://www.waveshare.com/wiki/Template:Jetson_Nano_Guides_for_SPI_e-Paper

https://www.waveshare.com/wiki/4.2inch_e-Paper_Module_Manual#User_Guides_of_Jetson_Nano

inline JS in example

It makes sense for simplicities sake to have inline JS in an example html file but be mindful if people copy/paste it will cause inline javascript issues down the road for them.

I guess maybe a warning not to include the JS in the HTML is one solution? Another is to have it another file? Another is to disregard this and hope that the developers know what they are doing :P

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script

api usage

Thanks so much for this module. It works great except for 1 issue I'm having with a Waveshare 4.2" e-paper display connected via SPI device 0 on a Pi 3b+. I'm using the following code to send a PNG to the display via the API:

const { Rpi4In2 } = require('@epaperjs/rpi-4in2')
const displayHardware = new Rpi4In2()
displayHardware.connect()
displayHardware.clear()
setTimeout( () => {
  generateImage().then( (image) => {
          displayHardware.displayPng(image)
  }), 10000)

This hangs the node event loop at displayHardware.connect the first time I run it following a reboot. Closing and restarting always gets it working the second time and each time thereafter until a reboot. Note "generateImage" is a function that builds out the PNG buffer.

An "lsof" shows the node process (and nothing else) writing to the spi device in all instances.

Am I misunderstanding the API or the proper use of "connect()"?

Thanks so much for putting this module together. It's great!

Not running on RPI4 64-bit (Please make JETSON !!!!!!!!!!)

Hi,
I've been trying to run epaper.js on my Rpi4 and getting some issues. After installing everything I run the following command:
ejs display rpi-7in5-v2 "https://github.com/samsonmking/epaper.js"

And getting the following error (I ran with --debug):

Connecting to rpi-7in5-v2 screen
/***********************************/
Current environment: Debian
Please make JETSON !!!!!!!!!!
Connected
Displaying https://github.com/samsonmking/epaper.js
[DEBUG] Browser console.warning Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'. [ { url: undefined, lineNumber: undefined } ]
^CPowering off display and exiting...
Powering off display and exiting...
Failed to close SPI device.
: Bad file descriptor

Note that I'm using Raspbian 64-bit and not 32.
Obviously I saw Please make JETSON !!!!!!!!!! but Google didn't help much with that :/.

Any help would be appreciated.

Thanks a lot!

Inconsistent drawing between 'identical' devices

Context: So I have the same setup across 5 'identical' devices:

Raspberry Pi Zero 2 running Raspbian Lite (Legacy) - Debian Buster (required by another dependency)
Waveshare 7.5in E-Ink Display V2 via e-paper HAT (using wires, rather than as a HAT, to keep as thin as possible.
All set up identically, with same software and hardware, and set up at similar times.

2 of the screens display perfectly fine, one is live-able, and the other 2 have great difficulty displaying more than a very simple page.

On the 'defective' screens, they commonly fail to draw all of the black pixels, giving a very faded appearance. The screens can draw simple images fine, they only start failing when there's more complex patterns to draw. I have experimented with swapping out the Pi, and it's made no change, but as the screens are the most expensive component, I'm hesitant to replace them, especially if they've only got a ~50% chance of success (based on circumstantial data).

Now, why am I raising an issue here if it's a hardware problem?
Well, during the 'redraw' step, as the screen flashes back and forth, the full screen image is perfectly visible, both as white on black, and the inverted version, but fades out during the final draw. My understanding of the hardware and C aspects aren't
wonderful, but I've recently been wondering if there may be something that can be done via the software to improve this.
The fact that they only struggle for complex pages, and seem fine during the redraw made me wonder whether adjusting the timings of the redraw might 'allow it more time'?

It looks like the delays aren't currently configurable - is this because there'd never be any benefit to changing them? (i.e. I'm barking up the wrong tree) Or do you think this might be a reasonable line of enquiry?
Any advise or pointers you may have would be greatly appreciated!

Build is broken in version 1.7.0

I believe version 1.7.0 has broken the build.
After npm installing, running my app produces the following error:

Error: Could not locate the bindings file

Downgrading to version 1.6.0 solves the issue.

Running on RPi Zero, Node v14.4.0 via nvm

HTTP Basic Auth support?

πŸ‘‹πŸ» What do you think about adding HTTP Basic Auth support for url?

My use case:

I want to host my page on the web so that I can make use of some Google APIs which require user interaction initially (calendar read events), however, I don't want to publically expose my data to the world.

It would be great if I could use HTTP basic auth to protect my page on the server, and then pass those values through ejs via command line option like --basic-auth.

It seems puppeteer supports this like

page.authenticate({'username':'YOUR_BASIC_AUTH_USERNAME', 'password': 'YOUR_BASIC_AUTH_PASSWORD'});

I think this could be added here and set with the values provided via --basic-auth to ejs

Add Support for 2.13 inch V3 - HAT

Hi @samsonmking,

Thank you for this library. I kindly request you to add support for version3 of HAT - 2.13inch. Turns out V2 does not work with this hardware.
Please let me know if I am misunderstanding anything here.

Best,
Abhay

Add support for Waveshare 7in5bc black/red/white display

@ciocan @RaedsLab if you have devices and would like to help with development or testing please let me know.
Thank you @samsonmking

I have tried to see if EPD_7in5 drivers will work on EPD_7in5bc which I have. It does not work.

The display method for EPD_7in5bc needs two buffer arguments. I managed to make it work like this:

Napi::Value Display(const Napi::CallbackInfo& info) {
    Napi::Env env = info.Env();
    Napi::Buffer<uint8_t> jsBufferBlack = info[0].As<Napi::Buffer<uint8_t>>();
    Napi::Buffer<uint8_t> jsBufferRed = info[1].As<Napi::Buffer<uint8_t>>();
    EPD_7IN5BC_Display(reinterpret_cast<uint8_t *>(jsBufferBlack.Data()), reinterpret_cast<uint8_t *>(jsBufferRed.Data()));
    return env.Undefined();
}

It compiles ok, but now I need to figure out how to make the black and red buffers from the png image.

Originally posted by @ciocan in #1 (comment)

Question: How to display images from file?

Not exactly in the scope of the project, but just a generic question.

I wanted to save the screenshot in a PNG file to use as a sort of "snapshot".

The problem I'm facing that when i load the files again they don't get displayed properly, so I think i'm messing up some buffer formatting here.

Any idea why this isn't working the same as the PNG image here : https://github.com/samsonmking/epaper.js/blob/master/page.js#L11 ?

My understanding is that both functions (pupetter screenshot, and fs.readFile) should return a buffer

const fs = require('fs')
const devices = require('./devices');
const { convertPNGto1BitBW } = require('./image.js');


(async () => {
    try {
        const device = devices.waveshare4in2
        const driver = device.driver

        driver.dev_init();
        driver.init();

        fs.readFile('./snapshot.png', async (err, buffer) => {
            if (err) {
                console.log("ERROR", err);
                driver.sleep();
                return;
            }
            const out = await convertPNGto1BitBW(buffer);
            driver.display(out)
            driver.sleep();
            console.log("Done")
        });

    } catch (e) {
        console.log("ERROR", e)
    }
})();

Add support for Waveshare 12.48in B e-paper

Howdy! I'd love to add support for the 12.48" e-paper.

https://www.waveshare.com/wiki/12.48inch_e-Paper_Module
https://github.com/waveshare/12.48inch-e-paper

I'm excited to use this guy, but I'd rather write in Node... hence me coming here! I'm happy to write the binding, but I've never written one from scratch, (and I'm rusty as hell at C). If you could give me a quickstart, I could write and test and keep you up to speed via this issue.

Thanks in advance!

How to cleanly exit the backend server?

I am using this with a Waveshare 7.5 v2 display, and generally it is working well, and have also managed to get regular refreshs to work through the websocket.

But for whatever reason I cannot cleanly exit the backend script once init() is running; ctrl+c on ssh shell does not work, and sending SIGTERM via htop will also not end the script, only SIGKILL will do the job. This makes for quite a mess when testing/tweaking the static HTML on the display...

Not sure whether I am overlooking anything obvious, but any thoughts would be very welcome!

Text is displayed RTL not LTR

When i use my 2.7 inch waveshare screen and render an index.html the text is displayed RTL and not LTR.
IMG_0009
Version of lib 1.7.1
Display : waveshare 2.7 inch

Npm install hangs

Hello,
I am trying to install the library, for some reason the npm install -global hangs after loading for a while.
This is for 2.13 inch e paper HAT display

Add support for initializing with an existing express app

Hi there, I'm trying to integrate this project with an application that already has an existing express app.
Would it make sense to add support for sending the express app as part of init?
If so, would you like it to be another parameter or a config option?
If you think this is a good idea, I'd be happy to send a PR.

Does not seem to work with latest `chromium-browser` package on Raspbian 11

ejs version: 2.1.1
rpi-7in5-v2 version: 2.0.3

After upgrading chromium-browser on Raspbian 11 ejs no longer seems to be able to launch chromium.

It just hangs at this stage and never renders anything:

With Chromium 98

pi@pizero:~ $ chromium-browser --version
Chromium 98.0.4758.106 Built on Raspbian , running on Raspbian 11
pi@pizero:~ $ ejs refresh --debug --screenshotDelay=1000 rpi-7in5-v2 https://xyz.dev/
Connecting to rpi-7in5-v2 screen
/***********************************/
Current environment: Raspbian
Write and read /dev/spidev0.0
/***********************************/

After downgrading to the previous package version on Raspbian 11 it works again.

With Chromium 95

pi@pizero:~ $ chromium-browser --version
Chromium 95.0.4638.78 Built on Raspbian , running on Raspbian 11
pi@pizero:/tmp $ ejs refresh --debug --screenshotDelay=1000 rpi-7in5-v2 https://xyz.dev/
Connecting to rpi-7in5-v2 screen
/***********************************/
Current environment: Raspbian
Write and read /dev/spidev0.0
/***********************************/
Connected
[DEBUG] Waiting an additional 1000ms before taking screenshot
[DEBUG] Screenshot delay complete
Waking up display
Displaying https://xyz.dev/

7.5inch Display Not Working

Hello! Awesome project. I'm trying to get it working on the 7.5inch V2 by running the examples, but am unable to due to an undefined function.
Steps to reproduce:
In 4gray.js, change device:
const { init, devices } = require('epaperjs'); init(devices.waveshare7in5v2Horizontal);

Run npm run start

And the following logs are returned:

/***********************************/ Current environment: Raspbian set wiringPi lib success !!! /***********************************/ (node:4581) UnhandledPromiseRejectionWarning: ReferenceError: convertPNG is not defined at Object.displayPNG (/home/pi/Downloads/node_modules/epaperjs/devices.js:62:24) at Page.display (/home/pi/Downloads/node_modules/epaperjs/page.js:24:27) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async WebSocket.<anonymous> (/home/pi/Downloads/epaper.js-1.3.1/examples/ereader/ereader.js:8:13) (Use node --trace-warnings ...to show where the warning was created) (node:4581) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:4581) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:4581) UnhandledPromiseRejectionWarning: ReferenceError: convertPNG is not defined at Object.displayPNG (/home/pi/Downloads/node_modules/epaperjs/devices.js:62:24) at Page.display (/home/pi/Downloads/node_modules/epaperjs/page.js:24:27) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async WebSocket.<anonymous> (/home/pi/Downloads/epaper.js-1.3.1/examples/ereader/ereader.js:8:13) (node:4581) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

According to the logs, the convertPNG() method that's specific to the const waveshare7in5v2Horizontal in devices.js is never defined in image.js (or any other files or dependencies) and needs to be defined.

Screenshot Delay? What am I doing wrong?

πŸ‘‹πŸ» hello again!

So I'm trying to get my app displaying on my rpi-7in5-v2, using the command:

ejs refresh -i 60 --debug --screenshotDelay=5000 rpi-7in5-v2 https://my-url

Im using version 2.1.0 of the CLI:

pi@raspberrypi:~ $ ejs --version
2.1.0

Here's what it looks like in the browser (I blurred out the details of the calendar events):

blur-paper

However only part of my app is displaying on the epaper display:

IMG_2363

I'm trying to use screenshotDelay because the calendar details are loaded async, as my app is a client side app (vueJS) that loads the calendar events from a backend API (written in go). My thought was that the screenshot was happening too quickly before the app has fully loaded all the events, however now I'm not sure if screenshotDelay is working as I thought?

I included --debug but don't see any actual debug logs or change in output.

My questions are:

  1. Am I using --screenshotDelay=n correctly? I tried both --screenshotDelay n and --screenshotDelay=n
  2. Am I using --debug correctly? I tried --debug and --debug=true and --debug true
  3. Should I expect any additional debug output if there are no errors?
  4. Is there any other way I can debug why my async entries are not showing on the epaper display but are showing in the browser?

Thanks in advance!

wiringpi is deprecated

when trying to run the commands in the readme, I could not get wiringpi to install:

sudo apt-get install -y wiringpi

from what I'm reading, it is being deprecated
are there any alternatives?

Add Support for Waveshare 10.3

I forked the project to try and add support for the 10.3 waveshare screen. It uses the IIT8951 header hat and libs are available here :
https://github.com/waveshare/IT8951-ePaper/tree/master/Raspberry/lib/e-Paper

I did not manage to find correspondances for some functions like init, display, sleep ... some take arguments that I don't know how to get in this context, others don't seem to exist in the lib (like display). I guess I missed some things.

Fork is available here if needed (https://github.com/stan69b/epaper.js), a folder EDP_10IN3 has been created and libs were linked but it does not compile currently.
If anyone wants to try it out and fix it, that would be wonderful :)

Add support for EP-0133

Thank you for this awesome library! It's exactly what I need since I'm much more familiar with Node/HTML than Python or C++ πŸ˜„

I own an EP-0133, would it be possible to add support for this screen? I'd be happy to give you any debugging info/run commands if it's helpful. Thanks a million!

The demo code can be found here: https://github.com/geeekpi/epaper

Working with PDF.js for larger e-ink reader displays

Hi, great project that I just noticed. Naive question : how do you imagine relying on https://github.com/mozilla/pdf.js could work?

I have a reMarkable (v1) that I rely enjoy on its own but it also have some extensibility potential... year relations locked down by a vendor https://github.com/remarkable which doesn’t interact much with an otherwise very active community https://github.com/reHackable/awesome-reMarkable .

Consequently I’m looking at DIY alternatives. Any suggestion?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.