Reading GPIO

Hi,
I'm trying to read the data from pulseSensor. I am trying to understand if my code below is correct to get a basic value right.
Inside my on create :
        getApplicationContext().bindService(new Intent(this, MetaWearBleService.class),this, Context.BIND_AUTO_CREATE);
MWConnect = (Button)findViewById(R.id.buttonConnect);
MWDisConnect = (Button)findViewById(R.id.buttonDisconnect);
MWConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mwCtrllr.connect();
GPIO gpioCtrllr = (GPIO) mwCtrllr.getModuleController(Module.GPIO);
mwCtrllr.addModuleCallback(new GPIO.Callbacks() {
@Override
public void receivedAnalogInputAsAbsValue(byte pin, short value) {
Log.v("ExampleActivity", String.format(Locale.US, "pin= %d, Analog Abs Ref= %dmV",
pin, value));
}
@Override
public void receivedAnalogInputAsSupplyRatio(byte pin, short value) {
Log.v("ExampleActivity", String.format(Locale.US, "pin= %d, Analog Supply Ratio= %d",
pin, value));
}
});
gpioCtrllr.readAnalogInput((byte) 0, GPIO.AnalogMode.SUPPLY_RATIO);

mwCtrllr.addModuleCallback(new GPIO.Callbacks() {
@Override
public void receivedDigitalInput(byte pin, byte value) {
Log.i("ExampleActivity", String.format(Locale.US, "pin= %d, Digital In Value= %d",
pin, value));
}
});
gpioCtrllr.readDigitalInput((byte) 0);
}
});
MWDisConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mwCtrllr.close(true);
}
});
}

@Override
public void onDestroy() {
super.onDestroy();
getApplicationContext().unbindService(this);
}

@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mwService= ((MetaWearBleService.LocalBinder) service).getService();
final BluetoothManager btManager=
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
final BluetoothDevice mwBoard= BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MW_MAC_ADDRESS);
mwCtrllr= mwService.getMetaWearController(mwBoard);
}

Comments

This discussion has been closed.