?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*****************************************************************************
2 * Module for Microchip Graphics Library
3 * LCD controller driver
4 * Solomon Systech. SSD1289
5 * Solomon Systech. SSD2119
6 *****************************************************************************
7 * FileName: drvTFT002.c
8 * Dependencies: Graphics.h
9 * Processor: PIC24, PIC32
10 * Compiler: MPLAB C30, MPLAB C32
11 * Linker: MPLAB LINK30, MPLAB LINK32
12 * Company: Microchip Technology Incorporated
13 *
14 * Software License Agreement
15 *
16 * Copyright © 2009 Microchip Technology Inc. All rights reserved.
17 * Microchip licenses to you the right to use, modify, copy and distribute
18 * Software only when embedded on a Microchip microcontroller or digital
19 * signal controller, which is integrated into your product or third party
20 * product (pursuant to the sublicense terms in the accompanying license
21 * agreement).
22 *
23 * You should refer to the license agreement accompanying this Software
24 * for additional information regarding your rights and obligations.
25 *
26 * SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY
27 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
28 * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
29 * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
30 * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION,
31 * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT
32 * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
33 * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
34 * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY
35 * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
36 * OR OTHER SIMILAR COSTS.
37 *
38 * Author Date Comment
39 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40 * Anton Alkhimenok 05/29/09
41 *****************************************************************************/
42 #include "Graphics\Graphics.h"
43  
44 // Color
45 WORD _color;
46  
47 // Clipping region control
48 SHORT _clipRgn;
49  
50 // Clipping region borders
51 SHORT _clipLeft;
52 SHORT _clipTop;
53 SHORT _clipRight;
54 SHORT _clipBottom;
55  
56 /////////////////////// LOCAL FUNCTIONS PROTOTYPES ////////////////////////////
57 void SetReg(WORD index, WORD value);
58 void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
59 void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
60 void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
61 void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
62  
63 void PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
64 void PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
65 void PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
66 void PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
67  
68 /*********************************************************************
69 * Macro: WritePixel(color)
70 *
71 * PreCondition: none
72 *
73 * Input: color
74 *
75 * Output: none
76 *
77 * Side Effects: none
78 *
79 * Overview: writes pixel at the current address
80 *
81 * Note: chip select should be enabled
82 *
83 ********************************************************************/
84 #ifdef USE_16BIT_PMP
85 #define WritePixel(color) DeviceWrite(color)
86 #else
87 #define WritePixel(color) { DeviceWrite(((WORD_VAL)color).v[1]); DeviceWrite(((WORD_VAL)color).v[0]);}
88 #endif
89  
90 /*********************************************************************
91 * Macros: SetAddress(addr2,addr1,addr0)
92 *
93 * Overview: Writes address pointer.
94 *
95 * PreCondition: none
96 *
97 * Input: addr0 - Lower byte of the address.
98 * addr1 - Middle byte of the address.
99 * addr2 - Upper byte of the address.
100 *
101 * Output: none
102 *
103 * Side Effects: none
104 *
105 ********************************************************************/
106 inline void SetAddress(WORD x, WORD y)
107 {
108 DeviceSetCommand();
109  
110 #ifdef USE_16BIT_PMP
111 #if (DISP_ORIENTATION == 0)
112 DeviceWrite(0x004e);
113 #else
114 DeviceWrite(0x004f);
115 #endif
116 #else
117 #if (DISP_ORIENTATION == 0)
118 DeviceWrite(0);
119 DeviceWrite(0x4e);
120 #else
121 DeviceWrite(0);
122 DeviceWrite(0x4f);
123 #endif
124 #endif
125  
126 DeviceSetData();
127 #ifdef USE_16BIT_PMP
128 DeviceWrite(x);
129 #else
130 DeviceWrite(((WORD_VAL)x).v[1]);
131 DeviceWrite(((WORD_VAL)x).v[0]);
132 #endif
133  
134 DeviceSetCommand();
135 #ifdef USE_16BIT_PMP
136 #if (DISP_ORIENTATION == 0)
137 DeviceWrite(0x004f);
138 #else
139 DeviceWrite(0x004e);
140 #endif
141 #else
142 #if (DISP_ORIENTATION == 0)
143 DeviceWrite(0);
144 DeviceWrite(0x4f);
145 #else
146 DeviceWrite(0);
147 DeviceWrite(0x4e);
148 #endif
149 #endif
150  
151 DeviceSetData();
152 #ifdef USE_16BIT_PMP
153 DeviceWrite(y);
154 #else
155 DeviceWrite(((WORD_VAL)y).v[1]);
156 DeviceWrite(((WORD_VAL)y).v[0]);
157 #endif
158  
159 DeviceSetCommand();
160 #ifdef USE_16BIT_PMP
161 DeviceWrite(0x0022);
162 #else
163 DeviceWrite(0);
164 DeviceWrite(0x22);
165 #endif
166 DeviceSetData();
167 }
168  
169 /*********************************************************************
170 * Function: void SetReg(BYTE index, WORD value)
171 *
172 * PreCondition: none
173 *
174 * Input: index - register number
175 * value - value to be set
176 *
177 * Output: none
178 *
179 * Side Effects: none
180 *
181 * Overview: sets graphics controller register
182 *
183 * Note: none
184 *
185 ********************************************************************/
186 void SetReg(WORD index, WORD value)
187 {
188  
189 DeviceSelect();
190 DeviceSetCommand();
191 #ifdef USE_16BIT_PMP
192 DeviceWrite(index);
193 #else
194 DeviceWrite(((WORD_VAL)index).v[1]);
195 DeviceWrite(((WORD_VAL)index).v[0]);
196 #endif
197 DeviceSetData();
198 #ifdef USE_16BIT_PMP
199 DeviceWrite(value);
200 #else
201 DeviceWrite(((WORD_VAL)value).v[1]);
202 DeviceWrite(((WORD_VAL)value).v[0]);
203 #endif
204 DeviceDeselect();
205 }
206  
207 /*********************************************************************
208 * Function: void ResetDevice()
209 *
210 * PreCondition: none
211 *
212 * Input: none
213 *
214 * Output: none
215 *
216 * Side Effects: none
217 *
218 * Overview: resets LCD, initializes PMP
219 *
220 * Note: none
221 *
222 ********************************************************************/
223 void ResetDevice(void)
224 {
225  
226 // Initialize the device
227 DeviceInit();
228  
229  
230 // Setup display
231 #if (DISPLAY_CONTROLLER == SSD1289)
232  
233 /////////////////////////////////////////////////////////
234 SetReg(0x00, 0x0001);
235 SetReg(0x03, 0xAAAC);
236 SetReg(0x0C, 0x0002);
237 DelayMs(15);
238 SetReg(0x0D, 0x000A);
239 SetReg(0x0E, 0x2D00);
240 SetReg(0x1E, 0x00BC);
241  
242 SetReg(0x01, 0x1A0C);
243  
244 DelayMs(15);
245 #if (DISP_ORIENTATION == 0)
246 SetReg(0x01, 0x2B3F);
247 #else
248 SetReg(0x01, 0x293F);
249 #endif
250 SetReg(0x02, 0x0600);
251 SetReg(0x10, 0x0000);
252  
253 #if (DISP_ORIENTATION == 0)
254 SetReg(0x11, 0x60B0);
255 #else
256 SetReg(0x11, 0x60B8);
257 #endif
258 SetReg(0x05, 0x0000);
259 SetReg(0x06, 0x0000);
260 DelayMs(100);
261 SetReg(0x16, 0xEF1C);
262 SetReg(0x17, 0x0003);
263 SetReg(0x07, 0x0233);
264 SetReg(0x0B, 0x0000);
265 SetReg(0x0F, 0x0000);
266 SetReg(0x41, 0x0000);
267 SetReg(0x42, 0x0000);
268 SetReg(0x48, 0x0000);
269 SetReg(0x49, 0x013F);
270 SetReg(0x44, 0xEF00);
271 SetReg(0x45, 0x0000);
272 SetReg(0x46, 0x013F);
273 SetReg(0x4A, 0x0000);
274 SetReg(0x4B, 0x0000);
275 SetReg(0x30, 0x0707);
276 SetReg(0x31, 0x0704);
277 SetReg(0x32, 0x0204);
278 SetReg(0x33, 0x0502);
279 SetReg(0x34, 0x0507);
280 SetReg(0x35, 0x0204);
281 SetReg(0x36, 0x0204);
282 SetReg(0x37, 0x0502);
283 SetReg(0x3A, 0x0302);
284 SetReg(0x3B, 0x1f00);
285 SetReg(0x23, 0x0000);
286 SetReg(0x24, 0x0000);
287  
288 #elif (DISPLAY_CONTROLLER == SSD2119)
289 SetReg(0x0028, 0x0006); // VCOM OTP, page 55-56 of datasheet
290 SetReg(0x0000, 0x0001); // start Oscillator, page 36 of datasheet
291 SetReg(0x0010, 0x0000); // Sleep mode, page 49 of datasheet
292 #if (DISP_ORIENTATION == 0)
293 SetReg(0x0001, 0x72EF); // Driver Output Control, page 36-39 of datasheet
294 #else
295 SetReg(0x0001, 0x32EF); // Driver Output Control, page 36-39 of datasheet
296 #endif
297 SetReg(0x0002, 0x0600); // LCD Driving Waveform Control, page 40-42 of datasheet
298 SetReg(0x0003, 0x6A38); // Power Control 1, page 43-44 of datasheet
299 #if (DISP_ORIENTATION == 0)
300 SetReg(0x0011, 0x6870); // Entry Mode, page 50-52 of datasheet
301 #else
302 SetReg(0x0011, 0x6878); // Entry Mode, page 50-52 of datasheet
303 #endif
304 SetReg(0x000F, 0x0000); // Gate Scan Position, page 49 of datasheet
305 SetReg(0x000B, 0x5308); // Frame Cycle Control, page 45 of datasheet
306 SetReg(0x000C, 0x0003); // Power Control 2, page 47 of datasheet
307 SetReg(0x000D, 0x000A); // Power Control 3, page 48 of datasheet
308 SetReg(0x000E, 0x2E00); // Power Control 4, page 48 of datasheet
309 SetReg(0x001E, 0x00BE); // Power Control 5, page 53 of datasheet
310 SetReg(0x0025, 0x8000); // Frame Frequency Control, page 53 of datasheet
311 SetReg(0x0026, 0x7800); // Analog setting, page 54 of datasheet
312 SetReg(0x004E, 0x0000); // Ram Address Set, page 58 of datasheet
313 SetReg(0x004F, 0x0000); // Ram Address Set, page 58 of datasheet
314 SetReg(0x0012, 0x08D9); // Sleep mode, page 49 of datasheet
315  
316 // Gamma Control (R30h to R3Bh) -- page 56 of datasheet
317 SetReg(0x0030, 0x0000);
318 SetReg(0x0031, 0x0104);
319 SetReg(0x0032, 0x0100);
320 SetReg(0x0033, 0x0305);
321 SetReg(0x0034, 0x0505);
322 SetReg(0x0035, 0x0305);
323 SetReg(0x0036, 0x0707);
324 SetReg(0x0037, 0x0300);
325 SetReg(0x003A, 0x1200);
326 SetReg(0x003B, 0x0800);
327  
328 SetReg(0x0007, 0x0033); // Display Control, page 45 of datasheet
329 #endif
330 DelayMs(50);
331 }
332  
333 /*********************************************************************
334 * Function: void PutPixel(SHORT x, SHORT y)
335 *
336 * PreCondition: none
337 *
338 * Input: x,y - pixel coordinates
339 *
340 * Output: none
341 *
342 * Side Effects: none
343 *
344 * Overview: puts pixel
345 *
346 * Note: none
347 *
348 ********************************************************************/
349 void PutPixel(SHORT x, SHORT y)
350 {
351 DWORD_VAL address;
352 if(_clipRgn)
353 {
354 if(x < _clipLeft)
355 return;
356 if(x > _clipRight)
357 return;
358 if(y < _clipTop)
359 return;
360 if(y > _clipBottom)
361 return;
362 }
363  
364 CS_LAT_BIT = 0;
365 SetAddress(x, y);
366 WritePixel(_color);
367 CS_LAT_BIT = 1;
368 }
369  
370 /*********************************************************************
371 * Function: WORD GetPixel(SHORT x, SHORT y)
372 *
373 * PreCondition: none
374 *
375 * Input: x,y - pixel coordinates
376 *
377 * Output: pixel color
378 *
379 * Side Effects: none
380 *
381 * Overview: returns pixel color at x,y position
382 *
383 * Note: none
384 *
385 ********************************************************************/
386 WORD GetPixel(SHORT x, SHORT y)
387 {
388 return (0);
389 }
390  
391 /*********************************************************************
392 * Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
393 *
394 * PreCondition: none
395 *
396 * Input: left,top - top left corner coordinates,
397 * right,bottom - bottom right corner coordinates
398 *
399 * Output: none
400 *
401 * Side Effects: none
402 *
403 * Overview: draws rectangle filled with current color
404 *
405 * Note: none
406 *
407 ********************************************************************/
408 WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
409 {
410 register SHORT x, y;
411  
412 #ifndef USE_NONBLOCKING_CONFIG
413 while(IsDeviceBusy() != 0);
414  
415 /* Ready */
416 #else
417 if(IsDeviceBusy() != 0)
418 return (0);
419 #endif
420 if(_clipRgn)
421 {
422 if(left < _clipLeft)
423 left = _clipLeft;
424 if(right > _clipRight)
425 right = _clipRight;
426 if(top < _clipTop)
427 top = _clipTop;
428 if(bottom > _clipBottom)
429 bottom = _clipBottom;
430 }
431  
432 CS_LAT_BIT = 0;
433 for(y = top; y < bottom + 1; y++)
434 {
435 SetAddress(left, y);
436 for(x = left; x < right + 1; x++)
437 {
438 WritePixel(_color);
439 }
440 }
441  
442 CS_LAT_BIT = 1;
443 return (1);
444 }
445  
446 /*********************************************************************
447 * Function: void ClearDevice(void)
448 *
449 * PreCondition: none
450 *
451 * Input: none
452 *
453 * Output: none
454 *
455 * Side Effects: none
456 *
457 * Overview: clears screen with current color
458 *
459 * Note: none
460 *
461 ********************************************************************/
462 void ClearDevice(void)
463 {
464 DWORD counter;
465  
466 CS_LAT_BIT = 0;
467 SetAddress(0, 0);
468 for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++)
469 {
470 WritePixel(_color);
471 }
472  
473 CS_LAT_BIT = 1;
474 }
475  
476 /*********************************************************************
477 * Function: WORD PutImage(SHORT left, SHORT top, void* bitmap, BYTE stretch)
478 *
479 * PreCondition: none
480 *
481 * Input: left,top - left top image corner,
482 * bitmap - image pointer,
483 * stretch - image stretch factor
484 *
485 * Output: none
486 *
487 * Side Effects: none
488 *
489 * Overview: outputs image starting from left,top coordinates
490 *
491 * Note: image must be located in flash
492 *
493 ********************************************************************/
494 #ifdef USE_DRV_PUTIMAGE
495  
496 /* */
497 WORD PutImage(SHORT left, SHORT top, void *bitmap, BYTE stretch)
498 {
499 FLASH_BYTE *flashAddress;
500 BYTE colorDepth;
501 WORD colorTemp;
502  
503 #ifndef USE_NONBLOCKING_CONFIG
504 while(IsDeviceBusy() != 0);
505  
506 /* Ready */
507 #else
508 if(IsDeviceBusy() != 0)
509 return (0);
510 #endif
511  
512 // Save current color
513 colorTemp = _color;
514  
515 switch(*((SHORT *)bitmap))
516 {
517 #ifdef USE_BITMAP_FLASH
518  
519 case FLASH:
520  
521 // Image address
522 flashAddress = ((BITMAP_FLASH *)bitmap)->address;
523  
524 // Read color depth
525 colorDepth = *(flashAddress + 1);
526  
527 // Draw picture
528 switch(colorDepth)
529 {
530 case 1: PutImage1BPP(left, top, flashAddress, stretch); break;
531 case 4: PutImage4BPP(left, top, flashAddress, stretch); break;
532 case 8: PutImage8BPP(left, top, flashAddress, stretch); break;
533 case 16: PutImage16BPP(left, top, flashAddress, stretch); break;
534 }
535  
536 break;
537 #endif
538 #ifdef USE_BITMAP_EXTERNAL
539  
540 case EXTERNAL:
541  
542 // Get color depth
543 ExternalMemoryCallback(bitmap, 1, 1, &colorDepth);
544  
545 // Draw picture
546 switch(colorDepth)
547 {
548 case 1: PutImage1BPPExt(left, top, bitmap, stretch); break;
549 case 4: PutImage4BPPExt(left, top, bitmap, stretch); break;
550 case 8: PutImage8BPPExt(left, top, bitmap, stretch); break;
551 case 16: PutImage16BPPExt(left, top, bitmap, stretch); break;
552 default: break;
553 }
554  
555 break;
556 #endif
557  
558 default:
559 break;
560 }
561  
562 // Restore current color
563 _color = colorTemp;
564 return (1);
565 }
566  
567 #ifdef USE_BITMAP_FLASH
568  
569 /*********************************************************************
570 * Function: void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
571 *
572 * PreCondition: none
573 *
574 * Input: left,top - left top image corner,
575 * bitmap - image pointer,
576 * stretch - image stretch factor
577 *
578 * Output: none
579 *
580 * Side Effects: none
581 *
582 * Overview: outputs monochrome image starting from left,top coordinates
583 *
584 * Note: image must be located in flash
585 *
586 ********************************************************************/
587 void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
588 {
589 register FLASH_BYTE *flashAddress;
590 register FLASH_BYTE *tempFlashAddress;
591 BYTE temp;
592 WORD sizeX, sizeY;
593 WORD x, y;
594 BYTE stretchX, stretchY;
595 WORD pallete[2];
596 BYTE mask;
597  
598 // Move pointer to size information
599 flashAddress = bitmap + 2;
600  
601 // Read image size
602 sizeY = *((FLASH_WORD *)flashAddress);
603 flashAddress += 2;
604 sizeX = *((FLASH_WORD *)flashAddress);
605 flashAddress += 2;
606 pallete[0] = *((FLASH_WORD *)flashAddress);
607 flashAddress += 2;
608 pallete[1] = *((FLASH_WORD *)flashAddress);
609 flashAddress += 2;
610  
611 CS_LAT_BIT = 0;
612 for(y = 0; y < sizeY; y++)
613 {
614 tempFlashAddress = flashAddress;
615 for(stretchY = 0; stretchY < stretch; stretchY++)
616 {
617 flashAddress = tempFlashAddress;
618 SetAddress(left, top);
619 mask = 0;
620 for(x = 0; x < sizeX; x++)
621 {
622  
623 // Read 8 pixels from flash
624 if(mask == 0)
625 {
626 temp = *flashAddress;
627 flashAddress++;
628 mask = 0x80;
629 }
630  
631 // Set color
632 if(mask & temp)
633 {
634 SetColor(pallete[1]);
635 }
636 else
637 {
638 SetColor(pallete[0]);
639 }
640  
641 // Write pixel to screen
642 for(stretchX = 0; stretchX < stretch; stretchX++)
643 {
644 WritePixel(_color);
645 }
646  
647 // Shift to the next pixel
648 mask >>= 1;
649 }
650  
651 top++;
652 }
653 }
654  
655 CS_LAT_BIT = 1;
656 }
657  
658 /*********************************************************************
659 * Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
660 *
661 * PreCondition: none
662 *
663 * Input: left,top - left top image corner, bitmap - image pointer,
664 * stretch - image stretch factor
665 *
666 * Output: none
667 *
668 * Side Effects: none
669 *
670 * Overview: outputs 16 color image starting from left,top coordinates
671 *
672 * Note: image must be located in flash
673 *
674 ********************************************************************/
675 void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
676 {
677 register FLASH_BYTE *flashAddress;
678 register FLASH_BYTE *tempFlashAddress;
679 WORD sizeX, sizeY;
680 register WORD x, y;
681 BYTE temp;
682 register BYTE stretchX, stretchY;
683 WORD pallete[16];
684 WORD counter;
685  
686 // Move pointer to size information
687 flashAddress = bitmap + 2;
688  
689 // Read image size
690 sizeY = *((FLASH_WORD *)flashAddress);
691 flashAddress += 2;
692 sizeX = *((FLASH_WORD *)flashAddress);
693 flashAddress += 2;
694  
695 // Read pallete
696 for(counter = 0; counter < 16; counter++)
697 {
698 pallete[counter] = *((FLASH_WORD *)flashAddress);
699 flashAddress += 2;
700 }
701  
702 CS_LAT_BIT = 0;
703 for(y = 0; y < sizeY; y++)
704 {
705 tempFlashAddress = flashAddress;
706 for(stretchY = 0; stretchY < stretch; stretchY++)
707 {
708 flashAddress = tempFlashAddress;
709 SetAddress(left, top);
710 for(x = 0; x < sizeX; x++)
711 {
712  
713 // Read 2 pixels from flash
714 if(x & 0x0001)
715 {
716  
717 // second pixel in byte
718 SetColor(pallete[temp >> 4]);
719 }
720 else
721 {
722 temp = *flashAddress;
723 flashAddress++;
724  
725 // first pixel in byte
726 SetColor(pallete[temp & 0x0f]);
727 }
728  
729 // Write pixel to screen
730 for(stretchX = 0; stretchX < stretch; stretchX++)
731 {
732 WritePixel(_color);
733 }
734 }
735  
736 top++;
737 }
738 }
739  
740 CS_LAT_BIT = 1;
741 }
742  
743 /*********************************************************************
744 * Function: void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
745 *
746 * PreCondition: none
747 *
748 * Input: left,top - left top image corner, bitmap - image pointer,
749 * stretch - image stretch factor
750 *
751 * Output: none
752 *
753 * Side Effects: none
754 *
755 * Overview: outputs 256 color image starting from left,top coordinates
756 *
757 * Note: image must be located in flash
758 *
759 ********************************************************************/
760 void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
761 {
762 register FLASH_BYTE *flashAddress;
763 register FLASH_BYTE *tempFlashAddress;
764 WORD sizeX, sizeY;
765 WORD x, y;
766 BYTE temp;
767 BYTE stretchX, stretchY;
768 WORD pallete[256];
769 WORD counter;
770  
771 // Move pointer to size information
772 flashAddress = bitmap + 2;
773  
774 // Read image size
775 sizeY = *((FLASH_WORD *)flashAddress);
776 flashAddress += 2;
777 sizeX = *((FLASH_WORD *)flashAddress);
778 flashAddress += 2;
779  
780 // Read pallete
781 for(counter = 0; counter < 256; counter++)
782 {
783 pallete[counter] = *((FLASH_WORD *)flashAddress);
784 flashAddress += 2;
785 }
786  
787 CS_LAT_BIT = 0;
788 for(y = 0; y < sizeY; y++)
789 {
790 tempFlashAddress = flashAddress;
791 for(stretchY = 0; stretchY < stretch; stretchY++)
792 {
793 flashAddress = tempFlashAddress;
794 SetAddress(left, top);
795 for(x = 0; x < sizeX; x++)
796 {
797  
798 // Read pixels from flash
799 temp = *flashAddress;
800 flashAddress++;
801  
802 // Set color
803 SetColor(pallete[temp]);
804  
805 // Write pixel to screen
806 for(stretchX = 0; stretchX < stretch; stretchX++)
807 {
808 WritePixel(_color);
809 }
810 }
811  
812 top++;
813 }
814 }
815  
816 CS_LAT_BIT = 1;
817 }
818  
819 /*********************************************************************
820 * Function: void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
821 *
822 * PreCondition: none
823 *
824 * Input: left,top - left top image corner, bitmap - image pointer,
825 * stretch - image stretch factor
826 *
827 * Output: none
828 *
829 * Side Effects: none
830 *
831 * Overview: outputs hicolor image starting from left,top coordinates
832 *
833 * Note: image must be located in flash
834 *
835 ********************************************************************/
836 void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
837 {
838 register FLASH_WORD *flashAddress;
839 register FLASH_WORD *tempFlashAddress;
840 WORD sizeX, sizeY;
841 register WORD x, y;
842 WORD temp;
843 register BYTE stretchX, stretchY;
844  
845 // Move pointer to size information
846 flashAddress = (FLASH_WORD *)bitmap + 1;
847  
848 // Read image size
849 sizeY = *flashAddress;
850 flashAddress++;
851 sizeX = *flashAddress;
852 flashAddress++;
853  
854 CS_LAT_BIT = 0;
855 for(y = 0; y < sizeY; y++)
856 {
857 tempFlashAddress = flashAddress;
858 for(stretchY = 0; stretchY < stretch; stretchY++)
859 {
860 flashAddress = tempFlashAddress;
861 SetAddress(left, top); //address.v[2],address.v[1],address.v[0]);
862 for(x = 0; x < sizeX; x++)
863 {
864  
865 // Read pixels from flash
866 temp = *flashAddress;
867 flashAddress++;
868  
869 // Set color
870 SetColor(temp);
871  
872 // Write pixel to screen
873 for(stretchX = 0; stretchX < stretch; stretchX++)
874 {
875 WritePixel(_color);
876 }
877 }
878  
879 top++;
880 }
881 }
882  
883 CS_LAT_BIT = 1;
884 }
885  
886 #endif
887 #ifdef USE_BITMAP_EXTERNAL
888  
889 /*********************************************************************
890 * Function: void PutImage1BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
891 *
892 * PreCondition: none
893 *
894 * Input: left,top - left top image corner, bitmap - image pointer,
895 * stretch - image stretch factor
896 *
897 * Output: none
898 *
899 * Side Effects: none
900 *
901 * Overview: outputs monochrome image starting from left,top coordinates
902 *
903 * Note: image must be located in external memory
904 *
905 ********************************************************************/
906 void PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
907 {
908 register DWORD memOffset;
909 BITMAP_HEADER bmp;
910 WORD pallete[2];
911 BYTE lineBuffer[((GetMaxX() + 1) / 8) + 1];
912 BYTE *pData;
913 SHORT byteWidth;
914  
915 BYTE temp;
916 BYTE mask;
917 WORD sizeX, sizeY;
918 WORD x, y;
919 BYTE stretchX, stretchY;
920  
921 // Get bitmap header
922 ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
923  
924 // Get pallete (2 entries)
925 ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 2 * sizeof(WORD), pallete);
926  
927 // Set offset to the image data
928 memOffset = sizeof(BITMAP_HEADER) + 2 * sizeof(WORD);
929  
930 // Line width in bytes
931 byteWidth = bmp.width >> 3;
932 if(bmp.width & 0x0007)
933 byteWidth++;
934  
935 // Get size
936 sizeX = bmp.width;
937 sizeY = bmp.height;
938  
939 for(y = 0; y < sizeY; y++)
940 {
941  
942 // Get line
943 ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
944 memOffset += byteWidth;
945 CS_LAT_BIT = 0;
946 for(stretchY = 0; stretchY < stretch; stretchY++)
947 {
948 pData = lineBuffer;
949 SetAddress(left, top);
950 mask = 0;
951 for(x = 0; x < sizeX; x++)
952 {
953  
954 // Read 8 pixels from flash
955 if(mask == 0)
956 {
957 temp = *pData++;
958 mask = 0x80;
959 }
960  
961 // Set color
962 if(mask & temp)
963 {
964 SetColor(pallete[1]);
965 }
966 else
967 {
968 SetColor(pallete[0]);
969 }
970  
971 // Write pixel to screen
972 for(stretchX = 0; stretchX < stretch; stretchX++)
973 {
974 WritePixel(_color);
975 }
976  
977 // Shift to the next pixel
978 mask >>= 1;
979 }
980  
981 top++;
982 }
983  
984 CS_LAT_BIT = 1;
985 }
986 }
987  
988 /*********************************************************************
989 * Function: void PutImage4BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
990 *
991 * PreCondition: none
992 *
993 * Input: left,top - left top image corner, bitmap - image pointer,
994 * stretch - image stretch factor
995 *
996 * Output: none
997 *
998 * Side Effects: none
999 *
1000 * Overview: outputs monochrome image starting from left,top coordinates
1001 *
1002 * Note: image must be located in external memory
1003 *
1004 ********************************************************************/
1005 void PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
1006 {
1007 register DWORD memOffset;
1008 BITMAP_HEADER bmp;
1009 WORD pallete[16];
1010 BYTE lineBuffer[((GetMaxX() + 1) / 2) + 1];
1011 BYTE *pData;
1012 SHORT byteWidth;
1013  
1014 BYTE temp;
1015 WORD sizeX, sizeY;
1016 WORD x, y;
1017 BYTE stretchX, stretchY;
1018  
1019 // Get bitmap header
1020 ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
1021  
1022 // Get pallete (16 entries)
1023 ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 16 * sizeof(WORD), pallete);
1024  
1025 // Set offset to the image data
1026 memOffset = sizeof(BITMAP_HEADER) + 16 * sizeof(WORD);
1027  
1028 // Line width in bytes
1029 byteWidth = bmp.width >> 1;
1030 if(bmp.width & 0x0001)
1031 byteWidth++;
1032  
1033 // Get size
1034 sizeX = bmp.width;
1035 sizeY = bmp.height;
1036  
1037 for(y = 0; y < sizeY; y++)
1038 {
1039  
1040 // Get line
1041 ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
1042 memOffset += byteWidth;
1043 CS_LAT_BIT = 0;
1044 for(stretchY = 0; stretchY < stretch; stretchY++)
1045 {
1046 pData = lineBuffer;
1047 SetAddress(left, top);
1048  
1049 for(x = 0; x < sizeX; x++)
1050 {
1051  
1052 // Read 2 pixels from flash
1053 if(x & 0x0001)
1054 {
1055  
1056 // second pixel in byte
1057 SetColor(pallete[temp >> 4]);
1058 }
1059 else
1060 {
1061 temp = *pData++;
1062  
1063 // first pixel in byte
1064 SetColor(pallete[temp & 0x0f]);
1065 }
1066  
1067 // Write pixel to screen
1068 for(stretchX = 0; stretchX < stretch; stretchX++)
1069 {
1070 WritePixel(_color);
1071 }
1072 }
1073  
1074 top++;
1075 }
1076  
1077 CS_LAT_BIT = 1;
1078 }
1079 }
1080  
1081 /*********************************************************************
1082 * Function: void PutImage8BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
1083 *
1084 * PreCondition: none
1085 *
1086 * Input: left,top - left top image corner, bitmap - image pointer,
1087 * stretch - image stretch factor
1088 *
1089 * Output: none
1090 *
1091 * Side Effects: none
1092 *
1093 * Overview: outputs monochrome image starting from left,top coordinates
1094 *
1095 * Note: image must be located in external memory
1096 *
1097 ********************************************************************/
1098 void PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
1099 {
1100 register DWORD memOffset;
1101 BITMAP_HEADER bmp;
1102 WORD pallete[256];
1103 BYTE lineBuffer[(GetMaxX() + 1)];
1104 BYTE *pData;
1105  
1106 BYTE temp;
1107 WORD sizeX, sizeY;
1108 WORD x, y;
1109 BYTE stretchX, stretchY;
1110  
1111 // Get bitmap header
1112 ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
1113  
1114 // Get pallete (256 entries)
1115 ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 256 * sizeof(WORD), pallete);
1116  
1117 // Set offset to the image data
1118 memOffset = sizeof(BITMAP_HEADER) + 256 * sizeof(WORD);
1119  
1120 // Get size
1121 sizeX = bmp.width;
1122 sizeY = bmp.height;
1123  
1124 for(y = 0; y < sizeY; y++)
1125 {
1126  
1127 // Get line
1128 ExternalMemoryCallback(bitmap, memOffset, sizeX, lineBuffer);
1129 memOffset += sizeX;
1130 CS_LAT_BIT = 0;
1131 for(stretchY = 0; stretchY < stretch; stretchY++)
1132 {
1133 pData = lineBuffer;
1134 SetAddress(left, top);
1135  
1136 for(x = 0; x < sizeX; x++)
1137 {
1138 temp = *pData++;
1139 SetColor(pallete[temp]);
1140  
1141 // Write pixel to screen
1142 for(stretchX = 0; stretchX < stretch; stretchX++)
1143 {
1144 WritePixel(_color);
1145 }
1146 }
1147  
1148 top++;
1149 }
1150  
1151 CS_LAT_BIT = 1;
1152 }
1153 }
1154  
1155 /*********************************************************************
1156 * Function: void PutImage16BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
1157 *
1158 * PreCondition: none
1159 *
1160 * Input: left,top - left top image corner, bitmap - image pointer,
1161 * stretch - image stretch factor
1162 *
1163 * Output: none
1164 *
1165 * Side Effects: none
1166 *
1167 * Overview: outputs monochrome image starting from left,top coordinates
1168 *
1169 * Note: image must be located in external memory
1170 *
1171 ********************************************************************/
1172 void PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
1173 {
1174 register DWORD memOffset;
1175 BITMAP_HEADER bmp;
1176 WORD lineBuffer[(GetMaxX() + 1)];
1177 WORD *pData;
1178 WORD byteWidth;
1179  
1180 WORD temp;
1181 WORD sizeX, sizeY;
1182 WORD x, y;
1183 BYTE stretchX, stretchY;
1184  
1185 // Get bitmap header
1186 ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);
1187  
1188 // Set offset to the image data
1189 memOffset = sizeof(BITMAP_HEADER);
1190  
1191 // Get size
1192 sizeX = bmp.width;
1193 sizeY = bmp.height;
1194  
1195 byteWidth = sizeX << 1;
1196  
1197 for(y = 0; y < sizeY; y++)
1198 {
1199  
1200 // Get line
1201 ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
1202 memOffset += byteWidth;
1203 CS_LAT_BIT = 0;
1204 for(stretchY = 0; stretchY < stretch; stretchY++)
1205 {
1206 pData = lineBuffer;
1207 SetAddress(left, top);
1208  
1209 for(x = 0; x < sizeX; x++)
1210 {
1211 temp = *pData++;
1212 SetColor(temp);
1213  
1214 // Write pixel to screen
1215 for(stretchX = 0; stretchX < stretch; stretchX++)
1216 {
1217 WritePixel(_color);
1218 }
1219 }
1220  
1221 top++;
1222 }
1223  
1224 CS_LAT_BIT = 1;
1225 }
1226 }
1227  
1228 #endif // USE_DRV_PUTIMAGE
1229 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3