SPKDisplay - A mbed display class and processing imaging tools for 128x64 OLEDs using the SSD1305 driver, connected via SPI.

Dependents:   SPK-DVIMXR SPK-DMXer

spk_oled_screenByteMaker--processing.h

Committer:
tobyspark
Date:
2012-04-15
Revision:
2:8187d69071f8
Parent:
1:dd3faa2ab1dd
Child:
3:ade83210ecf6

File content as of revision 2:8187d69071f8:

// OLED display using SSD1305 driver
// Copyright *spark audio-visual 2012
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 3 as published by the Free Software Foundation.

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("}");
}