Skip to content

4ib3r/node-epd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-epd

Nodejs library for Waveshare e-Paper modules

Information

Library is writed for 2.9" waveshare e-paper display, but it should work for 1.54", 2.13".

Requirements

  • wiringPi
  • libfreetype6-dev

Example

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
});

Documentation

Classes

Lcd

Main Lcd driver class

Typedefs

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

Lcd

Main Lcd driver class

Kind: global class

new Lcd(channel, dc, cs, rst, led)

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

lcd.clear()

Clear whole screen and set all refresh mode

Kind: instance method of Lcd

lcd.clearPart()

Change display mode to partial drawing

Kind: instance method of Lcd

lcd.update()

Update whole screen

Kind: instance method of Lcd

lcd.partUpdate()

Update changed part of screen

Kind: instance method of Lcd

lcd.line(x, y, x2, y2, col)

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

lcd.rect(x, y, width, height, fill, col)

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

lcd.circle(x, y, r, fill, col)

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

lcd.pixel(x, y, col)

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

lcd.color(color)

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

Rect object

Kind: global typedef
Properties

Name Type
xMin number
yMin number
xMax number
yMax number

FontFace : Object

FT_Face object wrapper

Kind: global typedef
Properties

Name Type Description
size number font size
height number font size in px

EpdSize : Object

EpdSize object

Kind: global typedef
Properties

Name Type Description
width number Display width in px
height number Display height in px

Color : number

Drawing color -1 inverse, 1 black (default), 0 white

Kind: global typedef

About

Nodejs library for Waveshare e-Paper modules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published