samsonmking / epaper.js Goto Github PK
View Code? Open in Web Editor NEWNode.js library for easily creating an ePaper display on a Raspberry PI using HTML and Javascript.
License: MIT License
Node.js library for easily creating an ePaper display on a Raspberry PI using HTML and Javascript.
License: MIT License
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)
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:
I have a 4in2 and I use pin 26 for BUSY and 5 for DC.
How can I change that in this library?
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
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
What needs to be changed to work on 880Γ528, 7.5inch E-Ink raw display, red / black / white three-color?
puppeteer quite a power hungry. is it possible to render an image on screen directly without taking screenshot?
I'd be interested in support for the Waveshare 1448Γ1072 high definition, 6inch E-Ink display: https://www.waveshare.com/6inch-hd-e-paper-hat.htm
I am a developer, but when it comes to C-programming I'm somewhat out of my comfort zone but if there's anything I can do to help out, please let me know. FWIW, I own one of these displays.
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!
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!
Is it possible to add support for:
https://www.waveshare.com/7.5inch-hd-e-paper-hat.htm
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!
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
Hi,
total noob here :) is it much work to add support for https://www.waveshare.com/product/displays/7.8inch-e-paper-hat.htm?
Thanks and cheers!
If you want I can write a TypeScript type declaration file for this package so that TS developers can utilise the type-checking feature of the language as they use this package. Let me know if you are interested.
ππ» 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
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
@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)
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)
}
})();
Working on the support myself whenever I have time. Will submit a pull if I create anything useful. :)
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!
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!
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
Is it possible to add support for https://www.waveshare.com/7.5inch-e-paper-hat-b.htm
Thank you!
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.
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:
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.
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/
Sounds like a fun project! I can start with testing for the 2.7" model next week. I'll be using a Raspberry PI model 3 B.
Haven't done much C
coding in many years but i'll give it a shot!
Originally posted by @RaedsLab in #1 (comment)
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.
ππ» 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):
However only part of my app is displaying on the epaper display:
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:
--screenshotDelay=n
correctly? I tried both --screenshotDelay n
and --screenshotDelay=n
--debug
correctly? I tried --debug
and --debug=true
and --debug true
Thanks in advance!
https://www.waveshare.com/wiki/5.83inch_e-Paper_HAT
I will try to add support myself but i would grateful for any tipps & gotchas
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?
Is the 7in5bc display also supported? I am not able to run anything but the original waveshare python example code on that display.
https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT_Manual#Hardware_connection
Would love to see a html page on that display. :)
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 :)
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
I was working on a few things and ran into a snag, I wanted to ask a few questions but when I clicked the Discord link (https://discord.com/channels/888893320309379122) and it says "no text channels" I think it may be because this is a link to the Discord channel rather than a sever invite.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.