adafruit / adafruit/Adafruit_CircuitPython_CharLCD
Row Offsets for 16x4 display.
- Dominant language
- Python
- Stars
- 76
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I am trying to use this library with a 16x4 character display. Looking at the code (snippet below) there are hardcoded offsets for the third and fourth rows, with the third row starting at ``0x14`` (20) and the fourth at ``0x54`` (84, 20 addresses along from the start of row 2).
https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/7cd74e9b757081064d5dde8ed04e93db403d09f6/adafruit_character_lcd/character_lcd.py#L72-L73
This would make sense for a 20x4 LCD. However, for my particular display, row 3 starts at ``0x10`` (16) and row 4 at ``0x50`` (80, 64+16). I imagine this would be the case with almost all displays, with the offsets equal to the number of characters in each row.
I had expected the ``columns`` and ``lines`` arguments to `Character_LCD_Mono` to automatically handle the offsets for me. My workaround is to modify the class level `_LCD_ROW_OFFSETS` at runtime:
```python
import adafruit_character_lcd.character_lcd as characterlcd
characterlcd._LCD_ROW_OFFSETS = (0x00, 0x40, 0x14-4, 0x54-4)
```
If there a better way to go about this? If not, would it be possible to add proper support? Perhaps the calculated offsets could be exposed as a property that can be changed for screens that work differently?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in adafruit_character_lcd/character_lcd.py around lines 72-73 and inspect Character_LCD_Mono's columns, lines, and _LCD_ROW_OFFSETS handling. Compare the current hardcoded offsets with the reported 16x4 display behavior, then define the support needed for row offsets and verify that both 16x4 and existing 20x4 layouts work correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 46/100