A basic graphics package for the LPC4088 Display Module.
Dependents: lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more
Fork of DMBasicGUI by
lpc_swim/lpc_colors.c@22:f0d00f29bfeb, 2019-11-04 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Nov 04 14:31:50 2019 +0000
- Revision:
- 22:f0d00f29bfeb
- Parent:
- 0:4977187e90c7
More updates related to mbed OS 5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:4977187e90c7 | 1 | /* |
embeddedartists | 0:4977187e90c7 | 2 | * @brief SWIM color definitions and palette table setup |
embeddedartists | 0:4977187e90c7 | 3 | * |
embeddedartists | 0:4977187e90c7 | 4 | * @note |
embeddedartists | 0:4977187e90c7 | 5 | * Copyright(C) NXP Semiconductors, 2012 |
embeddedartists | 0:4977187e90c7 | 6 | * All rights reserved. |
embeddedartists | 0:4977187e90c7 | 7 | * |
embeddedartists | 0:4977187e90c7 | 8 | * @par |
embeddedartists | 0:4977187e90c7 | 9 | * Software that is described herein is for illustrative purposes only |
embeddedartists | 0:4977187e90c7 | 10 | * which provides customers with programming information regarding the |
embeddedartists | 0:4977187e90c7 | 11 | * LPC products. This software is supplied "AS IS" without any warranties of |
embeddedartists | 0:4977187e90c7 | 12 | * any kind, and NXP Semiconductors and its licensor disclaim any and |
embeddedartists | 0:4977187e90c7 | 13 | * all warranties, express or implied, including all implied warranties of |
embeddedartists | 0:4977187e90c7 | 14 | * merchantability, fitness for a particular purpose and non-infringement of |
embeddedartists | 0:4977187e90c7 | 15 | * intellectual property rights. NXP Semiconductors assumes no responsibility |
embeddedartists | 0:4977187e90c7 | 16 | * or liability for the use of the software, conveys no license or rights under any |
embeddedartists | 0:4977187e90c7 | 17 | * patent, copyright, mask work right, or any other intellectual property rights in |
embeddedartists | 0:4977187e90c7 | 18 | * or to any products. NXP Semiconductors reserves the right to make changes |
embeddedartists | 0:4977187e90c7 | 19 | * in the software without notification. NXP Semiconductors also makes no |
embeddedartists | 0:4977187e90c7 | 20 | * representation or warranty that such application will be suitable for the |
embeddedartists | 0:4977187e90c7 | 21 | * specified use without further testing or modification. |
embeddedartists | 0:4977187e90c7 | 22 | * |
embeddedartists | 0:4977187e90c7 | 23 | * @par |
embeddedartists | 0:4977187e90c7 | 24 | * Permission to use, copy, modify, and distribute this software and its |
embeddedartists | 0:4977187e90c7 | 25 | * documentation is hereby granted, under NXP Semiconductors' and its |
embeddedartists | 0:4977187e90c7 | 26 | * licensor's relevant copyrights in the software, without fee, provided that it |
embeddedartists | 0:4977187e90c7 | 27 | * is used in conjunction with NXP Semiconductors microcontrollers. This |
embeddedartists | 0:4977187e90c7 | 28 | * copyright, permission, and disclaimer notice must appear in all copies of |
embeddedartists | 0:4977187e90c7 | 29 | * this code. |
embeddedartists | 0:4977187e90c7 | 30 | */ |
embeddedartists | 0:4977187e90c7 | 31 | |
embeddedartists | 0:4977187e90c7 | 32 | #include "lpc_colors.h" |
embeddedartists | 0:4977187e90c7 | 33 | |
embeddedartists | 0:4977187e90c7 | 34 | /***************************************************************************** |
embeddedartists | 0:4977187e90c7 | 35 | * Private types/enumerations/variables |
embeddedartists | 0:4977187e90c7 | 36 | ****************************************************************************/ |
embeddedartists | 0:4977187e90c7 | 37 | |
embeddedartists | 0:4977187e90c7 | 38 | /***************************************************************************** |
embeddedartists | 0:4977187e90c7 | 39 | * Public types/enumerations/variables |
embeddedartists | 0:4977187e90c7 | 40 | ****************************************************************************/ |
embeddedartists | 0:4977187e90c7 | 41 | |
embeddedartists | 0:4977187e90c7 | 42 | /***************************************************************************** |
embeddedartists | 0:4977187e90c7 | 43 | * Private functions |
embeddedartists | 0:4977187e90c7 | 44 | ****************************************************************************/ |
embeddedartists | 0:4977187e90c7 | 45 | |
embeddedartists | 0:4977187e90c7 | 46 | /***************************************************************************** |
embeddedartists | 0:4977187e90c7 | 47 | * Public functions |
embeddedartists | 0:4977187e90c7 | 48 | ****************************************************************************/ |
embeddedartists | 0:4977187e90c7 | 49 | |
embeddedartists | 0:4977187e90c7 | 50 | /* Generate a palette table (only in 8-bit mode) */ |
embeddedartists | 0:4977187e90c7 | 51 | void lpc_colors_set_palette(uint16_t *palette_table) |
embeddedartists | 0:4977187e90c7 | 52 | { |
embeddedartists | 0:4977187e90c7 | 53 | #if COLORS_DEF == 8 |
embeddedartists | 0:4977187e90c7 | 54 | int32_t idx; |
embeddedartists | 0:4977187e90c7 | 55 | uint16_t entry, r, g, b; |
embeddedartists | 0:4977187e90c7 | 56 | |
embeddedartists | 0:4977187e90c7 | 57 | /* 256 entries */ |
embeddedartists | 0:4977187e90c7 | 58 | for (idx = 0; idx < NUM_COLORS; idx++) { |
embeddedartists | 0:4977187e90c7 | 59 | r = ((uint16_t) idx & REDMASK) >> REDSHIFT; |
embeddedartists | 0:4977187e90c7 | 60 | g = ((uint16_t) idx & GREENMASK) >> GREENSHIFT; |
embeddedartists | 0:4977187e90c7 | 61 | b = ((uint16_t) idx & BLUEMASK) >> BLUESHIFT; |
embeddedartists | 0:4977187e90c7 | 62 | |
embeddedartists | 0:4977187e90c7 | 63 | #ifdef COLORS_8_565_MODE |
embeddedartists | 0:4977187e90c7 | 64 | /* Strip out and scale colors */ |
embeddedartists | 0:4977187e90c7 | 65 | r = r * 0x1F / ((REDMASK >> REDSHIFT) + 1); |
embeddedartists | 0:4977187e90c7 | 66 | g = g * 0x3F / ((GREENMASK >> GREENSHIFT) + 1); |
embeddedartists | 0:4977187e90c7 | 67 | b = b * 0x1F / ((BLUEMASK >> BLUESHIFT) + 1); |
embeddedartists | 0:4977187e90c7 | 68 | entry = b + (g << 5) + (r << 11); |
embeddedartists | 0:4977187e90c7 | 69 | |
embeddedartists | 0:4977187e90c7 | 70 | #else |
embeddedartists | 0:4977187e90c7 | 71 | /* Strip out and scale colors */ |
embeddedartists | 0:4977187e90c7 | 72 | r = r * 0x1F / ((REDMASK >> REDSHIFT) + 1); |
embeddedartists | 0:4977187e90c7 | 73 | g = g * 0x1F / ((GREENMASK >> GREENSHIFT) + 1); |
embeddedartists | 0:4977187e90c7 | 74 | b = b * 0x1F / ((BLUEMASK >> BLUESHIFT) + 1); |
embeddedartists | 0:4977187e90c7 | 75 | entry = b + (g << 5) + (r << 10); |
embeddedartists | 0:4977187e90c7 | 76 | #endif |
embeddedartists | 0:4977187e90c7 | 77 | |
embeddedartists | 0:4977187e90c7 | 78 | /* Save palette entry */ |
embeddedartists | 0:4977187e90c7 | 79 | palette_table[idx] = entry; |
embeddedartists | 0:4977187e90c7 | 80 | } |
embeddedartists | 0:4977187e90c7 | 81 | #endif /* COLORS_DEF == 8 */ |
embeddedartists | 0:4977187e90c7 | 82 | } |
embeddedartists | 0:4977187e90c7 | 83 |