mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 11:21:06 +01:00
IO: Invert OLED example
This makes bright pixels be illuminated on the display.
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user