lcdjs

Write stuff to your LCD device

npm install lcdjs
15 downloads in the last week
29 downloads in the last month
   __       __  _   
  / /______/ / (_)__
 / / __/ _  / / (_-<
/_/\__/\_,_/_/ /___/
          |___/

A much more worked out lib is lcd by @fivdi

Provides 4 functions for a nodejs-raspi-lcd arrangment. By now it works with a 20x4 Hitachi compatible LCD.

I widely followed the blog post 20x4 lcd module control using python

The code below lib/lcd.js is a nodejs rewrite. THX to Matt Hawkins

The raspi pins are controlled by rpio written by jperkin. THX to him too.

Infrastructure for configuring other lcd-types will be provided if needed. Don't hesitate, open a issue on github

provides

  • lcd.setup(callback) sets the rasp pins as they should be
  • lcd.ini(callback) initializes the lcd
  • lcd.write(string, callback) writes a string to the current line
  • lcd.switchline(lineNumber, callback) switches the current line

usage example

this makes your lcd device writable over http

#!/usr/bin/env node

var port   = 80,
    lcd    = require("lcdjs"),
    drest  = require("drest"),
    router = drest.createRouter(80,"0.0.0.0"),
    api    = {
        line: {
            write : function (handler) {
                var lineNumber = parseInt(handler.path.pop(),10) -1,
                    txt = unescape(handler.query.txt);
    console.log(lineNumber)
    console.log(txt)

    lcd.switchline(lineNumber,
        function(){
            setTimeout(function(){ 
                lcd.write(txt);
                    },100)                       
                })


                    handler.respond("<h1>wrote" +txt+"</h1>");
}
    }
        }    


        lcd.setup(lcd.ini);

router.addRoute(
    {
        method:"get",
        path:"line/{number}",
        action:api.line.write
    }
);
npm loves you