Giter Club home page Giter Club logo

liquid_crystal_i2c_avr's Introduction

Liquid Crystal I2C library for AVR

Port of Arduino Liquid Crystal I2C library for HD44780 (or a compatible) displays from Frank de Brabander (https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library) for ATmega Controller (e.g. 328P).

Getting Started

Copy both liquid_crystal_i2c.c and liquid_crystal_i2c.h to your project and just start using it. Note: this library uses custom I2C AVR implementation (cheprogrammer/i2c_avr). It is easy to get rid of this library and use your own I2C routine.

Example of usage

At the begining of programm initialize your i2c peripheral and call the Liquid Crystal I2C initialization routine by using the following method:

lq_init(0x27, 20, 4, LCD_5x8DOTS);

This function accepts I2C shield address for LCD display, number of columns, rows and dot size (defined LCD_5x8DOTS, LCD_5x10DOTS). After performing all initialization routine, this function returns instance of LiquidCrystalDevice_t structure. This structure should be stored somewhere in programm because it contains required information for evaluating future operations.

Here is the definition of this structure:

typedef struct LiquidCrystalDevice_t {
	uint8_t Address;
	uint8_t Columns;
	uint8_t Rows;
	uint8_t Backlight;
	uint8_t DisplayFunction;
	uint8_t DisplayControl;
	uint8_t DisplayMode;
} LiquidCrystalDevice_t;

Here is the example of initialization and printing some text:

LiquidCrystalDevice_t device = lq_init(0x27, 20, 4, LCD_5x8DOTS); // intialize 4-lines display

lq_turnOnBacklight(&device); // simply turning on the backlight

lq_print(&device, "Hello world!");
lq_setCursor(&device, 1, 0); // moving cursor to the next line
lq_print(&device, "How are you?");

I2C Error handling

Current version of library does not support I2C error handling. It will be added in the future (maybe).

License

This project is licensed under the MIT License - see the LICENSE.md file for details

liquid_crystal_i2c_avr's People

Contributors

denisgoriachev avatar

Stargazers

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

Watchers

 avatar  avatar

liquid_crystal_i2c_avr's Issues

Error compiling

Hi denisgoriachev,
thank you so much for your library. It is very great. But when I follow your instructions, I get this error(s).

  1. I open Arduino IDE and start a new project
  2. I copied all your file(s) (liquid_crystal_i2c.h, liquid_crystal_i2c.c, i2c_master.h, i2c_master.c)
  3. I write a code like this, please correct if I wrong. (https://pastebin.com/raw/1agAgctL)

#define F_CPU 160000000 // 16 MHz
#include <avr/io.h>
#include <util/delay.h>
#include "liquid_crystal_i2c.h"

int main(void) {
LiquidCrystalDevice_t device = lq_init(0x27, 20, 4, LCD_5x8DOTS); // intialize 4-lines display

lq_turnOnBacklight(&device); // simply turning on the backlight

lq_print(&device, "Hello world!");
lq_setCursor(&device, 1, 0); // moving cursor to the next line
lq_print(&device, "How are you?");
}

  1. Then it gave me this error(s) message:
    "Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"

sketch\liquid_crystal_i2c.c.o (symbol from plugin): In function `i2c_getErrorMessage':

(.text+0x0): multiple definition of `i2c_getErrorMessage'

sketch\i2c_master.c.o (symbol from plugin):(.text+0x0): first defined here

C:\Users**\AppData\Local\Temp\ccKOLEcc.ltrans0.ltrans.o: In function `main':

C:\Users**\Desktop\Test-i2c/Test-i2c.ino:9: undefined reference to `lq_init(unsigned char, unsigned char, unsigned char, unsigned char)'

C:\Users*\Desktop\Test-i2c/Test-i2c.ino:11: undefined reference to `lq_turnOnBacklight(LiquidCrystalDevice_t)'

C:\Users*\Desktop\Test-i2c/Test-i2c.ino:13: undefined reference to `lq_print(LiquidCrystalDevice_t, char*)'

C:\Users*\Desktop\Test-i2c/Test-i2c.ino:14: undefined reference to `lq_setCursor(LiquidCrystalDevice_t, unsigned char, unsigned char)'

C:\Users*\Desktop\Test-i2c/Test-i2c.ino:15: undefined reference to `lq_print(LiquidCrystalDevice_t, char*)'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino Uno."

So I wonder that maybe I miss-understand something in your instruction. Could you spot that for me?

Thank you so much. Have a nice day.

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.