Subdirectory provided by Embedded Artists
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src
Dependents: lpc4088_displaymodule_hello_world_Sept_2018
Fork of DMSupport by
BiosDisplay.cpp
00001 /* 00002 * Copyright 2014 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 #include "mbed.h" 00018 #include "BiosDisplay.h" 00019 #include "BiosLoader.h" 00020 #include "DMBoard.h" 00021 #include "bios.h" 00022 00023 00024 /****************************************************************************** 00025 * Defines and typedefs 00026 *****************************************************************************/ 00027 00028 00029 /****************************************************************************** 00030 * Local variables 00031 *****************************************************************************/ 00032 00033 00034 /****************************************************************************** 00035 * Private Functions 00036 *****************************************************************************/ 00037 00038 BiosDisplay::BiosDisplay() : 00039 _initialized(false), 00040 _poweredOn(false), 00041 _bios(NULL), 00042 _biosData(NULL), 00043 _width(0), 00044 _height(0), 00045 _bpp(0), 00046 _supportedRes(0), 00047 _activeRes(Res_16bit_rgb565), 00048 _landscape(false) 00049 { 00050 } 00051 00052 BiosDisplay::~BiosDisplay() 00053 { 00054 // _bios and _biosData are deallocated by BiosLoader 00055 } 00056 00057 00058 /****************************************************************************** 00059 * Public Functions 00060 *****************************************************************************/ 00061 00062 BiosDisplay::DisplayError BiosDisplay::init() 00063 { 00064 DisplayError err = DisplayError_Ok; 00065 if (!_initialized) { 00066 do { 00067 if (BiosLoader::instance().params(&_bios, &_biosData) != DMBoard::Ok) { 00068 err = DisplayError_ConfigError; 00069 break; 00070 } 00071 00072 err = (DisplayError)_bios->displayInit(_biosData); 00073 if (err != DisplayError_Ok) { 00074 break; 00075 } 00076 00077 err = (DisplayError)_bios->displayInformation(_biosData, &_width, &_height, &_bpp, &_landscape, &_supportedRes, &_activeRes); 00078 if (err != DisplayError_Ok) { 00079 break; 00080 } 00081 00082 _initialized = true; 00083 } while(0); 00084 } 00085 return err; 00086 } 00087 00088 BiosDisplay::DisplayError BiosDisplay::powerUp(void* framebuffer, Display::Resolution res, FrameRate_t rate) 00089 { 00090 DisplayError err = DisplayError_Ok; 00091 if (!_poweredOn) { 00092 err = init(); 00093 if (err == DisplayError_Ok) { 00094 do { 00095 err = (DisplayError)_bios->displayPowerUp(_biosData, framebuffer, (Resolution_t)res, rate); 00096 00097 if (err != DisplayError_Ok) { 00098 break; 00099 } 00100 00101 err = (DisplayError)_bios->displayInformation(_biosData, &_width, &_height, &_bpp, &_landscape, &_supportedRes, &_activeRes); 00102 if (err != DisplayError_Ok) { 00103 break; 00104 } 00105 00106 _poweredOn = true; 00107 } while(0); 00108 } 00109 } 00110 return err; 00111 } 00112 00113 BiosDisplay::DisplayError BiosDisplay::powerDown() 00114 { 00115 DisplayError err = DisplayError_Ok; 00116 if (_poweredOn) { 00117 err = (DisplayError)_bios->displayPowerDown(_biosData); 00118 _poweredOn = false; 00119 } 00120 return err; 00121 } 00122 00123 BiosDisplay::DisplayError BiosDisplay::backlight(int percent) 00124 { 00125 DisplayError err = DisplayError_Ok; 00126 if (!_initialized) { 00127 err = DisplayError_NoInit; 00128 } else { 00129 err = (DisplayError)_bios->displayBacklight(_biosData, percent); 00130 } 00131 return err; 00132 } 00133 00134 uint16_t BiosDisplay::width() 00135 { 00136 return _width; 00137 } 00138 00139 uint16_t BiosDisplay::height() 00140 { 00141 return _height; 00142 } 00143 00144 uint16_t BiosDisplay::bytesPerPixel() 00145 { 00146 return _bpp; 00147 } 00148 00149 uint32_t BiosDisplay::fbSize() 00150 { 00151 return _width * _height * _bpp; 00152 } 00153 00154 bool BiosDisplay::landscape() 00155 { 00156 return _landscape; 00157 } 00158 00159 void* BiosDisplay::allocateFramebuffer(Display::Resolution res) 00160 { 00161 if (_initialized) { 00162 return malloc(_width*_height*bpp(res)); 00163 } 00164 return NULL; 00165 } 00166 00167 void* BiosDisplay::allocateFramebuffers(uint32_t num, Display::Resolution res) 00168 { 00169 if (_initialized && num>0) { 00170 return malloc(_width*_height*bpp(res)*num); 00171 } 00172 return NULL; 00173 } 00174 00175 void BiosDisplay::setFramebuffer(void* buff) 00176 { 00177 LPC_LCD->UPBASE = (uint32_t)buff; 00178 } 00179 00180 void* BiosDisplay::swapFramebuffer(void* buff) 00181 { 00182 uint32_t old = LPC_LCD->UPBASE; 00183 LPC_LCD->UPBASE = (uint32_t)buff; 00184 return (void*)old; 00185 } 00186 00187 bool BiosDisplay::isSupported(Display::Resolution res) 00188 { 00189 return (_supportedRes & res); 00190 } 00191 00192 BiosDisplay::Resolution BiosDisplay::currentResolution() 00193 { 00194 return (Resolution)_activeRes; 00195 }
Generated on Wed Jul 13 2022 02:57:23 by
![doxygen](doxygen.png)