Skip to content
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

Using terminal mode with 90/270 degree rotation leads to incorrect output and panic #196

Closed
plm opened this issue Sep 27, 2023 · 1 comment · Fixed by #197
Closed

Using terminal mode with 90/270 degree rotation leads to incorrect output and panic #196

plm opened this issue Sep 27, 2023 · 1 comment · Fixed by #197

Comments

@plm
Copy link

plm commented Sep 27, 2023

  • Version of ssd1306 in use (if applicable): 0.8.1
  • MCU/other hardware in use: Seeeduino XIAO RP2040 with expansion board
  • Display resolution and interface: I2C, 128x64

Description of the problem/feature request/other

When TerminalMode and Rotation90 or Rotation270 is used, writing a new line of text results in the first character being written to the first line of the display, with the remainder of the text for the same line displayed on a later, but expected, line. After writing the eighth line, attempts to write the ninth line trigger a panic, possibly because the first character of the ninth line would (incorrectly) need to be written off screen.

Test case (if applicable)

A sample reproducer using rp2040-hal is provided in plm/ssd1306-rotation-panic, with the relevant lines below.

let i2c = ... // omitted for brevity
let mut display = I2CDisplayInterface::new(i2c),
    DisplaySize128x64,
    DisplayRotation::Rotate270,
)
.into_terminal_mode();

if display.init().is_ok() && display.clear().is_ok() {
   let _ = writeln!(display, "INIT OK");
   loop {
       for count in 0..u8::MAX {
           let _ = writeln!(display, "{}TEST", count); // panics on count == 7
       }
   }
}

Expected display output, which should repeat indefinitely:

INIT OK
0TEST
1TEST
2TEST
3TEST
4TEST
5TEST
6TEST
7TEST

Actual display output, which panics when writing the eighth test line:

I0123456
 TEST
 TEST
 TEST
 TEST
 TEST
 TEST
 TEST
@jamwaffles
Copy link
Collaborator

Hey, thanks for the detailed bug report! It made it easy to reproduce your issue. I've opened PR #197 to fix this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants