IO: Invert OLED example

This makes bright pixels be illuminated on the display.
This commit is contained in:
gohai
2017-04-05 14:52:22 +02:00
parent 1df221200b
commit 5ff162e20a
2 changed files with 3 additions and 2 deletions

View File

@@ -14,7 +14,8 @@ void setup() {
}
void draw() {
background(255);
background(0);
stroke(255);
line(0, 0, 127, 63);
line(0, 63, 127, 0);
oled.sendImage(get());

View File

@@ -61,7 +61,7 @@ class SSD1306 extends I2C {
img.loadPixels();
for (int y=startY; y < height && y-startY < 64; y++) {
for (int x=startX; x < width && x-startX < 128; x++) {
if (brightness(img.pixels[y*img.width+x]) < 128) {
if (128 <= brightness(img.pixels[y*img.width+x])) {
// this isn't the normal (scanline) mapping, but 8 pixels below each other at a time
// white pixels have their bit turned on
frame[x + (y/8)*128] |= (1 << (y % 8));