Potential but in Comparison filter
in iOS
Can you combine "Comparison" filters in IOS to create a range filter? For instance, unless I am mistaking I believe this should work...
MBLEvent<MBLNumericData *> *filterAccelerometerSides = [device.accelerometer.zAxisReadyEvent compareEventUsingOperation:MBLComparisonOperationGreaterThan withData:-0.8];
MBLEvent<MBLNumericData *> *filterAccelerometerSides2 = [filterAccelerometerSides compareEventUsingOperation:MBLComparisonOperationLessThan withData:0.8];
[filterAccelerometerSides2 programCommandsToRunOnEventAsync:^{
[device.led setLEDColorAsync:[UIColor blueColor] withIntensity:1.0];
}];
I have confirmed that the Z axis of the accelerometer are in the described ranges.. Yet the light is never turned on. Am I missing something or this a bug?
This discussion has been closed.
Comments
MBLEvent *zAxis = self.device.accelerometer.zAxisReadyEvent;
MBLEvent *zAxisLowEvent = [zAxis changeOfEventAcrossThreshold:-0.8 hysteresis:0.1 output:MBLThresholdValueOutputBinary];
MBLEvent *lowEventLightOn = [zAxisLowEvent compareEventUsingOperation:MBLComparisonOperationEqual withData:1]; // Rising above -0.8
MBLEvent *lowEventlightOff = [zAxisLowEvent compareEventUsingOperation:MBLComparisonOperationEqual withData:-1]; // Falling below -0.8
MBLEvent *zAxisHighEvent = [zAxis changeOfEventAcrossThreshold:0.8 hysteresis:0.1 output:MBLThresholdValueOutputBinary];
MBLEvent *highEventLightOff = [zAxisHighEvent compareEventUsingOperation:MBLComparisonOperationEqual withData:1]; // Rising above 0.8
MBLEvent *highEventlightOn = [zAxisHighEvent compareEventUsingOperation:MBLComparisonOperationEqual withData:-1]; // Falling below 0.8
[lowEventLightOn programCommandsToRunOnEventAsync:^{
[self.device.led setLEDColorAsync:[UIColor blueColor] withIntensity:1.0];
}];
[highEventlightOn programCommandsToRunOnEventAsync:^{
[self.device.led setLEDColorAsync:[UIColor blueColor] withIntensity:1.0];
}];
[lowEventlightOff programCommandsToRunOnEventAsync:^{
[self.device.led setLEDOnAsync:NO withOptions:1];
}];
[highEventLightOff programCommandsToRunOnEventAsync:^{
[self.device.led setLEDOnAsync:NO withOptions:1];
}];