SPKDisplay - A mbed display class and processing imaging tools for 128x64 OLEDs using the SSD1305 driver, connected via SPI.
Dependents: SPK-DVIMXR SPK-DMXer
Diff: spk_oled_screenByteMaker--processing.h
- Revision:
- 0:76bb084fa033
- Child:
- 1:dd3faa2ab1dd
diff -r 000000000000 -r 76bb084fa033 spk_oled_screenByteMaker--processing.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spk_oled_screenByteMaker--processing.h Sun Apr 15 16:51:01 2012 +0000 @@ -0,0 +1,67 @@ +int w = 132; +int h = 64; +int scaleFactor = 10; + +PImage imgPixel; +color white = color(255, 255, 255, 255); +color black = color(0, 0, 0, 255); + +void setup() +{ + size(w*scaleFactor, h*scaleFactor); + imgPixel = loadImage("spk_dvimxr_screen.png"); + + noSmooth(); +} + +void draw() +{ + background(0); + image(imgPixel, 0, 0, w*scaleFactor, h*scaleFactor); +} + +void mouseDragged() +{ + int x = mouseX/scaleFactor; + int y = mouseY/scaleFactor; + + imgPixel.set(x, y, white); +} + +void mousePressed() +{ + int x = mouseX/scaleFactor; + int y = mouseY/scaleFactor; + + if (imgPixel.get(x, y) == white) + { + imgPixel.set(x, y, black); + } + else + { + imgPixel.set(x, y, white); + } +} + +void keyPressed() +{ + println("{"); + for (int page = 0; page < 8; page++) + { + for (int i = 0; i < w; i++) + { + byte theByte = 0; + for (int j = 0; j < 8; j++) + { + if (imgPixel.get(i, (page*8)+j) == white) + { + theByte += pow(2, j); + } + } + print("0x" + hex(theByte, 2)); + print(", "); + } + println(); + } + println("}"); +}