Skip to content

Commit

Permalink
replaced assert keyword with RuntimeExceptions for analog and digital…
Browse files Browse the repository at this point in the history
… input setValue methods
  • Loading branch information
topherbuckley committed Jun 1, 2021
1 parent ce3c1d1 commit ac982f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion IOIOLibCore/src/main/java/ioio/lib/impl/AnalogInputImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public float getReference() {
@Override
synchronized public void setValue(int value) {
// Log.v("AnalogInputImpl", "Pin " + pinNum_ + " value is " + value);
assert (value >= 0 && value < 1024);
if (value < 0 || value >= 1024) {
throw new RuntimeException("value must be between 0 (inclusive) and 1024 (exclusive). A value of " + value + " was given.");
}
value_ = value;
++sampleCount_;
bufferPush((short) value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class DigitalInputImpl extends AbstractPin implements DigitalInput,
@Override
synchronized public void setValue(int value) {
// Log.v("DigitalInputImpl", "Pin " + pinNum_ + " value is " + value);
assert (value == 0 || value == 1);
if (value != 0 && value != 1) {
throw new RuntimeException("value must be 0 or 1. A value of " + value + " was given.");
}
value_ = (value == 1);
if (!valid_) {
valid_ = true;
Expand Down

0 comments on commit ac982f6

Please sign in to comment.