mbed support for LPC4088 Display Module
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src
Fork of DMSupport by
Display/Display.h@31:d47cffcb0a3e, 2015-02-17 (annotated)
- Committer:
- embeddedartists
- Date:
- Tue Feb 17 10:41:48 2015 +0100
- Revision:
- 31:d47cffcb0a3e
- Parent:
- 22:1a58a518435c
- Child:
- 39:e1cb4dd9bfeb
- Added function get current BIOS version
- Added function to allocate consequtive frame buffers
- Removed printouts that slowed down the touch controller
- Replaced wait_ms with Thread::wait in MCIFileSystem
- Changed CardDetect pin for MCIFileSystem
- Added (but disabled) extra pins for measurements
- Updated the DM_USBHost library (see version history there for changes)
- Updated EthernetInterface library to get TARGET_LPC4088_DM support
- Updated to latest versions of mbed, mbed-rpc, mbed-rtos and USBDevice libs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:6b68dac0d986 | 1 | /* |
embeddedartists | 0:6b68dac0d986 | 2 | * Copyright 2014 Embedded Artists AB |
embeddedartists | 0:6b68dac0d986 | 3 | * |
embeddedartists | 0:6b68dac0d986 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 0:6b68dac0d986 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 0:6b68dac0d986 | 6 | * You may obtain a copy of the License at |
embeddedartists | 0:6b68dac0d986 | 7 | * |
embeddedartists | 0:6b68dac0d986 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 0:6b68dac0d986 | 9 | * |
embeddedartists | 0:6b68dac0d986 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 0:6b68dac0d986 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 0:6b68dac0d986 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 0:6b68dac0d986 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 0:6b68dac0d986 | 14 | * limitations under the License. |
embeddedartists | 0:6b68dac0d986 | 15 | */ |
embeddedartists | 0:6b68dac0d986 | 16 | |
embeddedartists | 0:6b68dac0d986 | 17 | #ifndef DISPLAY_H |
embeddedartists | 0:6b68dac0d986 | 18 | #define DISPLAY_H |
embeddedartists | 0:6b68dac0d986 | 19 | |
embeddedartists | 0:6b68dac0d986 | 20 | #include "mbed.h" |
embeddedartists | 10:1ac4b213f0f7 | 21 | #include "bios.h" |
embeddedartists | 0:6b68dac0d986 | 22 | |
embeddedartists | 9:a33326afd686 | 23 | /** |
embeddedartists | 9:a33326afd686 | 24 | * Display example |
embeddedartists | 9:a33326afd686 | 25 | * |
embeddedartists | 9:a33326afd686 | 26 | * @code |
embeddedartists | 9:a33326afd686 | 27 | * #include "mbed.h" |
embeddedartists | 9:a33326afd686 | 28 | * #include "DMBoard.h" |
embeddedartists | 9:a33326afd686 | 29 | * |
embeddedartists | 9:a33326afd686 | 30 | * int main(void) { |
embeddedartists | 9:a33326afd686 | 31 | * // initialize the display |
embeddedartists | 9:a33326afd686 | 32 | * DMBoard::instance().init(); |
embeddedartists | 9:a33326afd686 | 33 | * |
embeddedartists | 9:a33326afd686 | 34 | * // allocate one framebuffer |
embeddedartists | 9:a33326afd686 | 35 | * Display* disp = DMBoard::instance().display(); |
embeddedartists | 9:a33326afd686 | 36 | * uint16_t* fb = (uint16_t*)disp->allocateFramebuffer(); |
embeddedartists | 9:a33326afd686 | 37 | * if (fb == NULL) { |
embeddedartists | 9:a33326afd686 | 38 | * DMBoard::instance().logger()->printf("Failed to allocate memory for framebuffer\r\n"); |
embeddedartists | 9:a33326afd686 | 39 | * mbed_die(); |
embeddedartists | 9:a33326afd686 | 40 | * } |
embeddedartists | 9:a33326afd686 | 41 | * |
embeddedartists | 9:a33326afd686 | 42 | * // draw something on the framebuffer |
embeddedartists | 9:a33326afd686 | 43 | * ... |
embeddedartists | 9:a33326afd686 | 44 | * |
embeddedartists | 9:a33326afd686 | 45 | * // turn on the display |
embeddedartists | 9:a33326afd686 | 46 | * disperr = disp->powerUp(fb); |
embeddedartists | 9:a33326afd686 | 47 | * if (disperr != Display::Ok) { |
embeddedartists | 9:a33326afd686 | 48 | * DMBoard::instance().logger()->printf("Failed to initialize the display, got error %d\r\n", disperr); |
embeddedartists | 9:a33326afd686 | 49 | * mbed_die(); |
embeddedartists | 9:a33326afd686 | 50 | * } |
embeddedartists | 9:a33326afd686 | 51 | * |
embeddedartists | 9:a33326afd686 | 52 | * ... |
embeddedartists | 9:a33326afd686 | 53 | * } |
embeddedartists | 9:a33326afd686 | 54 | * @endcode |
embeddedartists | 9:a33326afd686 | 55 | */ |
embeddedartists | 0:6b68dac0d986 | 56 | class Display { |
embeddedartists | 0:6b68dac0d986 | 57 | public: |
embeddedartists | 0:6b68dac0d986 | 58 | enum DisplayError { |
embeddedartists | 10:1ac4b213f0f7 | 59 | DisplayError_Ok = BiosError_Ok, |
embeddedartists | 10:1ac4b213f0f7 | 60 | DisplayError_ConfigError = BiosError_ConfigError, |
embeddedartists | 10:1ac4b213f0f7 | 61 | DisplayError_WrongBPP = BiosError_WrongBPP, |
embeddedartists | 10:1ac4b213f0f7 | 62 | DisplayError_InvalidParam = BiosError_InvalidParam, |
embeddedartists | 10:1ac4b213f0f7 | 63 | DisplayError_NoInit = BiosError_NoInit, |
embeddedartists | 10:1ac4b213f0f7 | 64 | DisplayError_CalibrationError = BiosError_Calibration, |
embeddedartists | 22:1a58a518435c | 65 | DisplayError_Timeout = BiosError_Timeout, |
embeddedartists | 22:1a58a518435c | 66 | DisplayError_TouchNotSupported = BiosError_NotSupported, |
embeddedartists | 10:1ac4b213f0f7 | 67 | DisplayError_MemoryError, |
embeddedartists | 0:6b68dac0d986 | 68 | }; |
embeddedartists | 0:6b68dac0d986 | 69 | |
embeddedartists | 0:6b68dac0d986 | 70 | enum Resolution { |
embeddedartists | 10:1ac4b213f0f7 | 71 | Resolution_16bit_rgb565 = Res_16bit_rgb565, |
embeddedartists | 10:1ac4b213f0f7 | 72 | Resolution_18bit_rgb666 = Res_18bit_rgb666, |
embeddedartists | 10:1ac4b213f0f7 | 73 | Resolution_24bit_rgb888 = Res_24bit_rgb888, |
embeddedartists | 0:6b68dac0d986 | 74 | }; |
embeddedartists | 0:6b68dac0d986 | 75 | |
embeddedartists | 9:a33326afd686 | 76 | /** Turns the display on with the specified framebuffer showing |
embeddedartists | 0:6b68dac0d986 | 77 | * |
embeddedartists | 0:6b68dac0d986 | 78 | * @returns |
embeddedartists | 0:6b68dac0d986 | 79 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 80 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 81 | */ |
embeddedartists | 10:1ac4b213f0f7 | 82 | virtual DisplayError powerUp(void* framebuffer, Resolution wanted = Resolution_16bit_rgb565) = 0; |
embeddedartists | 0:6b68dac0d986 | 83 | |
embeddedartists | 9:a33326afd686 | 84 | /** Turns the display off |
embeddedartists | 0:6b68dac0d986 | 85 | * |
embeddedartists | 0:6b68dac0d986 | 86 | * @returns |
embeddedartists | 0:6b68dac0d986 | 87 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 88 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 89 | */ |
embeddedartists | 10:1ac4b213f0f7 | 90 | virtual DisplayError powerDown() = 0; |
embeddedartists | 0:6b68dac0d986 | 91 | |
embeddedartists | 0:6b68dac0d986 | 92 | /** Sets the backlight level. 0% is off and 100% is fully on |
embeddedartists | 0:6b68dac0d986 | 93 | * |
embeddedartists | 0:6b68dac0d986 | 94 | * @returns |
embeddedartists | 0:6b68dac0d986 | 95 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 96 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 97 | */ |
embeddedartists | 10:1ac4b213f0f7 | 98 | virtual DisplayError backlight(int percent) = 0; |
embeddedartists | 0:6b68dac0d986 | 99 | |
embeddedartists | 10:1ac4b213f0f7 | 100 | virtual uint16_t width() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 101 | virtual uint16_t height() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 102 | virtual uint16_t bytesPerPixel() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 103 | virtual uint32_t fbSize() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 104 | virtual bool landscape() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 105 | virtual bool isSupported(Resolution res) = 0; |
embeddedartists | 10:1ac4b213f0f7 | 106 | virtual Resolution currentResolution() = 0; |
embeddedartists | 9:a33326afd686 | 107 | |
embeddedartists | 9:a33326afd686 | 108 | /** Replaces the current framebuffer. |
embeddedartists | 9:a33326afd686 | 109 | * |
embeddedartists | 9:a33326afd686 | 110 | * Note that this requires the caller or someone else to have a |
embeddedartists | 9:a33326afd686 | 111 | * reference to the existing framebuffer, otherwise that memory |
embeddedartists | 9:a33326afd686 | 112 | * is lost. |
embeddedartists | 9:a33326afd686 | 113 | * |
embeddedartists | 9:a33326afd686 | 114 | * @param buff the new framebuffer |
embeddedartists | 9:a33326afd686 | 115 | */ |
embeddedartists | 10:1ac4b213f0f7 | 116 | virtual void setFramebuffer(void* buff) = 0; |
embeddedartists | 9:a33326afd686 | 117 | |
embeddedartists | 9:a33326afd686 | 118 | /** Replaces the current framebuffer with the specified one. |
embeddedartists | 9:a33326afd686 | 119 | * |
embeddedartists | 9:a33326afd686 | 120 | * This function as opposed to the setFramebuffer() one does return |
embeddedartists | 9:a33326afd686 | 121 | * the old framebuffer. This way the caller can save the old one and |
embeddedartists | 9:a33326afd686 | 122 | * then swap it back when done. |
embeddedartists | 9:a33326afd686 | 123 | * |
embeddedartists | 9:a33326afd686 | 124 | * @param buff the new framebuffer |
embeddedartists | 9:a33326afd686 | 125 | * @returns the old framebuffer |
embeddedartists | 9:a33326afd686 | 126 | */ |
embeddedartists | 10:1ac4b213f0f7 | 127 | virtual void* swapFramebuffer(void* buff) = 0; |
embeddedartists | 9:a33326afd686 | 128 | |
embeddedartists | 9:a33326afd686 | 129 | /** Allocate enough memory for one framebuffer |
embeddedartists | 9:a33326afd686 | 130 | * |
embeddedartists | 9:a33326afd686 | 131 | * This function is a to make it easier to allocate memory for framebuffers |
embeddedartists | 9:a33326afd686 | 132 | * as the number of bytes needed depends on width, height and bytes per pixel. |
embeddedartists | 9:a33326afd686 | 133 | * |
embeddedartists | 9:a33326afd686 | 134 | * Free the allocated memory when done using the free() function. |
embeddedartists | 9:a33326afd686 | 135 | * |
embeddedartists | 31:d47cffcb0a3e | 136 | * @param res the resolution (default is the one that the display is using) |
embeddedartists | 9:a33326afd686 | 137 | * @returns a new framebuffer or NULL if out of memory |
embeddedartists | 9:a33326afd686 | 138 | */ |
embeddedartists | 10:1ac4b213f0f7 | 139 | virtual void* allocateFramebuffer(Resolution res=Resolution_16bit_rgb565) = 0; |
embeddedartists | 31:d47cffcb0a3e | 140 | |
embeddedartists | 31:d47cffcb0a3e | 141 | /** Allocate enough memory for one or more consequtive framebuffers |
embeddedartists | 31:d47cffcb0a3e | 142 | * |
embeddedartists | 31:d47cffcb0a3e | 143 | * This function is a to make it easier to allocate memory for framebuffers |
embeddedartists | 31:d47cffcb0a3e | 144 | * as the number of bytes needed depends on width, height and bytes per pixel. |
embeddedartists | 31:d47cffcb0a3e | 145 | * |
embeddedartists | 31:d47cffcb0a3e | 146 | * Free the allocated memory when done using the free() function. |
embeddedartists | 31:d47cffcb0a3e | 147 | * |
embeddedartists | 31:d47cffcb0a3e | 148 | * Use the default parameters to get one framebuffer for the display's current |
embeddedartists | 31:d47cffcb0a3e | 149 | * resolution. |
embeddedartists | 31:d47cffcb0a3e | 150 | * |
embeddedartists | 31:d47cffcb0a3e | 151 | * @param num the number of framebuffers, should be >= 1 |
embeddedartists | 31:d47cffcb0a3e | 152 | * @param res the resolution (default is the one that the display is using) |
embeddedartists | 31:d47cffcb0a3e | 153 | * @returns new framebuffers or NULL if out of memory |
embeddedartists | 31:d47cffcb0a3e | 154 | */ |
embeddedartists | 31:d47cffcb0a3e | 155 | virtual void* allocateFramebuffers(uint32_t num=1, Resolution res=Resolution_16bit_rgb565) = 0; |
embeddedartists | 0:6b68dac0d986 | 156 | }; |
embeddedartists | 0:6b68dac0d986 | 157 | |
embeddedartists | 0:6b68dac0d986 | 158 | #endif |