thingm.blink1
Class Blink1

java.lang.Object
  extended by thingm.blink1.Blink1

public class Blink1
extends java.lang.Object


Constructor Summary
Blink1()
          Constructor.
 
Method Summary
 void close()
          Close blink(1) device
 int command(int cmd, byte[] buf_send, byte[] buf_recv)
          FIXME: this does not work Do a transaction with the Blink1 length of both byte arrays determines amount of data sent or received
 int enumerate()
          (re)Enumerate the bus and return a count of blink(1) device found
 int fadeToRGB(int fadeMillis, int r, int g, int b)
          Fade blink(1) to RGB color over fadeMillis milliseconds.
 int getCount()
           
 java.lang.String[] getDevicePaths()
          Return the list of blink(1) device paths found by enumerate
 java.lang.String[] getDeviceSerials()
          Return the list of blink(1) device serials found by enumerate
 int getFirmwareVersion()
           
static int log2lin(int n)
          one attempt at a degamma curve //FIXME: this is now in blink1-lib
static void main(java.lang.String[] args)
          Simple command-line demonstration
 int open()
          Open blink(1) device.
 int openById(int id)
          Open blink(1) device by blink(1) numerical id (0-getCount()) Id list is ordered by serial number.
 int openByPath(java.lang.String devicepath)
          Open blink(1) device by USB path, may be different for each insertion
 int openBySerial(java.lang.String serialnumber)
          Open blink(1) device by blink(1) serial number
static void pause(int millis)
          Utility: A simple delay
 int play(boolean play, int pos)
           
static void print(java.lang.String s)
           
static void println(java.lang.String s)
           
 int serverdown(boolean on, int millis)
           
 int setRGB(int r, int g, int b)
          Set blink(1) RGB color immediately
static void usage()
           
 int writePatternLine(int fadeMillis, int r, int g, int b, int pos)
          Write a blink(1) light pattern entry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Blink1

public Blink1()
Constructor. Searches for plugged in blink(1) devices and populates internal caches

Method Detail

usage

public static void usage()

main

public static void main(java.lang.String[] args)
Simple command-line demonstration


enumerate

public int enumerate()
(re)Enumerate the bus and return a count of blink(1) device found


getCount

public int getCount()

getDevicePaths

public java.lang.String[] getDevicePaths()
Return the list of blink(1) device paths found by enumerate


getDeviceSerials

public java.lang.String[] getDeviceSerials()
Return the list of blink(1) device serials found by enumerate


open

public int open()
Open blink(1) device. Stores open device id statically in native lib. Only one device can be open at once.


close

public void close()
Close blink(1) device


openByPath

public int openByPath(java.lang.String devicepath)
Open blink(1) device by USB path, may be different for each insertion


openBySerial

public int openBySerial(java.lang.String serialnumber)
Open blink(1) device by blink(1) serial number


openById

public int openById(int id)
Open blink(1) device by blink(1) numerical id (0-getCount()) Id list is ordered by serial number.


command

public int command(int cmd,
                   byte[] buf_send,
                   byte[] buf_recv)
FIXME: this does not work Do a transaction with the Blink1 length of both byte arrays determines amount of data sent or received

Parameters:
cmd - the blink1 command code
buf_send - is byte array of command to send, may be null
buf_recv - is byte array of any receive data, may be null

setRGB

public int setRGB(int r,
                  int g,
                  int b)
Set blink(1) RGB color immediately

Parameters:
r - red component 0-255
g - green component 0-255
b - blue component 0-255

fadeToRGB

public int fadeToRGB(int fadeMillis,
                     int r,
                     int g,
                     int b)
Fade blink(1) to RGB color over fadeMillis milliseconds.

Parameters:
fadeMillis - milliseconds to take to get to color
r - red component 0-255
g - green component 0-255
b - blue component 0-255

writePatternLine

public int writePatternLine(int fadeMillis,
                            int r,
                            int g,
                            int b,
                            int pos)
Write a blink(1) light pattern entry

Parameters:
fadeMillis - milliseconds to take to get to color
r - red component 0-255
g - green component 0-255
b - blue component 0-255
pos - entry position 0-patt_max

play

public int play(boolean play,
                int pos)
Parameters:
play - true to play, false to stop
pos - starting position to play from, 0 = start

serverdown

public int serverdown(boolean on,
                      int millis)
Parameters:
on - true = turn on serverdown mode, false = turn it off
millis - milliseconds until light pattern plays if not updated

getFirmwareVersion

public int getFirmwareVersion()

log2lin

public static final int log2lin(int n)
one attempt at a degamma curve //FIXME: this is now in blink1-lib


pause

public static final void pause(int millis)
Utility: A simple delay


println

public static final void println(java.lang.String s)

print

public static final void print(java.lang.String s)