Coder Social home page Coder Social logo

python_lcd's Issues

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!")

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

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..

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.

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

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 ?

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!

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

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.

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

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

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.

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

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?

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. 😀

Pin assignment

Hi

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

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.