Giter Site home page Giter Site logo

montymole / adafruit-i2c-lcd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fehmer/adafruit-i2c-lcd

0.0 3.0 0.0 171 KB

Node.js library using the Adafruit RGB 16x2 LCD+Keypad Kit on the Raspberry Pi

License: BSD 3-Clause "New" or "Revised" License

CoffeeScript 100.00%

adafruit-i2c-lcd's Introduction

Adafruit I2C LCD Plate

Node.js implementation for the Adafruit RGB 16x2 LCD+Keypad Kit for Raspberry Pi http://www.adafruit.com/products/1110

Usage

  1. read the i2c documentation how to setup your raspberry pi.
  2. add dependency using npm install adafruit-i2c-lcd --save
  3. copy the example (coffee or js) and run them using coffee or node. Maybe you have to run them as root.

coffeescript

LCDPLATE=require('adafruit-i2c-lcd').plate
lcd=new LCDPLATE  '/dev/i2c-1', 0x20

lcd.backlight lcd.colors.RED
lcd.message 'Hello World!'

javascript

var LCDPLATE, lcd;
LCDPLATE = require('adafruit-i2c-lcd').plate;
lcd = new LCDPLATE('/dev/i2c-1', 0x20);

lcd.backlight(lcd.colors.RED);
lcd.message('Hello World!');

API

LCDPLATE(device:String,address:Number,[pollInterval:Number])

Setting up a new LCDPLATE.

  • device: Device name, e.g. '/dev/i2c-1'
  • address: Address of the i2c panel, e.g. 0x20
  • pollInterval: optional. Set the poll interval for the buttons to x ms. Use pollInterval=-1 to disable polling. (Buttons will not work)

LCDPLATE.clear()

Clear the LCD, remove all text.

LCDPLATE.close()

Close the LCD plate. Use this to stop the polling.

LCDPLATE.backlight(color:Number)

Set the backlight of the LCD to the given color. You can use predefined colors from the LCDPLATE class:

LCDPLATE.colors = [OFF, RED, GREEN, BLUE, YELLOW, TEAL, VIOLET, WHITE, ON]

LCDPLATE.message(text:String)

Display the text on the LCD. Use \n as line feed. Only the first two lines will be sent to the display.

LCDPLATE.buttonState():Number

Returns the pressed buttons as a number. Use bitmasks to mask out the state of the desired button. See LCDPLATE.buttons for button values.

LCDPLATE.buttonName(val:Number):String

Returns the name, e.g. 'SELECT' to a button number. See LCDPLATE.buttons for button values.

Events

button_change

Fires if a button is pressed or released.

Parameters:

  • button: the button, See LCDPLATE.buttons for button values.

Example

lcd.on 'button_change', (button) ->
    lcd.clear()
	lcd.message 'Button changed:\n'+lcd.buttonName button

button_up

Fires if a button is released.

Parameters:

  • button: the button, See LCDPLATE.buttons for button values.

button_down

Fires if a button is pressed.

Parameters:

  • button: the button, See LCDPLATE.buttons for button values.

Licence

BSD

Based on the Adafruit's Raspberry-Pi Python Code Library

Here is a growing collection of libraries and example python scripts for controlling a variety of Adafruit electronics with a Raspberry Pi

In progress!

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Limor Fried, Kevin Townsend and Mikey Sklar for Adafruit Industries. BSD license, all text above must be included in any redistribution

To download, we suggest logging into your Pi with Internet accessibility and typing: git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.