This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
hello = tf.constant('Hello, TensorFlow!') | |
# Start tf session | |
sess = tf.Session() | |
# Run the op | |
print(sess.run(hello)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dataB1 = [1, 1, 0]; | |
var dataB2 = [2, 1, 0]; | |
var dataB3 = [2, .5, 0]; | |
var dataB4 = [3, 1, 0]; | |
var dataR1 = [3, 1.5, 1]; | |
var dataR2 = [3.5, .5, 1]; | |
var dataR3 = [4, 1.5, 1]; | |
var dataR4 = [5.5, 1, 1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical"> | |
<TextView | |
android:id="@+id/title_paired_devices" | |
android:layout_width="match_parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
xml version="1.0" encoding="utf-8"?> | |
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:padding="5dp" | |
android:textSize="18sp" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private BluetoothAdapter bluetoothAdapter; | |
Button scanButton; | |
private static final int REQUEST_ENABLE_BT = 1; | |
private ArrayAdapter<String> mNewDevicesArrayAdapter; | |
Setup oncreateFirst check if your smartphone supports BluetoothbluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); | |
if (bluetoothAdapter == null) { Toast.makeText(this, "Device does not support bluetooth", | |
Toast.LENGTH_SHORT).show(); | |
finish(); | |
} | |
else if (!bluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
if(resultCode == RESULT_CANCELED) | |
Toast.makeText(this,"Please provide permission to turn on bluetooth",Toast.LENGTH_SHORT).show(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scanButton = (Button) findViewById(R.id.button_scan); | |
scanButton.setOnClickListener(new View.OnClickListener() { | |
public void onClick(View v) { | |
doDiscovery(); | |
v.setVisibility(View.GONE); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Register for broadcasts when a device is discovered IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); | |
this.registerReceiver(mReceiver, filter); // Register for broadcasts when discovery has finished | |
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); | |
this.registerReceiver(mReceiver, filter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get a set of currently paired devices | |
Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices(); | |
// If there are paired devices, add each one to the ArrayAdapter | |
if (pairedDevices.size() > 0) { | |
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE); | |
for (BluetoothDevice device : pairedDevices) { | |
pairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); | |
} | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override protected void onDestroy() { super.onDestroy(); | |
// Make sure we're not doing discovery anymore | |
if (bluetoothAdapter != null) | |
{ | |
bluetoothAdapter.cancelDiscovery(); | |
} | |
// Unregister broadcast listeners | |
this.unregisterReceiver(mReceiver); | |
} |
OlderNewer