Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LCDConf_CustomPaletteMode.c Source File

LCDConf_CustomPaletteMode.c

00001 /*********************************************************************
00002 *                SEGGER Microcontroller GmbH                         *
00003 *        Solutions for real time microcontroller applications        *
00004 **********************************************************************
00005 *                                                                    *
00006 *        (c) 1996 - 2018  SEGGER Microcontroller GmbH                *
00007 *                                                                    *
00008 *        Internet: www.segger.com    Support:  support@segger.com    *
00009 *                                                                    *
00010 **********************************************************************
00011 
00012 ** emWin V5.48 - Graphical user interface for embedded applications **
00013 All  Intellectual Property rights  in the Software belongs to  SEGGER.
00014 emWin is protected by  international copyright laws.  Knowledge of the
00015 source code may not be used to write a similar product.  This file may
00016 only be used in accordance with the following terms:
00017 
00018 The software  has been licensed to  Cypress Semiconductor Corporation,
00019 whose registered  office is situated  at 198 Champion Ct. San Jose, CA 
00020 95134 USA  solely for the  purposes of creating  libraries for Cypress
00021 PSoC3 and  PSoC5 processor-based devices,  sublicensed and distributed
00022 under  the  terms  and  conditions  of  the  Cypress  End User License
00023 Agreement.
00024 Full source code is available at: www.segger.com
00025 
00026 We appreciate your understanding and fairness.
00027 ----------------------------------------------------------------------
00028 Licensing information
00029 Licensor:                 SEGGER Microcontroller Systems LLC
00030 Licensed to:              Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA
00031 Licensed SEGGER software: emWin
00032 License number:           GUI-00319
00033 License model:            Services and License Agreement, signed June 10th, 2009
00034 Licensed platform:        Any Cypress platform (Initial targets are: PSoC3, PSoC5)
00035 ----------------------------------------------------------------------
00036 Support and Update Agreement (SUA)
00037 SUA period:               2009-06-12 - 2022-07-27
00038 Contact to extend SUA:    sales@segger.com
00039 ----------------------------------------------------------------------
00040 File        : LCDConf.c
00041 Purpose     : Sample file for custom palette mode
00042 ---------------------------END-OF-HEADER------------------------------
00043 */
00044 
00045 #include "GUI.h"
00046 
00047 #include "GUIDRV_Lin.h"
00048 
00049 /*********************************************************************
00050 *
00051 *       Layer configuration (to be modified)
00052 *
00053 **********************************************************************
00054 */
00055 //
00056 // Physical display size
00057 //
00058 #define XSIZE_PHYS 320
00059 #define YSIZE_PHYS 240
00060 
00061 //
00062 // Color conversion
00063 //
00064 #define COLOR_CONVERSION GUICC_0
00065 
00066 //
00067 // Display driver
00068 //
00069 #define DISPLAY_DRIVER GUIDRV_LIN_8
00070 
00071 /*********************************************************************
00072 *
00073 *       Configuration checking
00074 *
00075 **********************************************************************
00076 */
00077 #ifndef   VRAM_ADDR
00078   #define VRAM_ADDR 0
00079 #endif
00080 #ifndef   XSIZE_PHYS
00081   #error Physical X size of display is not defined!
00082 #endif
00083 #ifndef   YSIZE_PHYS
00084   #error Physical Y size of display is not defined!
00085 #endif
00086 #ifndef   COLOR_CONVERSION
00087   #error Color conversion not defined!
00088 #endif
00089 #ifndef   DISPLAY_DRIVER
00090   #error No display driver defined!
00091 #endif
00092 
00093 /*********************************************************************
00094 *
00095 *       Static data
00096 *
00097 **********************************************************************
00098 */
00099 static const LCD_COLOR _aColors_256[] = {
00100   0x000000, 0x240000, 0x480000, 0x6D0000, 0x910000, 0xB60000, 0xDA0000, 0xFF0000, 
00101   0x005500, 0x245500, 0x485500, 0x6D5500, 0x915500, 0xB65500, 0xDA5500, 0xFF5500, 
00102   0x00AA00, 0x24AA00, 0x48AA00, 0x6DAA00, 0x91AA00, 0xB6AA00, 0xDAAA00, 0xFFAA00, 
00103   0x00FF00, 0x24FF00, 0x48FF00, 0x6DFF00, 0x91FF00, 0xB6FF00, 0xDAFF00, 0xFFFF00, 
00104   0x000024, 0x240024, 0x480024, 0x6D0024, 0x910024, 0xB60024, 0xDA0024, 0xFF0024, 
00105   0x005524, 0x245524, 0x485524, 0x6D5524, 0x915524, 0xB65524, 0xDA5524, 0xFF5524, 
00106   0x00AA24, 0x24AA24, 0x48AA24, 0x6DAA24, 0x91AA24, 0xB6AA24, 0xDAAA24, 0xFFAA24, 
00107   0x00FF24, 0x24FF24, 0x48FF24, 0x6DFF24, 0x91FF24, 0xB6FF24, 0xDAFF24, 0xFFFF24, 
00108   0x000048, 0x240048, 0x480048, 0x6D0048, 0x910048, 0xB60048, 0xDA0048, 0xFF0048, 
00109   0x005548, 0x245548, 0x485548, 0x6D5548, 0x915548, 0xB65548, 0xDA5548, 0xFF5548, 
00110   0x00AA48, 0x24AA48, 0x48AA48, 0x6DAA48, 0x91AA48, 0xB6AA48, 0xDAAA48, 0xFFAA48, 
00111   0x00FF48, 0x24FF48, 0x48FF48, 0x6DFF48, 0x91FF48, 0xB6FF48, 0xDAFF48, 0xFFFF48, 
00112   0x00006D, 0x24006D, 0x48006D, 0x6D006D, 0x91006D, 0xB6006D, 0xDA006D, 0xFF006D, 
00113   0x00556D, 0x24556D, 0x48556D, 0x6D556D, 0x91556D, 0xB6556D, 0xDA556D, 0xFF556D, 
00114   0x00AA6D, 0x24AA6D, 0x48AA6D, 0x6DAA6D, 0x91AA6D, 0xB6AA6D, 0xDAAA6D, 0xFFAA6D, 
00115   0x00FF6D, 0x24FF6D, 0x48FF6D, 0x6DFF6D, 0x91FF6D, 0xB6FF6D, 0xDAFF6D, 0xFFFF6D, 
00116   0x000091, 0x240091, 0x480091, 0x6D0091, 0x910091, 0xB60091, 0xDA0091, 0xFF0091, 
00117   0x005591, 0x245591, 0x485591, 0x6D5591, 0x915591, 0xB65591, 0xDA5591, 0xFF5591, 
00118   0x00AA91, 0x24AA91, 0x48AA91, 0x6DAA91, 0x91AA91, 0xB6AA91, 0xDAAA91, 0xFFAA91, 
00119   0x00FF91, 0x24FF91, 0x48FF91, 0x6DFF91, 0x91FF91, 0xB6FF91, 0xDAFF91, 0xFFFF91, 
00120   0x0000B6, 0x2400B6, 0x4800B6, 0x6D00B6, 0x9100B6, 0xB600B6, 0xDA00B6, 0xFF00B6, 
00121   0x0055B6, 0x2455B6, 0x4855B6, 0x6D55B6, 0x9155B6, 0xB655B6, 0xDA55B6, 0xFF55B6, 
00122   0x00AAB6, 0x24AAB6, 0x48AAB6, 0x6DAAB6, 0x91AAB6, 0xB6AAB6, 0xDAAAB6, 0xFFAAB6, 
00123   0x00FFB6, 0x24FFB6, 0x48FFB6, 0x6DFFB6, 0x91FFB6, 0xB6FFB6, 0xDAFFB6, 0xFFFFB6, 
00124   0x0000DA, 0x2400DA, 0x4800DA, 0x6D00DA, 0x9100DA, 0xB600DA, 0xDA00DA, 0xFF00DA, 
00125   0x0055DA, 0x2455DA, 0x4855DA, 0x6D55DA, 0x9155DA, 0xB655DA, 0xDA55DA, 0xFF55DA, 
00126   0x00AADA, 0x24AADA, 0x48AADA, 0x6DAADA, 0x91AADA, 0xB6AADA, 0xDAAADA, 0xFFAADA, 
00127   0x00FFDA, 0x24FFDA, 0x48FFDA, 0x6DFFDA, 0x91FFDA, 0xB6FFDA, 0xDAFFDA, 0xFFFFDA, 
00128   0x0000FF, 0x2400FF, 0x4800FF, 0x6D00FF, 0x9100FF, 0xB600FF, 0xDA00FF, 0xFF00FF, 
00129   0x0055FF, 0x2455FF, 0x4855FF, 0x6D55FF, 0x9155FF, 0xB655FF, 0xDA55FF, 0xFF55FF, 
00130   0x00AAFF, 0x24AAFF, 0x48AAFF, 0x6DAAFF, 0x91AAFF, 0xB6AAFF, 0xDAAAFF, 0xFFAAFF, 
00131   0x00FFFF, 0x24FFFF, 0x48FFFF, 0x6DFFFF, 0x91FFFF, 0xB6FFFF, 0xDAFFFF, 0xFFFFFF,
00132 };
00133 
00134 static const LCD_PHYSPALETTE _aPalette_256 = {
00135   GUI_COUNTOF(_aColors_256), _aColors_256
00136 };
00137 
00138 /*********************************************************************
00139 *
00140 *       Static code
00141 *
00142 **********************************************************************
00143 */
00144 /*********************************************************************
00145 *
00146 *       _InitController
00147 *
00148 * Purpose:
00149 *   Should initialize the display controller
00150 */
00151 static void _InitController(void) {
00152   /* TBD by customer */
00153 }
00154 
00155 /*********************************************************************
00156 *
00157 *       _SetLUTEntry
00158 *
00159 * Purpose:
00160 *   Should set the desired LUT entry
00161 */
00162 static void _SetLUTEntry(LCD_COLOR Color, U8 Pos) {
00163   /* TBD by customer */
00164 }
00165 
00166 /*********************************************************************
00167 *
00168 *       Public code
00169 *
00170 **********************************************************************
00171 */
00172 /*********************************************************************
00173 *
00174 *       LCD_X_Config
00175 *
00176 * Purpose:
00177 *   Called during the initialization process in order to set up the
00178 *   display driver configuration.
00179 *   
00180 */
00181 void LCD_X_Config(void) {
00182   //
00183   // Set display driver and color conversion for 1st layer
00184   //
00185   GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);
00186   //
00187   // Display driver configuration
00188   //
00189   if (LCD_GetSwapXY()) {
00190     LCD_SetSizeEx (0, YSIZE_PHYS, XSIZE_PHYS);
00191     LCD_SetVSizeEx(0, YSIZE_PHYS, XSIZE_PHYS);
00192   } else {
00193     LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
00194     LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS);
00195   }
00196   LCD_SetVRAMAddrEx(0, (void *)VRAM_ADDR);
00197   //
00198   // Set user palette data (only required if no fixed palette is used)
00199   //
00200   LCD_SetLUTEx(0, &_aPalette_256);
00201 }
00202 
00203 /*********************************************************************
00204 *
00205 *       LCD_X_DisplayDriver
00206 *
00207 * Purpose:
00208 *   This function is called by the display driver for several purposes.
00209 *   To support the according task the routine needs to be adapted to
00210 *   the display controller. Please note that the commands marked with
00211 *   'optional' are not cogently required and should only be adapted if 
00212 *   the display controller supports these features.
00213 *
00214 * Parameter:
00215 *   LayerIndex - Index of layer to be configured
00216 *   Cmd        - Please refer to the details in the switch statement below
00217 *   pData      - Pointer to a LCD_X_DATA structure
00218 *
00219 * Return Value:
00220 *   < -1 - Error
00221 *     -1 - Command not handled
00222 *      0 - Ok
00223 */
00224 int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
00225   int r;
00226 
00227   switch (Cmd) {
00228   case LCD_X_INITCONTROLLER: {
00229     _InitController();
00230     return 0;
00231   }
00232   case LCD_X_SETLUTENTRY: {
00233     LCD_X_SETLUTENTRY_INFO * p;
00234     p = (LCD_X_SETLUTENTRY_INFO *)pData;
00235     _SetLUTEntry(p->Color, p->Pos);
00236     return 0;
00237   }
00238   default:
00239     r = -1;
00240   }
00241   return r;
00242 }
00243 
00244 /*************************** End of file ****************************/