embed-rs / stm32f7-discovery

Apache License 2.0
30 stars 23 forks source link

Can't println! on last line #99

Closed pbrinkmeier closed 5 years ago

pbrinkmeier commented 5 years ago

When you print on the last line using println!, the screen gets cleared immediately; anything println!ed on the last line will thusly not be shown.

This is because the newline character causes the TextWriter to issue calls to newline() (which increases the cursor's y-position by 8 (moving it off the screen when printing on the last line)) and carriage_return(), which resets the cursor's x-position to 0 and, if the cursor's y-position if off-screen, resets it to 0 too.

Textwriter:

    fn newline(&mut self) {
        self.y_pos += 8;
        self.carriage_return()
    }
    fn carriage_return(&mut self) {
        if self.y_pos >= HEIGHT {
            self.clear();
        } else {
            self.x_pos = 0;
        }
    }

A simple fix would be to move if self.y_pos >= HEIGHT: clear() to line 341; this would clear the screen only when a character is about to be written on the next (off-screen) line.