1.0.0 • Published 7 years ago

node-epd v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

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

Typedefs

Lcd

Main Lcd driver class

Kind: global class

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

ParamTypeDescription
channelnumberspi channel
dcnumberdc pin
csnumbercs pin
rstnumberrst pin
lednumberadditional led pin

lcd.font(ttfPath, font) ⇒ FontFace

Load ttf font

Kind: instance method of Lcd
Returns: FontFace - Description of return value.

ParamTypeDescription
ttfPathstringfont path
fontnumbersize

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

ParamTypeDescription
xnumberstart point on x axis
ynumberstart point on y axis
x2numberend point on x axis
y2numberend point on y axis
colColorline color

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

Draw rect

Kind: instance method of Lcd

ParamTypeDescription
xnumberstart point on x axis
ynumberstart point on y axis
widthnumberrect width
heightnumberrect height
fillboolIf true rect is filled
colColorrect color

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

Draw circle

Kind: instance method of Lcd

ParamTypeDescription
xnumbermid point on x axis
ynumbermid point on y axis
rnumbercircle size
fillboolIf true circle is filled
colColorcircle color

lcd.pixel(x, y, col)

Draw pixel

Kind: instance method of Lcd

ParamTypeDescription
xnumberpoint on x axis
ynumberpoint on y axis
colColorpixel color

lcd.drawChar(x, y, char) ⇒ Rect

Draw character from 16 bit representation

Kind: instance method of Lcd

ParamTypeDescription
xnumberpoint on x axis
ynumberpoint on y axis
charnumberchar code

lcd.drawString(font, x, y) ⇒ Rect

Draw string from 8bit representation

Kind: instance method of Lcd
Returns: Rect - drawed coordinates

ParamTypeDescription
fontFontFaceFont to draw string
xnumberx position
ynumbery position

lcd.color(color)

Set default color to use

Kind: instance method of Lcd

ParamTypeDescription
colornumber0 is white, 1 is black, -1 is inversion of current state

Rect : Object

Rect object

Kind: global typedef
Properties

NameType
xMinnumber
yMinnumber
xMaxnumber
yMaxnumber

FontFace : Object

FT_Face object wrapper

Kind: global typedef
Properties

NameTypeDescription
sizenumberfont size
heightnumberfont size in px

EpdSize : Object

EpdSize object

Kind: global typedef
Properties

NameTypeDescription
widthnumberDisplay width in px
heightnumberDisplay height in px

Color : number

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

Kind: global typedef