kunerd / clerk

Hardware independent HD44780 LCD library written in Rust
MIT License
13 stars 1 forks source link

SeekFrom::Line does not make sense for CGRAM #26

Closed kunerd closed 6 years ago

kunerd commented 6 years ago

CGRAM has different size than DDRAM.

CGRAM = 64 byte DDRAM = 128 byte (2 line version)

kunerd commented 6 years ago

CGRAM is devided into two address rooms, the first one for characters itself and the other for each pixel line of a character. See Table 5, Datasheet page 19-20.

5x8 dot characters:

7 6 5 \ 4 \ 3 2 \ 1 \ 0
r r char addr line addr

5x10 dot characters:

7 6 5 \ 4 3 \ 2 \ 1 \ 0
r r char addr line addr
kunerd commented 6 years ago

Implementation proposal:

pub struct CharacterAddress(u8);
pub struct CharacterLineAddress(u8);

pub enum SeekCgRamFrom<T> {
    Home(T),
    Current(T),
}

impl<P, U> Display<P, U, CgRam>
where
    U: Into<Address> + Home,
    P: Send,
{
    pub fn seek_character(&self, pos: SeekCgRamFrom<CharacterAddress>) {
        // ...
    }
    pub fn seek_character_line(
        &self,
        char_pos: SeekCgRamFrom<CharacterAddress>,
        line_pos: SeekCgRamFrom<CharacterLineAddress>,
    ) {
        // ...
    }
    // ...
}
kunerd commented 6 years ago

fixed by #29