Coder Social home page Coder Social logo

python_lcd's Introduction

lcd_api and i2c_lcd

Python code for talking to HD44780 compatible character based dot matrix LCDs.

Other ports

This code is synchronous. Peter Hinch put together an async driver for the HD77480 over here.

This library is based off of a C version that I wrote, which can be found here (also look for files in the same directory which start with lcd).

Nic created a C# port of this library which can be found here.

Communicating with the LCD

You can communicate with the LCDs using either 4 or 8 GPIO pins.

Alternatively, the I2C classes implement 8-bit GPIO expander boards PCF8574 and MCP23008 which reduces the number of required GPIO pins to two (SCL, SDA). The boards usually mount behind the LCDs and are commonly called "backpacks".

The most commonly used display is a "1602" or "16x2", which features 16 columns and 2 rows of characters. There are also other LCDs using the same HD44780 controller. eg. 8x2, 16x1, 16x4, 20x2, 20x4, 40x1, 40x2. Each come in various backlight and pixel colours.

There are also variants of the code for MicroPython. All of the files which start with pyb_ were tested on the pyboard. Files starting with esp8266_ were tested on a WeMos D1 Mini. Files starting with nodemcu_ were tested on a NodeMCU development board. The files containing adafruit_lcd were tested on an Adafruit I2C / SPI character LCD backpack

Installing CPython

Cpython 3.x

# python smbus needs dev headers
sudo apt update
sudo apt install python3-dev
python -m pip install smbus  # optional, good test before installing library
python -m pip install -e .

Cpython 2.7

# python smbus needs dev headers
sudo apt update
sudo apt install python2-dev
python -m pip install smbus  # optional, good test before installing library
python -m pip install -e .

Tutorial

Giuseppe Cassibba wrote up a tutorial which demonstrates connecting an I2C LCD to a Raspberry Pi Pico.

Files

File Description
circuitpython_i2c_lcd.py CircuitPython PCF8574 I2C backpack
circuitpython_i2c_lcd_test.py CircuitPython test using PCF8574 backpack
esp32_gpio_lcd.py ESP32 GPIO HAL
esp32_gpio_lcd_test.py ESP32 test using 4-bit GPIO
esp8266_i2c_lcd.py ESP8266 PCF8574 I2C HAL
esp8266_i2c_lcd_test.py ESP8266 test using PCF8574 backpack
i2c_lcd.py Linux PCF8574 I2C HAL
i2c_lcd_test.py Linux test using PCF8574 backpack
lcd_api.py Core logic
machine_i2c_lcd.py Pyboard machine.I2C PCF8574 backpack
machine_i2c_lcd_test.py Test for machine.I2C PCF8574 backpack
nodemcu_gpio_lcd.py NodeMCU GPIO HAL
nodemcu_gpio_lcd_test.py NodeMCU test using 4-bit GPIO
onion_lcd_gpio.py Onion GPIO HAL
onion_lcd_gpio.py Ontion test using 4 bit GPIO
pyb_gpio_lcd.py Pyboard GPIO HAL
pyb_gpio_lcd_test8.py Pyboard test using 8-bit GPIO
pyb_gpio_lcd_test.py Pyboard test using 4-bit GPIO
pyb_i2c_adafruit_lcd.py Pyboard MCP23008 I2C HAL
pyb_i2c_adafruit_lcd_test.py Pyboard test using Adafruit backpack
pyb_i2c_grove_rgb_lcd.py Pyboard Grove I2C RGB LCD HAL
pyb_i2c_grove_rgb_lcd_test.py Pyboard test using Grove I2C RGB LCD
pyb_i2c_lcd.py Pyboard PCF8574 I2C HAL
pyb_i2c_lcd_test.py Pyboard test using PCF8574 backpack

The files which end in _test.py are examples which show how the corresponding file is used.

i2c_lcd.py was tested on a BeagleBone Black using a 2 x 16 LCD with an I2C module similar to this one.

To install on your BBB:

git clone https://github.com/dhylands/python_lcd.git
cd python_lcd
sudo pip install -e .

And to test:

sudo lcd/i2c_lcd_test.py

Since my LCD was a 5v device, I used a level converter to convert from BBB's 3.3v to the LCD's 5v.

I put together some [photos here] (https://picasaweb.google.com/115853040635737241756/PythonI2CLCD?authkey=Gv1sRgCLyZoJ3_uPjiXA)

Coming from the BeagleBone Black the wire colors are:

Color Pin Name
Black P9-1 GND
Red P9-3 3.3v
Orange P9-7 SYS_5V
Yellow P9-19 SCL
White P9-20 SDA

The photo shows Orange connected to P9-5. I discovered that P9-7 is controlled by the onboard voltage regulators, so when you do a "sudo poweroff" then SYS_5V drops to 0v when the BBB is powered off. P9-5 (VDD_5V) remains at 5v after the BBB is powered off.

And the colors going to the LCD are:

Color Name
Black GND
Red 5v
White SDA
Yellow SCL

I used a SparkFun level shifter (this particular model is no longer available).

Some examples of other level shifters which could be used:

I found a circuit mentioned in this Google+ post and thought I would include it here, since it's related to the LCDs these drivers interface with. LCD Schematic

The circuit allows for digitally controlling the contrast via PWM and also controlling the backlight brightness via PWM.

Custom characters

The HD44780 displays come with 3 possible CGROM font sets. Japanese, European and Custom. Test which you have using:

lcd.putchar(chr(247))

If you see Pi (π), you have a Japanese A00 ROM. If you see a division sign (÷), you have a European A02 ROM.

Characters match ASCII characters in range 32-127 (0x20-0x7F) with a few exceptions:

  • 0x5C is a Yen symbol instead of backslash
  • 0x7E is a right arrow instead of tilde
  • 0x7F is a left arrow instead of delete

Only the ASCII characters are common between the two ROMs 32-125 (0x20-0x7D) Refer to the HD44780 datasheet for the table of characters.

The first 8 characters are CGRAM or character-generator RAM. You can specify any pattern for these characters.

To design a custom character, start by drawing a 5x8 grid. I use dots and hashes as it's a lot easier to read than 1s and 0s. Draw pixels by replacing dots with hashes. Where possible, leave the bottom row unpopulated as it may be occupied by the underline cursor.

Happy Face (where .=0, #=1)
.....
.#.#.
.....
..#..
.....
#...#
.###.
.....

To convert this into a bytearray for the custom_char() method, you need to add each row of 5 pixels to least significant bits of a byte (the right side).

Happy Face (where .=0, #=1)
..... == 0b00000 == 0x00
.#.#. == 0b01010 == 0x0A
..... == 0b00000 == 0x00
..#.. == 0b00100 == 0x04
..... == 0b00000 == 0x00
#...# == 0b10001 == 0x11
.###. == 0b01110 == 0x0E
..... == 0b00000 == 0x00

Next, add each byte from top to bottom to a new byte array and pass to custom_char() with location 0-7.

happy_face = bytearray([0x00,0x0A,0x00,0x04,0x00,0x11,0x0E,0x00])
lcd.custom_char(0, happy_face)

custom_char() does not print anything to the display. It only updates the CGRAM. To display the custom characters, use putchar() with chr(0) through chr(7).

lcd.putchar(chr(0))
lcd.putchar(b'\x00')

Characters are displayed by reference. Once you have printed a custom character to the lcd, you can overwrite the custom character and all visible instances will also update. This is useful for drawing animations and graphs, as you only need to print the characters once and then can simply modify the custom characters in CGRAM.

Examples:

# smiley faces
happy = bytearray([0x00,0x0A,0x00,0x04,0x00,0x11,0x0E,0x00])
sad = bytearray([0x00,0x0A,0x00,0x04,0x00,0x0E,0x11,0x00])
grin = bytearray([0x00,0x00,0x0A,0x00,0x1F,0x11,0x0E,0x00])
shock = bytearray([0x0A,0x00,0x04,0x00,0x0E,0x11,0x11,0x0E])
meh = bytearray([0x00,0x0A,0x00,0x04,0x00,0x1F,0x00,0x00])
angry = bytearray([0x11,0x0A,0x11,0x04,0x00,0x0E,0x11,0x00])
tongue = bytearray([0x00,0x0A,0x00,0x04,0x00,0x1F,0x05,0x02])

# icons
bell = bytearray([0x04,0x0e,0x0e,0x0e,0x1f,0x00,0x04,0x00])
note = bytearray([0x02,0x03,0x02,0x0e,0x1e,0x0c,0x00,0x00])
clock = bytearray([0x00,0x0e,0x15,0x17,0x11,0x0e,0x00,0x00])
heart = bytearray([0x00,0x0a,0x1f,0x1f,0x0e,0x04,0x00,0x00])
duck = bytearray([0x00,0x0c,0x1d,0x0f,0x0f,0x06,0x00,0x00])
check = bytearray([0x00,0x01,0x03,0x16,0x1c,0x08,0x00,0x00])
cross = bytearray([0x00,0x1b,0x0e,0x04,0x0e,0x1b,0x00,0x00])
retarrow = bytearray([0x01,0x01,0x05,0x09,0x1f,0x08,0x04,0x00])

# battery icons
battery0 = bytearray([0x0E,0x1B,0x11,0x11,0x11,0x11,0x11,0x1F])  # 0% Empty
battery1 = bytearray([0x0E,0x1B,0x11,0x11,0x11,0x11,0x1F,0x1F])  # 16%
battery2 = bytearray([0x0E,0x1B,0x11,0x11,0x11,0x1F,0x1F,0x1F])  # 33%
battery3 = bytearray([0x0E,0x1B,0x11,0x11,0x1F,0x1F,0x1F,0x1F])  # 50%
battery4 = bytearray([0x0E,0x1B,0x11,0x1F,0x1F,0x1F,0x1F,0x1F])  # 66%
battery5 = bytearray([0x0E,0x1B,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F])  # 83%
battery6 = bytearray([0x0E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F])  # 100% Full
battery7 = bytearray([0x0E,0x1F,0x1B,0x1B,0x1B,0x1F,0x1B,0x1F])  # ! Error

An online editor for creating customer characters is available online at https://clach04.github.io/lcdchargen/ (source code available from https://github.com/clach04/lcdchargen/tree/python)

python_lcd's People

Contributors

clach04 avatar darylknowles avatar davehylands avatar demestav avatar dhylands avatar freemansoft avatar mcauser avatar orbin avatar petrkr avatar synapski avatar tarjanpeter 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  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

python_lcd's Issues

Pin assignment

Hi

Do you have some indication of the expected pin assignment between the PCF8574 and the LCD?

Need driver for chip SPLC780D1

Sorry for borther.
I want to use this function to drive LCM4004 module (based on daul SPLC780D1 chip) but it seems does not work as expected. For example, sometimes I got some wrong chars on screen and generally no changes on it.
The LCM4002 module also use this chip, could help me to give a look for this issue?

Document link:
http://www.vatronix.com/upload/LCD_Controller/splc780d1.pdf
Ebay link:
https://www.ebay.com/itm/404-40X4-4004-Character-LCD-Module-Display-Screen-LCM-SPLC780D-Controller/202481696942?hash=item2f24d980ae:m:m0y8ZYK7spyvF9zJLMZG6DQ:rk:1:pf:0

Unable to get 16x2 LCD working with STM32F401RE Nucleo

Hi Dave, I have been trying to implement your pyb_gpio_lcd.py for a 16x2 lcd on micropython with no success.

I am using stm32f401re nucleo.
4-bit mode (d4,d5,d6,d7)
rw has been grounded
rs and en have been tied to PC14 and PC15 respectively
PC2, PC3, PC4 and PC5 has been used for data line.
I have connected a 10K pot for contrast adjustment . all i could see is black boxes on the first row.

Please advise what am I missing.

BBB install error

Hello,
when I put sudo pip install -e . command I've become an error:

[sudo] password for kuba: 
The directory '/home/kuba/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kuba/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Obtaining file:///home/kuba/Dokumenty/nodemcu/python_lcd
Collecting smbus (from python-lcd==0.1.0)
  Could not find a version that satisfies the requirement smbus (from python-lcd==0.1.0) (from versions: )
No matching distribution found for smbus (from python-lcd==0.1.0)

what schould I do now to install the library?
Thank you for answer

add seeed studio Grove - 16x2 LCD support - any chance?

Hi

I currently have a few of these ....

https://wiki.seeedstudio.com/Grove-16x2_LCD_Series/

This seems to be based on a JDH1804 controller....

https://github.com/SeeedDocument/Grove-16x2_LCD_Series/raw/master/res/JDH_1804_Datasheet.pdf

i am guessing that this is why i cannot seem to make it work under circuit python with your wonderful library?

Is there any way you could add support for this controller please?

I hope you don't mind me asking?

Regards

Jason

One linefeed too many, in case the line is filled up to the last character (4x20 display) / CircuitPython Port

@dhylands
In a 4x20 display, if I fill the line to the last row, it skips the following line without replacement and the following line remains empty. This is independent of whether I put a \n at the end of the line or not.

If I fill the display only with 19 characters instead of the 20 possible characters, the line jump to the following line works.

Is this intentional or is it possible to turn it off?
Or am I doing something wrong?

Here is my code for testing

import board
import busio
from time import sleep, monotonic
from lcd.circuitpython_i2c_lcd import I2cLcd

# The PCF8574 has a jumper selectable address: 0x20 - 0x27
DEFAULT_I2C_ADDR = 0x26

def test_main():
    """Test function for verifying basic functionality."""
    print("Running test_main")
    i2c = busio.I2C(board.SCL, board.SDA)

    # circuitpython seems to require locking the i2c bus
    while i2c.try_lock():
        pass

    # 2 lines, 16 characters per line
    #lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16)

    #4 lines, 20 characters per line
    lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 4, 20)

    while True:
        lcd.clear()
        lcd.move_to(0, 0)
        lcd.putstr("It works!\nSecond line\n")
        print("It works!\nSecond line\n")
        sleep(2)
        lcd.clear()
        lcd.move_to(0, 0)
        lcd.putstr("12345678901234567890\n123xxxx890123yyyy890\n")
        print("12345678901234567890\n123xxxx890123yyyy890\n")
        sleep(2)
        print("Ende\n")

#if __name__ == "__main__":
test_main()

rp2 PIO variant

Hi Dave. This is a non-issue. I have adapted the GPIO version of the driver for the RP2040 using PIO. Just as an exercise. I added the ZIP package. If one takes care to wire the RW pin to GND before applying power, there is no risk of damage, since then all LCD pins are used as input.
I have tested it with an LCD in four bit mode only, and the 8 bit mode just with a logic analyzer.

print backslash to LCD

Hi.

I'm simply trying to create a spinning line effect with these symbols: | / - \

I saw in the docs that it was a few exceptions

0x5C is a Yen symbol instead of backslash

This is the code I'm using:

# write a command to lcd
def lcd_write(self, cmd, mode=0):
	self.lcd_write_four_bits(mode | (cmd & 0xF0))
	self.lcd_write_four_bits(mode | ((cmd << 4) & 0xF0))
	
# put string function
def lcd_display_string(self, string, line):
	if line == 1:
		self.lcd_write(0x80)
	if line == 2:
		self.lcd_write(0xC0)
	if line == 3:
		self.lcd_write(0x94)
	if line == 4:
		self.lcd_write(0xD4)

	for char in string:
		self.lcd_write(ord(char), Rs)

string = "\\"
lcd.lcd_display_string(string, 1)

Are there any ways to print a backslash?

How to add extra commands?

HI

novice programmer here so please excuse the stupid question

Looking through the lcd_api.py code i notice there seem to be some command codes that have not had any functions defined to use them ( for example LCD_MOVE_DISP) .

I have tried to define functions to implement these but so far zero success

any advice would be gratefully received - i have read the data sheet for the controller but lack the ability to translate the information contained into working code it seems

regards

J

LCD hangs at initialization

Hello! First of all, many thanks for your effort in bringing the LCD to us.

I am using Zerynth and its flavor of Python. I took your GpioLcd.py, and LcdApi.py, and went through them to change the machine.py references to the HAL of Zerynth. Eventually I got all the changes done and I got your test file to compile fine.

But there seems to be an issue with the

lcd = GpioLcd(rs_pin=2,
enable_pin=14,
d4_pin=17,
d5_pin=18,
d6_pin=21,
d7_pin=22,
num_lines=2, num_columns=16)

part. If I comment this out, execution goes on, but with this in, the execution hangs at this line.

I have wired everything as per your instructions, except the Enable to G11, as I don't see one on the ESP32 NodeMCU which I run. Therefore I have it on G14. I have also adjusted for my LCD1602 with just two lines and 16 columns. I see the 16 rectangles on the first line, when I connect the wires, so it's working technically, and I have tested in on an Arduino Nano, and got it running.

Another little change is that since I don't have a pot handy, I connected the V0 pin on the 1602 to ground on the ESP32.

I have a nagging feeling I am asking something terribly obvious, but I hope you have time to consider this question.

Many thanks!

IOError: File not found

So I got this error while trying to use your lib.
I suppose this is because Beaglebone black doesn't have device tree enabled.
Do you know how to solve it?

Cheers
Paul

debian@arm:~/python_lcd$ sudo python lcd/i2c_lcd.py
Traceback (most recent call last):
  File "lcd/i2c_lcd.py", line 125, in <module>
    test_main()
  File "lcd/i2c_lcd.py", line 93, in test_main
    lcd = I2cLcd(1, 0x27, 2, 16)
  File "lcd/i2c_lcd.py", line 24, in __init__
    self.bus = smbus.SMBus(port)
IOError: [Errno 2] No such file or directory

Could you please add a new class to i2c_lcd.py?

Request
So while using your library I created a simple class which I added to the /lcd/i2c_lcd.py file. The only purpose is to organize the main file by using one library instead of two. I am here to ask if you could add the class below to the bottom of the /lcd/i2c_lcd.py file. Thanks.

Class

class I2C_LCD():
    def __init__(self, SDA_PIN, SCL_PIN, ROWS, COLS, FREQ):
        self.SDA_PIN = SDA_PIN
        self.SCL_PIN = SCL_PIN
        
        self.I2C_NUM_ROWS = ROWS
        self.I2C_NUM_COLS = COLS
        
        self.FREQ = FREQ
        
        self.i2c = SoftI2C(sda=Pin(self.SDA_PIN), scl=Pin(self.SCL_PIN), freq=self.FREQ)
        self.I2C_ADDR = int(hex(self.i2c.scan()[0]))  # Finds the unique 7-bit I2C address
        self.lcd = I2cLcd(self.i2c, self.I2C_ADDR, self.I2C_NUM_ROWS, self.I2C_NUM_COLS)

Example/Main.py File

from i2c_lcd import I2C_LCD

disp1 = I2C_LCD(
    SDA_PIN = 0,
    SCL_PIN = 1,
    ROWS    = 2,
    COLS    = 16,
    FREQ    = 400_000
)

disp2 = I2C_LCD(
    SDA_PIN = 4,
    SCL_PIN = 5,
    ROWS    = 2,
    COLS    = 16,
    FREQ    = 400_000
)

disp1.lcd.putstr(f"Hello, World!")
disp2.lcd.putstr(f"Hello, Again!")

Unable to print on LCD

Hello,
I am a newbie in Micropython. I am working on STM32F407Discovery board. I wanted to display character on LCD (16x2) display. I tried to use the module given by you, but its not displaying any character on LCD.

Below is code ..

from pyb import Pin, delay, millis
from pyb_gpio_lcd import GpioLcd

#Configuring LCD Pins
rs = pyb.Pin('PB1',Pin.OUT_PP,Pin.PULL_UP)
rw = pyb.Pin('PB4', Pin.OUT_PP,Pin.PULL_UP)
en = pyb.Pin('PB5', Pin.OUT_PP,Pin.PULL_UP)
d0 = pyb.Pin('PE8', Pin.OUT_PP,Pin.PULL_DOWN)
d1 = pyb.Pin('PE9', Pin.OUT_PP,Pin.PULL_DOWN)
d2 = pyb.Pin('PE10', Pin.OUT_PP,Pin.PULL_DOWN)
d3 = pyb.Pin('PE11', Pin.OUT_PP,Pin.PULL_DOWN)
d4 = pyb.Pin('PE12', Pin.OUT_PP,Pin.PULL_DOWN)
d5 = pyb.Pin('PE13', Pin.OUT_PP,Pin.PULL_DOWN)
d6 = pyb.Pin('PE14', Pin.OUT_PP,Pin.PULL_DOWN)
d7 = pyb.Pin('PE15', Pin.OUT_PP,Pin.PULL_DOWN)

def test_main():
"""Test function for verifying basic functionality."""
print("Running test_main")
lcd = GpioLcd(rs,en,d0,d1,d2,d3,d4,d5,d6,d7,2,16)
lcd.putstr("It Works!\nSecond Line")
delay(3000)
lcd.clear()
count = 0
while True:
lcd.move_to(0, 0)
lcd.putstr("%7d" % (millis() // 1000))
delay(1000)
count += 1

I have initalised the LCD pins correctly and the code is getting executed properly, still i am unable to understand why nothing gets printed on LCD. Can anyone help me in the above code and how to implement on STM32F407disc board.

Hoping for some quick help..

putchar() can’t display custom chars

I have an application which drives a 20x4 LCD display on a RPi Pico. I have 6 custom characters which I need to display occasionally. However, when I try to send a number between 0 & 5 via putchar() I get an error at line 147 in lcd_api.py

On investigation I had to modify the code at line 147 as follows:

original code:

self.hal_write_data(ord(char))

which I moded to:

if type(char) is int:
    self.hal_write_data(char)
else:
    self.hal_write_data(ord(char))

This successfully allowed the api to display my custom chars but I have no idea if it would break other applications.

I guess it would be possible to move the test for int to the calling code and call hal_write_data() if test returns True. That somehow offends my OCD and wouldn’t advance the LCD cursor. 😀

Reduce code size and memory footprint

On the basis of the code here which I gratefully took as a starting point I derived a driver (I2C) which has reduced code size and memory footprint, while somewhat improving functionality. It is here.
Memory consumption went down from 4896 to 1616 bytes.
This was achieved by combining functions and replacing constant variables with their values.
The new version also should be easier for new users, as it is only one file, which probably should run on many platforms.
I would be happy to provide a set of (or a combined) pull request, if you are interested (thx for feedback here).
The same for a version for other interfaces than I2C and a more universal test script.

Unable to print in LCD - GPIO

Hello , i am trying to learn micropython and I got the board NEW NodeMcu Lua ESP8266 CH340G ESP-12E Wireless WIFI Internet Development Board from ebay.

I already completed some practices and now i'm trying to display information in LCD 1602A with GPIO pins but can not. only black squares.

i loaded esp8266-20190529-v1.11 With NodeMCU-PyFlasher-4.0-x64

blob:https://web.whatsapp.com/883eb399-9f53-4f52-8023-40e25437819a
image

Can i get some help ?

Broken CPython support

Thanks for making this library available! From reading through the docs/code looks like the intent is support both CPython and MicroPython?

I just tried this on my SBC with CPython (GPIO I²C port expander (using a PCF8574) to a Hitachi HD44780 controller) and got errors in the sleep code. It looks like this is micropython specific?

I have a quick hack so I'm up and running, but not sure what direction to take here for final fix:

(py38) pi@rock64lcd:~/py/python_lcd$ git diff
diff --git a/lcd/lcd_api.py b/lcd/lcd_api.py
index 61945d5..928c75c 100644
--- a/lcd/lcd_api.py
+++ b/lcd/lcd_api.py
@@ -205,4 +205,5 @@ class LcdApi:

     def hal_sleep_us(self, usecs):
         """Sleep for some time (given in microseconds)."""
-        time.sleep_us(usecs)
+        #time.sleep_us(usecs)  # appears to be a micropython specific function
+        time.sleep(usecs / 1000000)

My instinct is to support CPython time.sleep first and only use time.sleep_us if micropython has no support for it. I'm unclear on the micropython support though :(

We could monkey patch in a sleep_us but it feels a bit dirty.

Thoughts before I hack in a monkey patch and open a PR?

PyCom WiPy 3 with 20x4 LCD

Hi, I have an Adafruit 20x4 Display (https://www.adafruit.com/product/499) and I'm trying to hook it up to a PyCom WiPy 3. However, I don't think the WiPy uses the standard GPIO pins used by you libraries. I've been trying to use the esp32_gpio_lcd.py library but so far I can't get it to do anything. Is there a working example for this board or am I missing something obvious.

When I run the esp32_gpio_lcd_test.py it throws the following errors:

Running test_main
Traceback (most recent call last):
  File "<stdin>", line 58, in <module>
  File "<stdin>", line 41, in test_main
ValueError: invalid argument(s) value

Putting this code on my Nodemcu V3

I am a newbie and am running EsPy V1.0.07 on Win 8 with a Nodemcu V3. After a long struggle with moving around import statements I finally got a library for the PCF8574 working. I am now trying your I2C LCD stuff but am unsure as to how to get the code to run. When I run esp8266_i2C_lcd_test.py I get:

Running test_main
Traceback (most recent call last):
  File "<stdin>", line 47, in <module>
  File "<stdin>", line 15, in test_main
  File "esp8266_i2c_lcd.py", line 26, in __init__
OSError: [Errno 19] ENODEV

I know that it must be some newbie issue so I would appreciate your help.

Regards
Paul

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.