Skip to content

EasyI2C is made for Singelboard Computers like BananaPi or RasberryPi. Supporting I2C-LCD; I2C-PN532 (RFID, NFC) [WIP]

License

Notifications You must be signed in to change notification settings

lucsoft-DevTeam/EasyI2C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EasyI2C

EasyI2C is made for Singelboard Computers like BananaPi or RasberryPi. Supporting I2C-LCD; I2C-PN532 (RFID, NFC) [WIP]

Its a Wrapper! Using: i2c-bus

Installation

npm i easyi2c

https://www.npmjs.com/package/easyi2c

Usage

var EasyI2C = require("easyi2c");

var i2c = new EasyI2C(2);

i2c.on("connectedDevice", e => {
    console.log(`${ e.fid} has connected to the I2C-Bus`); 
});
i2c.on("disconnectedDevice", e => {
    console.log(`${ e.fid} has has disconnected from the I2C-Bus`);
});
i2c.on("message", e => {
    console.log(`${ e.fid} has send: ${ e.text} (${ e.bytes} Bytes)`);
});
i2c.on("ready", () => {
    console.log("EasyI2C is ready!");
});

i2c.start();

LCD-Example

i2c.on("connectedDevice", e => {
    console.log(`${ e.fid} has connected to the I2C-Bus`);
    if(e.fid =="0x27") {
        lcd = i2c.LCD(e.id, 16,2);
        lcd.print("Hello World");
    } 
});

Syntax

lcd.print(String);
lcd.clear();
lcd.cursorFull();
lcd.cursorUnder();
lcd.setCursor(x:number,y:number);
lcd.home(); // => setCursor(0,0)
lcd.blink(boolen)
lcd.cursor(boolen);
lcd.setBacklight(boolen);
lcd.off();
lcd.on();

i2c.on(name, func);
i2c.LCD(address,cols,rows); //=> EasyLCD
i2c.start();
i2c.updateSpeed; // default 1000
i2c.devicelist;
i2c.devicelistjson(); get i2c.devicelist as json
i2c.write(address,String);
i2c.read(address,length); (length > response text)
i2c.sleep(ms);
i2c.request(address,text,length); // write + read (length > response text)
i2c.updateDeviceList(this) // dont use if you dont use i2c.start();

Notes

Using i2c-bus for communication

About

EasyI2C is made for Singelboard Computers like BananaPi or RasberryPi. Supporting I2C-LCD; I2C-PN532 (RFID, NFC) [WIP]

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published