A library with drivers for different peripherals on the LPC4088 QuickStart Board or related add-on boards.
Dependents: LPC4088test LPC4088test_ledonly LPC4088test_deleteall LPC4088_RAMtest ... more
LcdController.h
00001 /* 00002 * Copyright 2013 Embedded Artists AB 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef LCDCONTROLLER_H 00018 #define LCDCONTROLLER_H 00019 00020 /** 00021 * A LCD controller interface 00022 * 00023 * @code 00024 * #include "mbed.h" 00025 * #include "LcdController.h" 00026 * 00027 * LcdController::Config innolux( 00028 * 45, 00029 * 17, 00030 * 2, 00031 * 800, 00032 * 22, 00033 * 22, 00034 * 2, 00035 * 480, 00036 * false, 00037 * false, 00038 * true, 00039 * true, 00040 * true, 00041 * LcdController::Bpp_16_565, 00042 * 36000000, 00043 * LcdController::Tft, 00044 * false); 00045 * 00046 * int main(void) { 00047 * LcdController lcd; 00048 * 00049 * lcd.open(&innolux); 00050 * lcd.setFrameBuffer(frameBuffer); 00051 * lcd.setPower(true); 00052 * 00053 * // draw on the frame buffer 00054 * ... 00055 * } 00056 * @endcode 00057 */ 00058 class LcdController { 00059 public: 00060 00061 enum LcdPanel { 00062 Tft = 0, // standard TFT 00063 AdTft, // advanced TFT 00064 HrTft, // highly reflective TFT 00065 Mono_4Bit, // 4-bit mono 00066 Mono_8Bit, // 8-bit mono 00067 ColorStn // Color STN 00068 }; 00069 00070 enum BitsPerPixel { 00071 Bpp_1 = 0, 00072 Bpp_2, 00073 Bpp_4, 00074 Bpp_8, 00075 Bpp_16, 00076 Bpp_24, 00077 Bpp_16_565, 00078 Bpp_12_444 00079 }; 00080 00081 /** 00082 * LCD configuration 00083 */ 00084 class Config { 00085 public: 00086 00087 /** Create an empty LCD configuration object 00088 * 00089 */ 00090 Config() { 00091 } 00092 00093 /** Create a LCD configuration object with specified values 00094 * 00095 * @param horizontalBackPorch Horizontal back porch in clocks 00096 * @param horizontalFrontPorch Horizontal front porch in clocks 00097 * @param hsync HSYNC pulse width in clocks 00098 * @param width width of display in pixels 00099 * @param verticalBackPorch vertical back porch in clocks 00100 * @param verticalFrontPorch vertical front porch in clocks 00101 * @param vsync VSYNC pulse width in clocks 00102 * @param height height of display in pixels 00103 * @param invertOutputEnable true to invert output enable 00104 * @param invertPanelClock true to invert panel clock 00105 * @param invertHsync true to invert HSYNC 00106 * @param invertVsync true to invert VSYNC 00107 * @param acBias AC bias frequency in clocks 00108 * @param bpp bits per pixel 00109 * @param optimalClock optimal clock rate (Hz) 00110 * @param panelType LCD panel type 00111 * @param dualPanel true if it is a dual panel display 00112 */ 00113 Config(int horizontalBackPorch, 00114 int horizontalFrontPorch, 00115 int hsync, 00116 int width, 00117 int verticalBackPorch, 00118 int verticalFrontPorch, 00119 int vsync, 00120 int height, 00121 bool invertOutputEnable, 00122 bool invertPanelClock, 00123 bool invertHsync, 00124 bool invertVsync, 00125 int acBias, 00126 BitsPerPixel bpp, 00127 int optimalClock, 00128 LcdPanel panelType, 00129 bool dualPanel) { 00130 00131 this->horizontalBackPorch = horizontalBackPorch; 00132 this->horizontalFrontPorch = horizontalFrontPorch; 00133 this->hsync = hsync; 00134 this->width = width; 00135 this->verticalBackPorch = verticalBackPorch; 00136 this->verticalFrontPorch = verticalFrontPorch; 00137 this->vsync = vsync; 00138 this->height = height; 00139 this->invertOutputEnable = invertOutputEnable; 00140 this->invertPanelClock = invertPanelClock; 00141 this->invertHsync = invertHsync; 00142 this->invertVsync = invertVsync; 00143 this->acBias = acBias; 00144 this->bpp = bpp; 00145 this->optimalClock = optimalClock; 00146 this->panelType = panelType; 00147 this->dualPanel = dualPanel; 00148 } 00149 00150 int horizontalBackPorch; 00151 int horizontalFrontPorch; 00152 int hsync; 00153 int width; 00154 int verticalBackPorch; 00155 int verticalFrontPorch; 00156 int vsync; 00157 int height; 00158 bool invertOutputEnable; 00159 bool invertPanelClock; 00160 bool invertHsync; 00161 bool invertVsync; 00162 int acBias; 00163 BitsPerPixel bpp; 00164 int optimalClock; 00165 LcdPanel panelType; 00166 bool dualPanel; 00167 }; 00168 00169 /** Create a LCD controller interface 00170 * 00171 */ 00172 LcdController(); 00173 00174 /** Open and initialize the LCD controller with the given LCD configuration 00175 * 00176 * @param cfg LCD configuration 00177 * 00178 * @returns 00179 * 0 on success 00180 * 1 on failure 00181 */ 00182 int open(LcdController::Config* cfg); 00183 00184 /** Close the LCD controller 00185 * 00186 * @returns 00187 * 0 on success 00188 * 1 on failure 00189 */ 00190 int close(); 00191 00192 /** Set and activate the address of the frame buffer to use. 00193 * 00194 * It is the content of the frame buffer that is shown on the 00195 * display. All the drawing on the frame buffer can be done 00196 * 'offline' and whenever it should be shown this function 00197 * can be called with the address of the offline frame buffer. 00198 * 00199 * @param address Memory address of the frame buffer 00200 * 00201 * @returns 00202 * 0 on success 00203 * 1 on failure 00204 */ 00205 int setFrameBuffer(uint32_t address); 00206 00207 /** Turn on/off the power to the display. 00208 * 00209 * @param on true to turn on, false to turn off 00210 * 00211 * @returns 00212 * 0 on success 00213 * 1 on failure 00214 */ 00215 int setPower(bool on); 00216 00217 00218 private: 00219 00220 bool _opened; 00221 static bool _lcdControllerUsed; 00222 00223 void init(LcdController::Config* cfg); 00224 void pinConfig(); 00225 uint32_t getClockDivisor(int clock); 00226 }; 00227 00228 #endif 00229 00230
Generated on Fri Jul 15 2022 02:16:08 by 1.7.2