Code Monkey home page Code Monkey logo

liquidtwi2's Introduction

LiquidTWI2
==========

A lean, high speed I2C LCD Library for Arduino, which supports MCP23008 (Adafruit LCD Backpack) and MCP23017 (Adafruit RGB LCD Shield)

hacked by Sam C. Lin / http://www.lincomatic.com
from 
  LiquidTWI by Matt Falcon (FalconFour) / http://falconfour.com
  logic gleaned from Adafruit RGB LCD Shield library
  Panelolu2 support by Tony Lock / http://blog.think3dprint3d.com
  Panelolu2 integration by Robert F-C / https://github.com/buildrob
  enhancements by Nick Sayer / https://github.com/nsayer

Compatible with Adafruit I2C LCD backpack (MCP23008) and
Adafruit RGB LCD Shield (and optionally, Panelolu2)

For more information see 
 http://blog.lincomatic.com/?tag=LiquidTWI2
 http://forums.adafruit.com/viewtopic.php?f=19&t=21586
 Panelolu2 usage see
 http://blog.think3dprint3d.com/2012/12/mcp23017-i2c.html

  Version 1.2.7

  Changelog:

  * 1.2.7 / 20190624 SCL
  fixed row offset issue w/ 16x4 LCD per #15

  * 1.2.6 / 20140220 SCL
  added device detected guard to home() & buzz()

  * 1.2.5 / 20130725 SCL
  added LcdDetected() from Scott Rubin

  * 1.2.4 / 20130409 SCL
  buzz() fixes from buildrob

  * 1.2.3 / 20130322 SCL
  PANELOLU2 support cleanup and always enabled when MCP23017 by buildrob
  buzz() now works for Panucatt Viki as well

  * 1.2.2 / 20130120 SCL
  make setMCPType() a no-op when only one MCPxxxx defined instead
  of removing it

  * 1.2.1 / 20130102 SCL
  disable PANELOLU2 by default

  * 1.2.0 / 20130101 SCL
  added DETECT_DEVICE

  * 1.1.1 / 20121219 SCL
  added Tony Lock's Panelolu2 enhancements

  * 1.1.0 / 20121018 SCL
  use 8-bit GPIO for writing on MCP23017 for 25% speed increase
  with only 14 byte size increase

  * 1.0.0 / 20121016 SCL
  initial release

  Distributed with as free-will a license as is available given this code's long
  associative chain of licenses (LiquidCrystal -> Arduino -> Wiring -> ...?). Use
  it in any way you feel fit, profit or free, provided it fits in the licenses of
  its associated works.

  Installation:
  extract LiquidTWI2/ into <arduinosketchbook>/libraries/LiquidTWI2

  To use with Panelolu2
	lcd.setMCPType(LTI_TYPE_MCP23017);
    Panelolu2 only has encoder.. use PANELOLU_ENCODER_X bits instead of BUTTON_xxx

  Usage:
  Compatible with Arduino LiquidCrystal library except that setMCPType() MUST
  be called at least once before begin() is called

  // MCP23008 (Adafruit LCD Backpack)
  #include <Wire.h>
  #include <LiquidTWI2.h>
  LiquidTWI2 lcd(0x20);
  void setup() {
   lcd.setMCPType(LTI_TYPE_MCP23008); // must be called before begin()
   lcd.begin(16,2);
   lcd.setBacklight(HIGH); // only supports HIGH or LOW
  }
  void loop() {
   lcd.print("Hello World!");
   delay(500);
   lcd.clear();
   delay(500);
  }

  // MCP23017 (Adafruit RGB LCD Shield)
  #include <Wire.h>
  #include <LiquidTWI2.h>
  LiquidTWI2 lcd(0x20);
  void setup() {
   lcd.setMCPType(LTI_TYPE_MCP23017); // must be called before begin()
   lcd.begin(16,2);
   lcd.setBacklight(WHITE); // see LiquidTWI2.h for color options
  }
  void loop() {
   lcd.print("Hello World!");
   delay(500);
   lcd.clear();
   delay(500);
   uint8_t btns = lcd.readButtons();
  }

  If you change the i2c address of the board, set "lcd(0x20)" to your new 3-bit
  address.
  If you have more than a 16x2 LCD, change "lcd.begin(16,2)" to reflect the
  columns and rows of your LCD.

  Normally, the code will hang if the device is not detected at the specified
  i2c address.  If you want to compile your code for an optionally installed
  LCD, call the constructor with 2nd parameter deviceDetect=1. E.g:
     LiquidTWI2 lcd(0x20,1);
  When enabled, if the device is not detected at the specified address when
  begin() is called, then the rest of the function calls become NOOPs

  Note that the library can switch modes at runtime. Simply call setMCPType(),
  followed by begin().
  This allows you to create a firmware which is compatible with either kind
  of LCD module, and select the type from EEPROM.

  For memory-constrained projects, disable the unnecessary support by
  commenting out the corresponding MCP230xx in LiquidTWI2.h, and DETECT_DEVICE

