-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
.idea/.name
Outdated
@@ -0,0 +1 @@ | |||
journey-android-bluetooth-scale |
There was a problem hiding this comment.
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.
235d014
to
bb5f2f1
Compare
bb5f2f1
to
87f7c30
Compare
@@ -100,6 +100,10 @@ public void disconnectScale(View view) { | |||
} | |||
} | |||
|
|||
public void writeZero(View view) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); | |||
} | |||
|
|||
|
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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
5453f74
to
7440831
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
To zero the scale, the byte array
{0x02, 0x4B, 0x5A, 0x52, 0x40, (byte) 0xB7, 0x0D}
is sent to the scale using the outputStream