almindor / st7789

Rust library for displays using the ST7735 driver
https://docs.rs/st7735-lcd
MIT License
47 stars 24 forks source link

discard any pixels with negative coordinates to avoid a panic in later code #22

Closed mutantbob closed 2 years ago

mutantbob commented 2 years ago

I tried to draw some text at x,y = 1,1 , and got a panic inside batch.rs

It seems that the code to batch up pixels was converting an i16 to a u16, and when it came time to self.y_bottom + 1 fory=(-1 as u16) that cause an arithmetic overflow and a panic.

This patch discards any pixels with coordinates <0

almindor commented 2 years ago

Nice catch, thanks.

I've mostly abandoned this crate for mipidsi though. I'll apply this fix there too, but you might want to switch to using that since the st7789 will become deprecated soon.