Epson Research and Development

Page 27

Vancouver Design Center

 

 

 

4.2.2 Examples

For the examples in this section assume that the display system has been set up to view a 640x480 pixel image in a 320x200 viewport. Refer to Section 2.2, “Register Initialization” on page 9 and Section 4.1, “Virtual Display” on page 23 for assistance with these settings.

Example 4: Panning - Right and Left

To pan to the right, increment the pixel pan value. If the pixel pan value is now equal to the current color depth then set the pixel pan value to zero and increment the start address value. To pan to the left decrement the pixel pan value. If the pixel pan value is now less than zero set it to the color depth (bpp) less one and decrement the start address value.

The following pans to the right by one pixel in 4 bpp display mode.

1.It’s better to keep one value (call it pan_value) to track both the pixel panning and start address rather than maintain separate values for each of these.

2.To pan to the right increment pan_value. pan_value = pan_value + 1

3.Mask off the values from pan_value for the pixel panning and start address register portions. In this case, 4 bpp, the lower two bits are the pixel panning value and the upper bits are the start address.

pixel_pan = pan_value AND 3

start_address = pan_value SHR 3

(shift right by 3 gives words)

4.Write the pixel panning and start address values to their respective registers using the proce- dure outlined in the registers section.

Example 5: Scrolling - Up and Down

To scroll down, increase the value in the Screen 1 Display Start Address Register by the number of words in one virtual scan line. To scroll up, decrease the value in the Screen 1 Display Start Address Register by the number of words in one virtual scan line.

Example 6: Scroll down one line for a 16 color 640x480 virtual image using a 320x240 single panel LCD.

1.To scroll down we need to know how many words each line takes up. At sixteen colors (4 bpp) each byte contains two pixels so each word contains 4 pixels.

words (offset) = pixels_per_line / pixels_per_word = 640 / 4 = 160 = 0xA0 We now know how much to add to the start address to scroll down one line.

2.Increment the start address by the number of words per virtual line. start_address = start_address + words

3.Separate the start address value into three bytes. Write the LSB to register [10h] and the MSB to register [12h].

Programming Notes and Examples

S1D13504

Issue Date: 01/02/01

X19A-G-002-07

Page 165
Image 165
Epson S1D13504 manual Example 4 Panning Right and Left