GithubHelp home page GithubHelp logo

patryk27 / pwr-hd44780 Goto Github PK

View Code? Open in Web Editor NEW
17.0 5.0 2.0 49 KB

A driver for HD44780 LCDs, with support for GPIO and I2C - created for use with Raspberry Pi

License: MIT License

Rust 100.00%
rust hd44780 raspberry driver lcd

pwr-hd44780's Introduction

pwr-hd44780

Version

Documentation

A Rust crate allowing to communicate with the HD44780 LCDs.

What buses are supported?

  • 4-bit GPIO bus (thanks to the rppal library),
  • I2C bus (thanks to the rust-i2cdev library).

Would you mind showing me some code?

Sure, pal:

extern crate pwr_hd44780;

use pwr_hd44780::Hd44780;

fn main() {
    run().unwrap();
}

fn run() -> Result<(), Box<std::error::Error>> {
    // create the LCD's bus instance;
    // use device at address 0x27 on the first I2C bus
    let lcd_bus = pwr_hd44780::I2CBus::new(
        "/dev/i2c-1", 0x27,
    )?;

    // create the direct LCD's instance;
    // use bus created before and assume LCD's width x height = 20 x 4
    let mut lcd = pwr_hd44780::DirectLcd::new(
        Box::new(lcd_bus),
        20, 4,
    )?;

    // finally - print our text
    lcd.clear()?;
    lcd.print("Hello World! :-)")?;

    Ok(())
}

For more examples, take a dive into the examples directory.

License

Copyright (c) 2018, Patryk Wychowaniec <[email protected]>.
Licensed under the MIT license.

pwr-hd44780's People

Contributors

patryk27 avatar pwychowaniec-polcode avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

asiamov icodein

pwr-hd44780's Issues

20x4 lcd oveflow

The overflow seems to be working wrongly for 20x4 LCDs. I have the following code:

let mut lcd = pwr_hd44780::DirectLcd::new(Box::new(lcd_bus), 20, 4)
    .expect("Error creating lcd instance");

But, when I print for example abcdefghijklmnopqrstuvxyz abcdefghijklmnopqrstuvxyz abcdefghijklmnopqrstuvxyz, it appears on my lcd as:

abcdefghijklmnopqrst
opqrstuvxyz abcdefgh
uvxyz abcdefghijklmn
ijklmnopqrstuvxyz

It is overflowing in the order of first line -> third line -> second line -> fourth line, instead of first line -> second line -> third line -> fourth line. What do I do?

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.