Skip to content

openpool/openpool-boost-pocket

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
web
 
 
 
 
 
 
 
 
 
 
 
 
 
 

openpool-boost-pocket

Copyright (C) 2013 Kazunori Ogasawara and Jun Kato


A boost module for openpool library.

How to use

Extract a zip archive

Extract contents of OpenPoolBoostPocket.zip into Processing library directory. All files should reside in its subdirectory e.g.

C:\Users\hoge\Documents\Processing\libraries\OpenpoolBoostPocket

Prepare proper RXTX library

Default RXTX library in OpenpoolBoostPocket/library directory is for Windows with 64bit Java VM. If you're running Processing in another configuration, e.g. Windows with 32bit Java VM or Mac OS with 64bit Java VM, please download proper RXTX library from its official website and extract files into the directory.

Write code

Select "OpenpoolBoostPocket" from Sketch > Import Library... menu.

import openpool.pocket.*;

OpenpoolBoostPocket obp;

void setup() {
  // Connect to the pocket detector.
  try {
    obp = new OpenpoolBoostPocket(this, "COM4");
    obp.start();
  } catch (Exception e) {
    println("Pocket detector not found.");
  }
}

void draw() {
  if (obp == null) return;

  // When you want to know the total pockets, call
  // getTotalPockets() method.
  int[] totalPockets = obp.getTotalPockets();

  // You might sometimes want to call resetTotal() to reset the
  // total numbers.
  //obp.resetTotal();

  // When you want to know if there's any pocket after the last
  // frame, call getPockets() method.
  
  int[] pockets = obp.getPockets();
  for (int i = 0; i < pockets.length; i ++) {
    if (pockets[i] > 0) {
      print(pockets[i]);
      print(" balls fell in the pocket no.");
      println(i + 1);
    }
  }
}

License

This work is licensed under GNU GPL, Version 2.0.


http://github.com/openpool/openpool-boost-pocket