Hi,
The procedure should be as follow:
Compare the current position with the last position, if y is positive then it's going up, if y is negative, it's going down.
Don't use any waiting or tricks, it's actually very simple.
I have attached a working sample, with two different execution of the procedure, one where it compares every x seconds, and another one where it switches states instead. The second one means duplication of comparision procedure, but that can also be optimized if an fsm is only responsible for getting the delta movement. But I did not wanted to complexify the example.
Bye,
Jean