liquidtwi2's People

Contributors

arhoads avatar chepo92 avatar ivankravets avatar lincomatic avatar nsayer avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liquidtwi2's Issues

Row Offset for 16x4 lcd is wrong

Hello,

the row offset in "LiquidTWI2.cpp" line 347 is wrong.

int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };

when you compile it with a 16x4 LCD you get this: (im just filling all the characters with 0-15 in hex)
photo_2019-06-23_22-40-32

when you change the row offset to
int row_offsets[] = { 0x00, 0x40, 0x10, 0x50 };
you get this like expected:
photo_2019-06-23_22-40-38

i think noone has found this bug yet, because i am using a 16x4 LCD instead of a 16x2 LCD.

Examples need minor updates

The examples included are somewhat out of date and could use some minor rework to be compatible with typical boards.

Update to the .ino format (is anyone expecting to use this library with a pre-1.0 IDE?)

The comments in both examples mention the pins to wire up, but that varies by board... per http://arduino.cc/en/Reference/Wire:

  Board      I2C / TWI pins
  ---------  --------------------------
  Uno, Yun   A4 (SDA), A5 (SCL)
  Mega2560   20 (SDA), 21 (SCL)
  Leonardo    2 (SDA),  3 (SCL)
  Due        20 (SDA), 21 (SCL)

(Purposely omitting SDA1/SCL1 on the Due because they are non-trivial to use IMHO)

Also, the default address would be better to be something like 0x20 (which is a typical default base address.

Doesn't compile on Arduino 1.0.0

Line 193 of LiquidTWI2.cpp needs to change from

#if defined(ARDUINO) && (ARDUINO >= 100)

to

#if defined(ARDUINO) && (ARDUINO > 100)

as the extra parameter to twi_writeTo seems to have been added at 1.0.1.

LiquidTWI2::home is missing a DETECT_DEVICE guard

Browsing through LiquidTWI2.cpp I noticed that the LiquidTWI2::home function has no guard code for DETECT_DEVICE. It calls LiquidTWI2::command directly and could be a cause for hanging if a display is not present.

LiquidTWI2::buzz is missing a DETECT_DEVICE guard

Browsing through LiquidTWI2.cpp I noticed that the LiquidTWI2::buzz function has no guard code for DETECT_DEVICE. It calls Wire library functions directly and could be a cause for hanging if a display is not present.

Unable to compile example with library for Panelolu and MCP23017 configuration

Issue
Unable to compile example with Library for Panelolu and MCP23017 configuration

Files
HelloWorld_i2c.pde
LiquidTWI2.cpp
LiquidTWI2.h

Settings
LiquidTWI2.h

define MCP23017 // Adafruit RGB LCD

Error
Unknown type mcpType

Suggestion correction

if defined(MCP23017) || defined(MCP23008) // SC changed from &&

void setMCPType(uint8_t mcptype) { _mcpType = mcptype; }

endif //defined(MCP23017)&&defined(MCP23008)

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.