Skip to content

Row Offsets for 16x4 display. #64

@domdfcoding

Description

@domdfcoding

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

# Offset for up to 4 rows.
_LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)

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:

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions