As long as i understand, you only want values when your data changes it's state, from ascending to high, and from descending to low, so you should put a case statement inside the loop, and use a shift register. In the case statement, just pass array data if state does not change, and if state changes use build array to add data to the shift register. To achieve this, you need a state change variable wired to the case statement.
Hope this helps