/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ocweb.grove;

import com.ociweb.gl.api.StartupListener;

import com.ociweb.iot.grove.three_axis_accelerometer_16g.*;
import com.ociweb.iot.maker.FogCommandChannel;
import com.ociweb.iot.maker.FogRuntime;
import static com.ociweb.iot.maker.FogRuntime.*;
import com.ociweb.iot.maker.I2CListener;

/**
 *
 * @author huydo
 */
public class AccelerometerBehavior implements StartupListener,INT_SOURCE_RegListener,AccelValsListener {
    
    private final FogCommandChannel c;
    private final ThreeAxisAccelerometer_16g_Transducer accSensor;
    
    public AccelerometerBehavior(FogRuntime runtime){
        this.c = runtime.newCommandChannel(I2C_WRITER);
        accSensor = new ThreeAxisAccelerometer_16g_Transducer(c,this);
    }
    
    @Override
    public void startup() {
        accSensor.begin();
        accSensor.setRange(4);
        accSensor.setFreeFallDuration(4);
        accSensor.setFreeFallThreshold(9);
        accSensor.setINT_ENABLE_Reg(0b00000100);
        
        
    }

    @Override
    public void accelVals(int x, int y, int z) {
        System.out.println("z: "+z);
    }

    @Override
    public void INT_SOURCE_RegStatus(int byteRead) {
        System.out.println("reg: "+byteRead);
    }

    @Override
    public void freefallStatus(int status) {
        System.out.println("free fall: "+status);
    }

}

@@ -571,30 +571,24 @@
 istener,
-INT_SOURCE_Reg
+FreeFall
 Listener
@@ -1286,128 +1286,8 @@
  %7D%0A%0A
-    @Override%0A    public void INT_SOURCE_RegStatus(int byteRead) %7B%0A        System.out.println(%22reg: %22+byteRead);%0A    %7D%0A%0A
     
@@ -1398,10 +1398,11 @@
 %0A    %7D%0A%0A
+%0A
 %7D%0A

clean up