BlipBox Processing

In order to make it easy to write apps for the BlipBox we publish a Processing library as part of the project. Processing is a programming language and environment for people who aren’t necessarily strong programmers, with a focus on visual arts, music and new¬† media. Programs in Processing are called sketches, and writing BlipBox sketches is an easy way to control and communicate with the device.

Library Overview

To use the library simply create a ProcessingBlipBox object. This object can be used to send commands to the device, e.g. to turn on some LEDs or write out a text on the display.

Commonly used commands are:

setLed(int x, int y, int brightness) : turn an LED on or off.
setLedColumn(int col, int data) : set individual LEDs in a whole column at once.
setLedRow(int row, int data) // same for a row of LEDs.
clear() // clear the display.
fill(int brightness) // set all LEDs to the same value.
writeText(String str, long delay) // write a text scrolling at a given speed.
shiftHorizontal(int steps) // move all LED values a number of steps left or right.
shiftVertical(int steps) // move LED values up or down.

There are also methods to query the state of the BlipBox.

boolean isScreenPressed() : returns true if the touchscreen is activated.
float getX() / getY() : get a touchscreen coordinate as a value between 0 and 1.
int getX(int min, int max) : get the coordinate as a value between min and max.
int getLed(int x, int y) : get the current brightness value of an LED.

When the BlipBox screen is touched, and when the touch is released, callback methods are triggered in the sketch. These are very similar to how Processing handles mouse input with mousePressed(), mouseDragged() and mouseReleased().

A Position object is passed to these methods which gives the touchscreen coordinates of the event.

touchPressed(Position pos) : first method called when the screen is touched.
touchDragged(Position pos) : called continuously while the touch position changes.
touchReleased(Position pos) : called when the touch is released.

Examples

Here we will present some of the sketches which have already been written for the BlipBox. They show how the library works and what can be done, and may provide a starting point for writing your own.

BlipDraw

A simple sketch which turns LEDs on and off on the BlipBox as you touch them on the touchscreen, thereby turning the BlipBox into a simple drawing surface.

// this is the BlipBox object for our sketch
ProcessingBlipBox blipbox;
// variables to store coordinates
int lastx = -1;
int lasty = -1;

void setup(){
  // initialise the library
  blipbox = new ProcessingBlipBox(this, 0);
}

void touchReleased(Position pos){
  // reset the coordinates
  // when the screen is no longer touched
  lastx = -1;
  lasty = -1;
}

void touchDragged(Position pos){
  // get the screen coordinates
  // scaled to the size of the LED matrix
  int x = pos.getX(0, 10);
  int y = pos.getY(0, 8);
  if(lastx != x || lasty != y){
    // if the previous coordinates were different
    // we toggle the LED on or off
    if(blipbox.getLed(x, y) == 0)
      blipbox.setLed(x, y, 255);
    else
      blipbox.setLed(x, y, 0);
   // save the current coordinates
    lastx = x;
    lasty = y;
  }
}

That’s all there is to writing a complete, working and useful BlipBox Processing sketch!

 

Share

3 Responses to BlipBox Processing

  1. tigabeatz says:

    Hi there,

    yesterday i recived the blipbox from schneiderladen. ecept that the usb port seems very sensitive for any movements, the box feels great.

    dont you have a forum? i could use to ask some questions regarding the processing sketches? i dont get them to run, maybe due to my x64 and the rxtx…

    cheers
    tigabeatz

    • mars says:

      Regarding the USB socket, there is normally some play between the socket and plug.
      That is normal for USB connectors and does not affect the function – compare with other devices and you will find they behave the same way.
      However the socket itself should be solid – it shouldn’t move inside the BlipBox case.
      Can you pls verify that this is the case with your unit?

  2. mars says:

    Hi there,

    The USB port should be robust. I’ve sent you an email.

    No forum yet, it’s on the todo-list!
    However I will update the docs as soon as we have resolved your issue.