Skip to content

glasgowneuro/AttysComm

Repository files navigation

AttysCOMM

The JAVA API for the Attys: http://www.attys.tech

alt tag

In general the java class AttysComm is well documented. Check out the class itself. You find all the constants and function calls there.

Usage

  1. Create AttysComm:
BluetoothDevice bd = AttysComm.findAttysBtDevice();
attysComm = new AttysComm(bd);
  1. Set options

In general there are constants defined for the differnet options, for example: AttysComm.ADC_RATE_250HZ for the sampling rate:

attysComm.setAdc_samplingrate_index(AttysComm.ADC_RATE_250HZ);
  1. (Optional) Register a message listener for error messages:
attysComm.registerMessageListener(messageListener);
  1. Start the data acquisition
attysComm.start();
  1. Read the data from the ringbuffer in a TimerTask:
    class UpdatePlotTask extends TimerTask {

        public synchronized void run() {

            if (attysComm != null) {

  	        n = attysComm.getNumSamplesAvilable();
		for(int i = 0;i<n;i++) {
                    sample = attysComm.getSampleFromBuffer();
		    PROCESS / PLOT / ETC SAMPLE
		}
	    }
        }
    }
  1. (Optional) there is also an event listener whenever a sample has arrived:
    public interface DataListener {
        void gotData(long samplenumber, float[] data);
    }
  1. to stop AttysComm just call stop(). It's blocking and will only return after the Thread talking to the Attys has been terminated.

Enjoy!

http://www.attys.tech