-
Notifications
You must be signed in to change notification settings - Fork 116
Custom characters #9
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
Conversation
lcd/lcd_api.py
Outdated
"""Writes a custom character to the LCD""" | ||
location &= 0x7 | ||
self.putchar(chr(location)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lcd.putchar(chr(location)) does the same thing as lcd.putcustom(location)
Do you think we still need putcustom ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only extra benefit is restricting to 0-7.
I'll scrap it with an amend.
It would be good to add mention of custom characters in the readme as well. |
I was thinking an /examples folder, with 20+ examples I'm porting across |
I'm also working on a SeeedStudio RGB LCD. Two I2C devices. One for the LCD and one for the backlight pwm driver. Separate PR coming shortly. |
That would be cool. Perhaps put a README.md in the examples folder which has a summary of the example. I really liked the picture you posted with the battery gauge. |
58f90bf
to
e71ab02
Compare
|
Sweet. For the examples, it would probably be good to arrange them so that they take the lcd object as a parameter. That way they could be used with I2C/GPIO etc without having to edit them. Perhaps something along the lines of say creating a borders.py example which contained: def border_example(lcd):
lcd.custom_char(0, bytearray([0x1F,0x10,0x17,0x14,0x14,0x14,0x14,0x14]))
... and then to actually use the example: >>> import border
>>> lcd = I2cLcd(i2c, 0x27, 4, 20)
>>> border.border_example(lcd) |
Custom characters are 5x8 pixels and can be created using a 8 byte bytearray, where the first element is the top row and last element is the bottom row of pixels. Least significant bit is the right edge pixel and only 5 bits of significance are used.
Side note: the characters are displayed from cg-ram by reference. Once you have printed a custom character to the screen, you can overwrite the custom character and all visible instances will also update. Useful for drawing animations and graphs.