diff --git a/IOIOLibCore/src/main/java/ioio/lib/impl/AnalogInputImpl.java b/IOIOLibCore/src/main/java/ioio/lib/impl/AnalogInputImpl.java index dedc6e0f..1c501ad6 100644 --- a/IOIOLibCore/src/main/java/ioio/lib/impl/AnalogInputImpl.java +++ b/IOIOLibCore/src/main/java/ioio/lib/impl/AnalogInputImpl.java @@ -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); diff --git a/IOIOLibCore/src/main/java/ioio/lib/impl/DigitalInputImpl.java b/IOIOLibCore/src/main/java/ioio/lib/impl/DigitalInputImpl.java index 5f498acb..e84448b1 100644 --- a/IOIOLibCore/src/main/java/ioio/lib/impl/DigitalInputImpl.java +++ b/IOIOLibCore/src/main/java/ioio/lib/impl/DigitalInputImpl.java @@ -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;