GithubHelp home page GithubHelp logo

lcd2usb's Introduction

LCD2USB's Python Library

home: http://github.com/xyb/lcd2usb

PyPI: http://pypi.python.org/pypi/lcd2usb

Introduce

The LCD2USB's Python Library is a Pure-python wrapper for LCD2USB which provide a simple way to control your LCD2USB display device. LCD2USB is a open source/open hardware project to connect HD44780 based text LCD displays to various PCs via USB.

Usage

Connect a lcd2usb device is easy:

>>> from lcd2usb import LCD
>>> lcd = LCD()
>>> lcd.info()
Found LCD2USB device on bus 004 device 004.

Get lcd2usb firmware version:

>>> lcd.version
(1, 9)

Write something on the screen:

>>> lcd.write('Hello, LCD2USB!')

Clean screen and wirte some on the 2nd row:

>>> lcd.clear()
>>> lcd.goto(0, 1)
>>> lcd.write('Flying with PYTHON')

Or simpler:

>>> lcd.write('Flying with PYTHON', 0, 1)

Define a custom smile symbol and display it on the center of first row (on a 4x20 display):

>>> from lcd2usb import SMILE_SYMBOL
>>> lcd.define_char(0, SMILE_SYMBOL)
>>> lcd.write('\0', 9, 0)

That it!

If you need a quickly running test for your device, use this:

python -m lcd2usb

Requirements

Installation

Installation is done just as for any other Python library. Using the pip or easy_install command from setuptools is the easiest:

pip install lcd2usb

Or:

easy_install install lcd2usb

lcd2usb's People

Contributors

gazhay avatar r4clet avatar vpelletier avatar xyb avatar

Stargazers

 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

lcd2usb's Issues

big characters

Hi,
is there any way to show big characters in the lcd? and different symbols? Something like this:
imagen

Or this one:
imagen

And for write symbols like this?:
imagen

Thank you very much for your support!!

script to show info in lcd

Hi,
I´m using your SW combined with RPI-Monitor to read the data from a sensor and place it in my lcd.
I´ve bought this lcd http://www.lcdmodkit.com/lcd/U204FR-A2.html which is compatible with lcd2usb.

The script that I´m using is this:

import httplib, time, os, sys, json
from lcd2usb import LCD
lcd = LCD()

# class Process dedicated to process data get from Client
# and send information to LCD and console
class Process:
  # Process constructor
  def run(self, jsonString):
    # Parse data as json
    data = json.loads( jsonString )
    # Try to get data from json or return default value
    try:
      rpi_temperature = data['living_room_temp']
    except:
      rpi_temperature = "--.---"
    try:
      rpi_humidity = data['humidity']
    except:
      rpi_humidity = "--.--"
    # Construct string to be displayed on screens
    temperature= "Temperatura: %s C" % rpi_temperature
    humidity= "Humedad:     %s %%" % rpi_humidity
    lcd.clear()
    lcd.write('Sensor RPi-Monitor', 0, 0)
    lcd.write('temperature', 0, 2)
    lcd.write('humidity', 0, 3)
    # Also print string in console
    os.system("clear")
    print " RPi-Monitor "
    print
    print temperature
    print humidity
    print
    time.sleep(1)

# Class client design to work as web client and get information 
# from RPi-Monitor embedded web server
class Client:
  # Client constructor
  def __init__(self):
    # Create a Process object
    self.process = Process()

  def run(self):
    # Infinite loop
    while True:
     try:
       # Initiate a connection to RPi-Monitor embedded server
       connection = httplib.HTTPConnection("localhost", 8888)
       # Get the file dynamic.json
       connection.request("GET","/dynamic.json")
       # Get the server response
       response = connection.getresponse()
       if ( response.status == 200 ):
         # If response is OK, read data
         data = response.read()
         # Run process object on extracted data
         self.process.run(data)
       # Close the connection to RPi-Monitor embedded server
       connection.close()
     finally:
       # Wait 5 secondes before restarting the loop
       time.sleep(5)

# Main function
def main():
  try:
    # Create a Client object
    client = Client()
    # Run it
    client.run()
  except KeyboardInterrupt:
    # if Ctrl+C has been pressed
    # turn off the lcd backlight
    lcd.backlight(0); 
    # exit from the program 
    sys.exit(0)

# Execute main if the script is directly called
if __name__ == "__main__":
    main()

I can check that the part of the web client to get the information from web server is OK because I can see printed in console this:

RPi-Monitor

Temperatura: 26.9 C
Humedad: 33.4 %

But in the lcd I only get this lines:

Sensor RPI-Monitor

temperature
humidity

I should expect the same lines "Temperatura" and "Humedad" with your values as in console to be showed in the lcd... but it doesn´t work.

Could you help me please?

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.