Controlling an AD5291 digipot

Hi folks,

Question from a newbie!

I'd like to control volume through the DigiPot AD5291 from Analog Devices.
It's a SPI compatible device, in sum a 16-bit wide shift register, with 6 fixed start bits (from the MSB side),
The 'WRITE' command always starts with the sequence '000001' , the last LSB's are don't care.
The following the complete sequence:

15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
===============================================
 0  0  0  0  0  1 D7 D6 D5 D4 D3 D2 D1 D0  X  X

I was thinking of using a rotary encoder to control the volume.
On the Arduino playground 'rotaryEncoders' there are interesting sketches.

In sum, I will read the movement of the encoder, store in a volatile variable, something like:

volatile unsigned int encoder0Pos = 0;

Now my question:

How do I put the 8-bit value from the encoder0Pos variable into the AD5291 sequence?

I was thinking of first declaring another unsigned int variable, such as

unsigned int commVol = 0x400; // command sequence: '0b0000010000000000'

unsigned int Vol0 = 0;	// whole 16-bit value to send to the AD5291

which stores the command line in the upper byte,
but how do I overwrite the encoder0Pos value (lower 8 bits, shifted 2 position left) onto this Vol0 variable
to send to the AD5291 shift register in the correct way?

I hope all's clear.

Any suggestion greatly appreciated.
TIA.

No one?

Use

valueToSend = ( encoder0Pos << 2 ) | 0x400;

an OR mask! Sure!

Thanks for your helpful answer!