Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /***************************************************************************** |
2 | * Module for Microchip Graphics Library |
||
3 | * Palette Support |
||
4 | ***************************************************************************** |
||
5 | * FileName: Palette.h |
||
6 | * Dependencies: Graphics.h |
||
7 | * Processor: PIC24, PIC32 |
||
8 | * Compiler: MPLAB C30, 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 Initial Release |
||
39 | *****************************************************************************/ |
||
40 | #ifndef _PALETTE_H |
||
41 | #define _PALETTE_H |
||
42 | |||
43 | #include "Graphics\Graphics.h" |
||
44 | |||
45 | #ifdef USE_PALETTE |
||
46 | |||
47 | typedef union |
||
48 | { |
||
49 | WORD value; //16 bits |
||
50 | struct |
||
51 | { |
||
52 | BYTE r : 5; |
||
53 | BYTE g : 6; |
||
54 | BYTE b : 5; |
||
55 | } color; |
||
56 | |||
57 | struct |
||
58 | { |
||
59 | BYTE luma : 4; |
||
60 | } monchrome; |
||
61 | |||
62 | } PALETTE_ENTRY; |
||
63 | |||
64 | typedef struct |
||
65 | { |
||
66 | WORD id; |
||
67 | WORD length; |
||
68 | } PALETTE_HEADER; |
||
69 | |||
70 | typedef struct |
||
71 | { |
||
72 | SHORT type; // must be FLASH |
||
73 | PALETTE_HEADER header; |
||
74 | PALETTE_ENTRY *pPaletteEntry; |
||
75 | } PALETTE_FLASH; |
||
76 | |||
77 | #define PALETTE_EXTERNAL EXTDATA /* PALETTE_EXTERNAL = { PALETTE_HEADER, PALETTE_ENTRIES } */ |
||
78 | |||
79 | /********************************************************************* |
||
80 | * Function: void PaletteInit(void) |
||
81 | * |
||
82 | * Overview: Initializes the CLUT. |
||
83 | * |
||
84 | * PreCondition: none |
||
85 | * |
||
86 | * Input: none |
||
87 | * |
||
88 | * Output: none |
||
89 | * |
||
90 | * Side Effects: Drawing mode will change to support palettes |
||
91 | * |
||
92 | ********************************************************************/ |
||
93 | void PaletteInit(void); |
||
94 | |||
95 | /********************************************************************* |
||
96 | * Function: void EnablePalette(void) |
||
97 | * |
||
98 | * Overview: Enables the Palette mode |
||
99 | * |
||
100 | * PreCondition: none |
||
101 | * |
||
102 | * Input: none |
||
103 | * |
||
104 | * Output: none |
||
105 | * |
||
106 | * Side Effects: |
||
107 | * |
||
108 | ********************************************************************/ |
||
109 | void EnablePalette(void); |
||
110 | |||
111 | /********************************************************************* |
||
112 | * Function: void DisablePalette(void) |
||
113 | * |
||
114 | * Overview: Disables the Palette mode |
||
115 | * |
||
116 | * PreCondition: none |
||
117 | * |
||
118 | * Input: none |
||
119 | * |
||
120 | * Output: none |
||
121 | * |
||
122 | * Side Effects: |
||
123 | * |
||
124 | ********************************************************************/ |
||
125 | void DisablePalette(void); |
||
126 | |||
127 | /********************************************************************* |
||
128 | * Function: BYTE IsPaletteEnabled(void) |
||
129 | * |
||
130 | * Overview: Returns if the Palette mode is enabled or not |
||
131 | * |
||
132 | * PreCondition: none |
||
133 | * |
||
134 | * Input: none |
||
135 | * |
||
136 | * Output: Enabled -> 1, Disabled -> 0 |
||
137 | * |
||
138 | * Side Effects: |
||
139 | * |
||
140 | ********************************************************************/ |
||
141 | BYTE IsPaletteEnabled(void); |
||
142 | |||
143 | /********************************************************************* |
||
144 | * Function: BYTE GetPaletteChangeError(void) |
||
145 | * |
||
146 | * Overview: Returns the Palette change error status |
||
147 | * |
||
148 | * PreCondition: none |
||
149 | * |
||
150 | * Input: none |
||
151 | * |
||
152 | * Output: NoError -> Zero; Error -> Non Zero |
||
153 | * |
||
154 | * Side Effects: none |
||
155 | * |
||
156 | ********************************************************************/ |
||
157 | BYTE GetPaletteChangeError(void); |
||
158 | |||
159 | /********************************************************************* |
||
160 | * Function: void ClearPaletteChangeError(void) |
||
161 | * |
||
162 | * Overview: Clears the Palette change error status |
||
163 | * |
||
164 | * PreCondition: none |
||
165 | * |
||
166 | * Input: none |
||
167 | * |
||
168 | * Output: none |
||
169 | * |
||
170 | * Side Effects: none |
||
171 | * |
||
172 | ********************************************************************/ |
||
173 | void ClearPaletteChangeError(void); |
||
174 | |||
175 | /********************************************************************* |
||
176 | * Function: BYTE SetPaletteBpp(BYTE bpp) |
||
177 | * |
||
178 | * Overview: Sets the CLUT's number of valid entries. |
||
179 | * |
||
180 | * PreCondition: PaletteInit() must be called before. |
||
181 | * |
||
182 | * Input: bpp -> Bits per pixel |
||
183 | * |
||
184 | * Output: Status: Zero -> Success, Non-zero -> Error. |
||
185 | * |
||
186 | * Side Effects: Drawing mode will change to support palettes |
||
187 | * |
||
188 | ********************************************************************/ |
||
189 | BYTE SetPaletteBpp(BYTE bpp); |
||
190 | |||
191 | /********************************************************************* |
||
192 | * Function: void RequestPaletteChange(void *pPalette, WORD startEntry, WORD length) |
||
193 | * |
||
194 | * Overview: Loads the palettes from the flash during vertical blanking period |
||
195 | * if possible, otherwise loads immediately. |
||
196 | * |
||
197 | * PreCondition: PaletteInit() must be called before. |
||
198 | * |
||
199 | * Input: pPalette - Pointer to the palette structure |
||
200 | * startEntry - Start entry to load (inclusive) |
||
201 | * length - Number of entries |
||
202 | * |
||
203 | * Output: none |
||
204 | * |
||
205 | * Side Effects: There may be a slight flicker when the Palette entries |
||
206 | * are getting loaded one by one. |
||
207 | * |
||
208 | ********************************************************************/ |
||
209 | void RequestPaletteChange(void *pPalette, WORD startEntry, WORD length); |
||
210 | |||
211 | /********************************************************************* |
||
212 | * Macro: RequestEntirePaletteChange(pPalette) |
||
213 | * |
||
214 | * Overview: Loads all the palette entries from the flash during |
||
215 | * vertical blanking period if possible, otherwise |
||
216 | * loads immediately. |
||
217 | * |
||
218 | * PreCondition: PaletteInit() must be called before. |
||
219 | * |
||
220 | * Input: pPalette - Pointer to the palette structure |
||
221 | * |
||
222 | * Output: none |
||
223 | * |
||
224 | * Side Effects: There may be a slight flicker when the Palette entries |
||
225 | * are getting loaded one by one. |
||
226 | * |
||
227 | ********************************************************************/ |
||
228 | #define RequestEntirePaletteChange(pPalette) RequestPaletteChange(pPalette, 0, 256) |
||
229 | |||
230 | /********************************************************************* |
||
231 | * Function: BYTE SetPalette(void *pPalette, WORD startEntry, WORD length) |
||
232 | * |
||
233 | * Overview: Loads the palettes from the flash immediately. |
||
234 | * |
||
235 | * PreCondition: PaletteInit() must be called before. |
||
236 | * |
||
237 | * Input: pPalette - Pointer to the palette structure |
||
238 | * startEntry - Start entry to load (inclusive) |
||
239 | * length - Number of entries |
||
240 | * |
||
241 | * Output: Status: Zero -> Success, Non-zero -> Error. |
||
242 | * |
||
243 | * Side Effects: There may be a slight flicker when the Palette entries |
||
244 | * are getting loaded one by one. |
||
245 | * |
||
246 | ********************************************************************/ |
||
247 | BYTE SetPalette(void *pPalette, WORD startEntry, WORD length); |
||
248 | |||
249 | /********************************************************************* |
||
250 | * Macro: SetEntirePalette(pPalette) |
||
251 | * |
||
252 | * Overview: Loads all the palette entries from the flash immediately. |
||
253 | * |
||
254 | * PreCondition: PaletteInit() must be called before. |
||
255 | * |
||
256 | * Input: pPalette - Pointer to the palette structure |
||
257 | * |
||
258 | * Output: Status: Zero -> Success, Non-zero -> Error. |
||
259 | * |
||
260 | * Side Effects: There may be a slight flicker when the Palette entries |
||
261 | * are getting loaded one by one. |
||
262 | * |
||
263 | ********************************************************************/ |
||
264 | #define SetEntirePalette(pPalette) SetPalette(pPalette, 0, 256) |
||
265 | |||
266 | /********************************************************************* |
||
267 | * Function: BYTE SetPaletteFlash(PALETTE_ENTRY *pPaletteEntry, WORD startEntry, WORD length) |
||
268 | * |
||
269 | * Overview: Loads the palettes from the flash immediately. |
||
270 | * |
||
271 | * PreCondition: PaletteInit() must be called before. |
||
272 | * |
||
273 | * Input: pPaletteEntry - Pointer to the palette table in ROM |
||
274 | * startEntry - Start entry to load (inclusive) |
||
275 | * length - Number of entries |
||
276 | * |
||
277 | * Output: Status: Zero -> Success, Non-zero -> Error. |
||
278 | * |
||
279 | * Side Effects: There may be a slight flicker when the Palette entries |
||
280 | * are getting loaded one by one. |
||
281 | * |
||
282 | ********************************************************************/ |
||
283 | BYTE SetPaletteFlash(PALETTE_ENTRY *pPaletteEntry, WORD startEntry, WORD length); |
||
284 | |||
285 | #endif //USE_PALETTE |
||
286 | #endif |
Powered by WebSVN v2.8.3