Like I said earlier, read the state of channel B at the rising edge of channel A and you have the direction.