When Z becomes X - problem understanding accelerometer (LSM303 DLHC)

This is my first time using an accelerometer 6D. My questions will probably sound a bit naive but I hope you'll be patient. Please be aware that I did look at all the posts (or nearly) on this forum dealing with the LSM303DHLC model and could not find an answer (or missed it).
My project : have brake lights embedded in a jacket I wear when cycling.
Equipment: a sewable board (Lillypad-like) + a LSM303 (in a sewable version) + other stuff meaningless for my current problem.

Basically, a deceleration will switch on red leds. I am prepared to spend some time later on defining the adequate thresholds but for the time being, here's my problem.
The board and LSM303 will be sewed somewhere on the "chest" level of the jacket, resulting in a nearly-vertical position of the sensor. Yet, due to the movement of the cyclist, the position of the sensor (the angle it makes with say the radius of the Earth) will vary a bit.

When I run the Accelsensor test provided with the LLSM303DLHC library (from Adafruit and compatible with the Unified sensor library), I get roughly low (close to 0) values for X and Y when the sensor stands still, and 9.8 as expected (gravity) for Z.
But if I rotate my "device" by 90°, X will show the former Z values (Earth gravity), and Z becomes the value to track for a cyclist linear deceleration.
It makes sense when looking at the diagram included in the sensor datasheet :

But given the way I intend to sew the sensor on my jacket, it will be oriented this way :

My question : is there any way to take into account this phenomenon when trying to detect a linear acceleration (or deceleration) in one axis only ? In my case, the movement of the cyclist.

I mean, the position of the sensor will be roughly vertical, but will randomly change (tilt effect) as the torso of the cyclist is never 100 % still.

I am aware that the LSM303 is a 6 D device, with a magnetometer and an accelerometer. I understood, from a theoretical perspective, that the accelerometer can be used to provide a tilt-compensation for the compass. But can this work the other way round?

In short, can you put me on the right direction ?

Pierre

Your idea is basically correct. The magnetometer tells you the direction (a 3D vector) of the Earth's magnetic field, which points mostly down, into the ground, at northern latitudes. That direction, combined with the acceleration due to gravity is often used to define X as magnetic North in the horizontal plane and Z as the vertical down direction, which in turn can give you tilt information. See this for a very complete analysis: http://cache.freescale.com/files/sensors/doc/app_note/AN4248.pdf

For the LSM303 to work as tilt indicator, it has to be held still, so that the acceleration due to gravity gives a reliable direction for "straight down". Any acceleration due to your motion will confuse the calculation. ALSO, there can't be any stray magnetic fields nearby, like those due to steel or iron on a bike, as those can affect the direction of the measured magnetic field. That can be a very strong effect, completely confusing the compass directions.

You should experiment with the LSM303 by writing a short program to print out values for the X, Y and Z components of the acceleration and the magnetic field vectors, and see how strongly those are influenced by your bike and typical motion while cycling. These effects could make it very difficult to produce a reliable brake light.