Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button to Zero scale #1

Merged
merged 3 commits into from
Feb 17, 2017
Merged

Add button to Zero scale #1

merged 3 commits into from
Feb 17, 2017

Conversation

WesselWessels
Copy link
Contributor

To zero the scale, the byte array {0x02, 0x4B, 0x5A, 0x52, 0x40, (byte) 0xB7, 0x0D} is sent to the scale using the outputStream

.idea/.name Outdated
@@ -0,0 +1 @@
journey-android-bluetooth-scale
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .idea folder (and any other IDE-generated files) should not be included in the git repo.

@@ -100,6 +100,10 @@ public void disconnectScale(View view) {
}
}

public void writeZero(View view) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a view parameter being passed in and not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, the onClick function requires the View parameter.

@@ -85,6 +85,7 @@ public final synchronized void connectToDevice(BluetoothDevice bluetoothDevice)
setState(ConnectionState.CONNECTING);
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace.

@@ -14,6 +14,7 @@
private final OutputStream outputStream;
private BluetoothService bluetoothService;
private final static int payloadSize = 11;
private final byte[] ZERO_INSTRUCTION_BYTES = new byte[]{0x02, 0x4B, 0x5A, 0x52, 0x40, (byte) 0xB7, 0x0D};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is 0xB7 being cast to a byte?

This should be made static as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is because 0xB7 is negative. I casted all of them, just to be explicit and consequential.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Found this mention about bytes being signed in Java: http://stackoverflow.com/a/13020962

@@ -37,6 +38,15 @@ public BluetoothConnectedThread(BluetoothService bluetoothService, BluetoothSock
this.outputStream = outputStream;
}

public void writeZero() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not obvious what writeZero means. I suggest having a more descriptive name here, like sendZeroCommand for example (this applies to the other levels where this is called from as well).

@@ -93,6 +93,11 @@ public final synchronized void connected(BluetoothSocket bluetoothSocket) {
setState(ConnectionState.CONNECTED);
}

public void writeZero() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be sendZeroInstruction for consistency.

@@ -14,6 +14,7 @@
private final OutputStream outputStream;
private BluetoothService bluetoothService;
private final static int payloadSize = 11;
private final byte[] ZERO_INSTRUCTION_BYTES = new byte[]{0x02, 0x4B, 0x5A, 0x52, 0x40, (byte) 0xB7, 0x0D};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Found this mention about bytes being signed in Java: http://stackoverflow.com/a/13020962

Copy link
Contributor

@kblum kblum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WesselWessels WesselWessels merged commit 4430f0e into master Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants