Nodejs library for Waveshare e-Paper modules
Library is writed for 2.9" waveshare e-paper display, but it should work for 1.54", 2.13".
- wiringPi
- libfreetype6-dev
var lcd = new Lcd(0, 4, 10, 5, 1, 55); //initialize display
lcd.clear(); //clear all lcd
var fontAwesome = lcd.font('./test/fontawesome-webfont.ttf', 10); //load ttf font
var robotoFont = lcd.font('./test/Roboto-Regular.ttf', 14); //load ttf font
lcd.char(fontAwesome, 50, 110, 0xf206); //draw char (utf16)
lcd.drawString(robotoFont, 10, 50, "Hello"); //draw string (utf8)
lcd.circle(10,20,25, true); //draw filled circle
lcd.rect(50, 8, 50, 50); //draw rect
lcd.update(function() { //update all display
console.log("LCD updated");
lcd.clearPart(); //switch to partitial update mode
lcd.rect(100, 100, 20, 20); //draw rect
lcd.line(100, 100, 120, 120); //draw line in rect
lcd.partUpdate(); //update only changed part of display
});
- Lcd
Main Lcd driver class
- Rect :
Object
Rect object
- FontFace :
Object
FT_Face object wrapper
- EpdSize :
Object
EpdSize object
- Color :
number
Drawing color -1 inverse, 1 black (default), 0 white
Main Lcd driver class
Kind: global class
- Lcd
- new Lcd(channel, dc, cs, rst, led)
- .font(ttfPath, font) ⇒
FontFace
- .size() ⇒
EpdSize
- .clear()
- .clearPart()
- .update()
- .partUpdate()
- .line(x, y, x2, y2, col)
- .rect(x, y, width, height, fill, col)
- .circle(x, y, r, fill, col)
- .pixel(x, y, col)
- .drawChar(x, y, char) ⇒
Rect
- .drawString(font, x, y) ⇒
Rect
- .color(color)
Param | Type | Description |
---|---|---|
channel | number |
spi channel |
dc | number |
dc pin |
cs | number |
cs pin |
rst | number |
rst pin |
led | number |
additional led pin |
lcd.font(ttfPath, font) ⇒ FontFace
Load ttf font
Kind: instance method of Lcd
Returns: FontFace
- Description of return value.
Param | Type | Description |
---|---|---|
ttfPath | string |
font path |
font | number |
size |
lcd.size() ⇒ EpdSize
Return lcd resolution
Kind: instance method of Lcd
Returns: EpdSize
- display width and height
Clear whole screen and set all refresh mode
Kind: instance method of Lcd
Change display mode to partial drawing
Kind: instance method of Lcd
Update whole screen
Kind: instance method of Lcd
Update changed part of screen
Kind: instance method of Lcd
Draw line
Kind: instance method of Lcd
Param | Type | Description |
---|---|---|
x | number |
start point on x axis |
y | number |
start point on y axis |
x2 | number |
end point on x axis |
y2 | number |
end point on y axis |
col | Color |
line color |
Draw rect
Kind: instance method of Lcd
Param | Type | Description |
---|---|---|
x | number |
start point on x axis |
y | number |
start point on y axis |
width | number |
rect width |
height | number |
rect height |
fill | bool |
If true rect is filled |
col | Color |
rect color |
Draw circle
Kind: instance method of Lcd
Param | Type | Description |
---|---|---|
x | number |
mid point on x axis |
y | number |
mid point on y axis |
r | number |
circle size |
fill | bool |
If true circle is filled |
col | Color |
circle color |
Draw pixel
Kind: instance method of Lcd
Param | Type | Description |
---|---|---|
x | number |
point on x axis |
y | number |
point on y axis |
col | Color |
pixel color |
lcd.drawChar(x, y, char) ⇒ Rect
Draw character from 16 bit representation
Kind: instance method of Lcd
Param | Type | Description |
---|---|---|
x | number |
point on x axis |
y | number |
point on y axis |
char | number |
char code |
lcd.drawString(font, x, y) ⇒ Rect
Draw string from 8bit representation
Kind: instance method of Lcd
Returns: Rect
- drawed coordinates
Param | Type | Description |
---|---|---|
font | FontFace |
Font to draw string |
x | number |
x position |
y | number |
y position |
Set default color to use
Kind: instance method of Lcd
Param | Type | Description |
---|---|---|
color | number |
0 is white, 1 is black, -1 is inversion of current state |
Rect object
Kind: global typedef
Properties
Name | Type |
---|---|
xMin | number |
yMin | number |
xMax | number |
yMax | number |
FT_Face object wrapper
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
size | number |
font size |
height | number |
font size in px |
EpdSize object
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
width | number |
Display width in px |
height | number |
Display height in px |
Drawing color -1 inverse, 1 black (default), 0 white
Kind: global typedef