?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 * Palette Support
4 *****************************************************************************
5 * FileName: Palette.c
6 * Dependencies: Graphics.h
7 * Processor: PIC24, PIC32
8 * Compiler: MPLAB C30 V3.00, MPLAB C32
9 * Linker: MPLAB LINK30, MPLAB LINK32
10 * Company: Microchip Technology Incorporated
11 *
12 * Software License Agreement
13 *
14 * Copyright © 2008 Microchip Technology Inc. All rights reserved.
15 * Microchip licenses to you the right to use, modify, copy and distribute
16 * Software only when embedded on a Microchip microcontroller or digital
17 * signal controller, which is integrated into your product or third party
18 * product (pursuant to the sublicense terms in the accompanying license
19 * agreement).
20 *
21 * You should refer to the license agreement accompanying this Software
22 * for additional information regarding your rights and obligations.
23 *
24 * SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY
25 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
26 * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
27 * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
28 * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION,
29 * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT
30 * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
31 * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
32 * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY
33 * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
34 * OR OTHER SIMILAR COSTS.
35 *
36 * Author Date Comment
37 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 * Pradeep Budagutta 11/06/09 Version 1.0 release
39 *****************************************************************************/
40 #include "Graphics\Palette.h"
41  
42 #ifdef USE_PALETTE
43  
44 BYTE PaletteBpp;
45 BYTE blPaletteChangeError;
46 void *pPendingPalette;
47 WORD PendingStartEntry;
48 WORD PendingLength;
49  
50 /*********************************************************************
51 * Function: void RequestPaletteChange(void *pPalette, WORD startEntry, WORD length)
52 *
53 * Overview: Loads the palettes from the flash during vertical blanking period
54 * if possible, otherwise loads immediately.
55 *
56 * PreCondition: PaletteInit() must be called before.
57 *
58 * Input: pPalette - Pointer to the palette structure
59 * startEntry - Start entry to load (inclusive)
60 * length - Number of entries
61 *
62 * Output: none
63 *
64 * Side Effects: There may be a slight flicker when the Palette entries
65 * are getting loaded one by one.
66 *
67 ********************************************************************/
68 void RequestPaletteChange(void *pPalette, WORD startEntry, WORD length)
69 {
70 pPendingPalette = pPalette;
71 PendingStartEntry = startEntry;
72 PendingLength = length;
73 StartVBlankInterrupt();
74 }
75  
76 /*********************************************************************
77 * Function: BYTE SetPalette(void *pPalette, WORD startEntry, WORD length)
78 *
79 * Overview: Loads the palettes from the flash immediately.
80 *
81 * PreCondition: PaletteInit() must be called before.
82 *
83 * Input: pPalette - Pointer to the palette structure
84 * startEntry - Start entry to load (inclusive)
85 * length - Number of entries
86 *
87 * Output: Status: Zero -> Success, Non-zero -> Error.
88 *
89 * Side Effects: There may be a slight flicker when the Palette entries
90 * are getting loaded one by one.
91 *
92 ********************************************************************/
93 BYTE SetPalette(void *pPalette, WORD startEntry, WORD length)
94 {
95 BYTE status = -1;
96 PALETTE_FLASH *pPaletteFlash;
97 #ifdef USE_PALETTE_EXTERNAL
98 WORD i;
99 PALETTE_ENTRY paletteEntry;
100 PALETTE_HEADER header;
101 #endif
102  
103 switch(*((SHORT *)pPalette))
104 {
105 case FLASH:
106 pPaletteFlash = (PALETTE_FLASH *)pPalette;
107 if(length > pPaletteFlash->header.length)
108 {
109 length = pPaletteFlash->header.length;
110 }
111  
112 status = SetPaletteFlash(pPaletteFlash->pPaletteEntry, startEntry, length);
113 break;
114  
115 #ifdef USE_PALETTE_EXTERNAL
116 case EXTERNAL:
117 ExternalMemoryCallback(pPalette, 0, sizeof(PALETTE_HEADER), &header);
118 if(length > header.length)
119 {
120 length = header.length;
121 }
122  
123 status = 0;
124 for(i = 0; i < length; i++)
125 {
126 ExternalMemoryCallback(pPalette, sizeof(PALETTE_HEADER) + (i * sizeof(paletteEntry)), sizeof(paletteEntry), (void*)&paletteEntry);
127 status += SetPaletteFlash(&paletteEntry, startEntry + i, 1);
128 }
129 break;
130 #endif
131 }
132  
133 return (status);
134 }
135  
136 /*********************************************************************
137 * Function: BYTE GetPaletteChangeError(void)
138 *
139 * Overview: Returns the Palette change error status
140 *
141 * PreCondition: none
142 *
143 * Input: none
144 *
145 * Output: NoError -> Zero; Error -> Non Zero
146 *
147 * Side Effects: none
148 *
149 ********************************************************************/
150 BYTE GetPaletteChangeError(void)
151 {
152 return (blPaletteChangeError);
153 }
154  
155 /*********************************************************************
156 * Function: void ClearPaletteChangeError(void)
157 *
158 * Overview: Clears the Palette change error status
159 *
160 * PreCondition: none
161 *
162 * Input: none
163 *
164 * Output: none
165 *
166 * Side Effects: none
167 *
168 ********************************************************************/
169 void ClearPaletteChangeError(void)
170 {
171 blPaletteChangeError = 0;
172 }
173  
174 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3