Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

putchar() can’t display custom chars #43

Open
CptDangerous opened this issue Nov 24, 2022 · 1 comment
Open

putchar() can’t display custom chars #43

CptDangerous opened this issue Nov 24, 2022 · 1 comment

Comments

@CptDangerous
Copy link

CptDangerous commented Nov 24, 2022

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

@dhylands
Copy link
Owner

Instead of calling putchar(3) (which passes an int) you could call putchar('\x03') which passes in a char. Or you could also do: putchar(chr(3))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants