Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Facing runtime issue with Adafruit characterlcd python libra
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Facing runtime issue with Adafruit characterlcd python libra

by erpgme on Sun Sep 06, 2020 8:35 am

Respected Forum Members,

I am facing issue wrt using Adafruit characterlcd library which I am using with a 16x2 LCD wired to my Raspberry Pi 4. I am using Python3 for running the following program :

import threading, queue
import adafruit_character_lcd.character_lcd as characterlcd
import board
import digitalio

lcd_columns = 16
lcd_rows = 2
lcd_line_3 = ""

lcd_rs = digitalio.DigitalInOut(board.D22)
lcd_en = digitalio.DigitalInOut(board.D17)
lcd_d4 = digitalio.DigitalInOut(board.D25)
lcd_d5 = digitalio.DigitalInOut(board.D24)
lcd_d6 = digitalio.DigitalInOut(board.D23)
lcd_d7 = digitalio.DigitalInOut(board.D18)

# Initialise the lcd class
lcd = characterlcd.Character_LCD_Mono(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows)

q = queue.Queue()

def worker():
while True:
item = q.get()
lcd.message(item)
q.task_done()

# turn-on the worker thread
threading.Thread(target=worker, daemon=True).start()

q.put("Hello")
q.put("World")
q.put("How")
q.put("are")
q.put("you")

print('All task requests sent\n', end='')

# block until all tasks are done
q.join()
print('All work completed')

For which I am getting error with nothing displayed on LCD :

All task requests sent
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "queu.py", line 25, in worker
lcd.message(item)
TypeError: 'NoneType' object is not callable

The same lcd.message when called in the main thread (and not in thread function), is working fine.

How to resolve this issue ?

Thanks in advance.

erpgme
 
Posts: 1
Joined: Sun Sep 06, 2020 7:52 am

Please be positive and constructive with your questions and comments.