Potential but in Comparison filter

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?


  • edited March 2016
    Thanks for the report, we have found and fixed a bug which will be fixed in the next release.  In the mean time I have a revised code snippet for you to try.  I'm assuming you wanted the LED to illuminate when the device isn't "flat" (i.e. the z-axis is [-0.8, 0.8] G's):

        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];


This discussion has been closed.