Skip to content

Commit

Permalink
fix the representation of the pixel bit
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyll committed Jun 23, 2016
1 parent f1409db commit 17e7ee9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ssd1306/ssd1306.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ func (o *OLED) SetPixel(x, y int, v byte) error {
if v > 1 {
return fmt.Errorf("value needs to be either 0 or 1; given %v", v)
}
i := x + (y/8)*o.w + 1
o.buf[i] = o.buf[i] | v<<uint((y%8))
i := 1 + x + (y/8)*o.w
if v == byte(0) {
o.buf[i] &= ^(1 << uint((y & 7)))
} else {
o.buf[i] |= 1 << uint((y & 7))
}
return nil
}

Expand Down

0 comments on commit 17e7ee9

Please sign in to comment.