simulate this circuit – Schematic created using CircuitLab
Figure 1. 2-bit rotary encoder waveforms.
A rotary encoder works by outputting a pair of quadrature (90° offset) pulse trains. These are used to run an up-down counter to keep track of the position. A suitable control algorithm would be as follows:
- Track the current state of 'A'. If the state changes to 'high' then:
- Look at input 'B'. If 'B' is low then count up. If 'B' is high then count down.
To get an encoder to do what you want you will need to add some logic to see if it's counting up (clockwise) or down (anti-clockwise) and pass the pulses to the appropriate button input. You won't need to keep track of the actual count.
Figure 2. Extracting up and down pulses.
This schematic is to get you started on a solution. A CD4013 D-type flip-flop will update its outputs on each positive-going clock transition based on the 'D' input. Depending on the direction of the encoder rotation either Q or /Q (not Q) will be high. ANDing (or NANDing) these signals with either A or B will give either an UP or DOWN pulse train.
Figure 3. Extract from CD4013 datasheet.
Your next problems will be:
- How to interface these with the phone. Have a look at CD4016 switches.
- What happens if the encoder stops with the UP or DOWN stuck on? This may not be a problem if the encoder detents line up consistently with an on or off position of one of the A or B contacts.
Over to you. I'm done.