I use a MMA8451Q to monitor a device that does not have to bend over x degrees to the vertical axis. Before I used a tilt switch CM1320-0 from Assemtech and wish to obtain the same result.
To do this , I thought used to detect portrait/landscape integrated. But I realize doing my tests that this mode is not the same if you turn around the Z axis or if the Z axis is tilted up or down.
Operation when turning around Z is perfect for my application, ideally I would have the same mode of operation on the other axis . But when I switch to the front ( Z down) , I have no hysteresis and backward (Z up) I hysteresis is too important! I tried to cheat the offset of the Z axis, but this is not enough.
I wonder if there is another solution that regularly read the MMA8451Q and make the angle calculation from the XYZ readings ? If there is no alternative , is there a sample source code?