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@10:1ac4b213f0f7, 2014-12-19 (annotated)
- Committer:
- embeddedartists
- Date:
- Fri Dec 19 09:03:25 2014 +0100
- Revision:
- 10:1ac4b213f0f7
- Parent:
- 9:a33326afd686
- Child:
- 22:1a58a518435c
- Added support for executing code in SDRAM.
- Restructured the Display/Touch interfaces.
- Added loading of Display/Touch BIOS.
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 | 10:1ac4b213f0f7 | 65 | DisplayError_MemoryError, |
embeddedartists | 0:6b68dac0d986 | 66 | }; |
embeddedartists | 0:6b68dac0d986 | 67 | |
embeddedartists | 0:6b68dac0d986 | 68 | enum Resolution { |
embeddedartists | 10:1ac4b213f0f7 | 69 | Resolution_16bit_rgb565 = Res_16bit_rgb565, |
embeddedartists | 10:1ac4b213f0f7 | 70 | Resolution_18bit_rgb666 = Res_18bit_rgb666, |
embeddedartists | 10:1ac4b213f0f7 | 71 | Resolution_24bit_rgb888 = Res_24bit_rgb888, |
embeddedartists | 0:6b68dac0d986 | 72 | }; |
embeddedartists | 0:6b68dac0d986 | 73 | |
embeddedartists | 9:a33326afd686 | 74 | /** Turns the display on with the specified framebuffer showing |
embeddedartists | 0:6b68dac0d986 | 75 | * |
embeddedartists | 0:6b68dac0d986 | 76 | * @returns |
embeddedartists | 0:6b68dac0d986 | 77 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 78 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 79 | */ |
embeddedartists | 10:1ac4b213f0f7 | 80 | virtual DisplayError powerUp(void* framebuffer, Resolution wanted = Resolution_16bit_rgb565) = 0; |
embeddedartists | 0:6b68dac0d986 | 81 | |
embeddedartists | 9:a33326afd686 | 82 | /** Turns the display off |
embeddedartists | 0:6b68dac0d986 | 83 | * |
embeddedartists | 0:6b68dac0d986 | 84 | * @returns |
embeddedartists | 0:6b68dac0d986 | 85 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 86 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 87 | */ |
embeddedartists | 10:1ac4b213f0f7 | 88 | virtual DisplayError powerDown() = 0; |
embeddedartists | 0:6b68dac0d986 | 89 | |
embeddedartists | 0:6b68dac0d986 | 90 | /** Sets the backlight level. 0% is off and 100% is fully on |
embeddedartists | 0:6b68dac0d986 | 91 | * |
embeddedartists | 0:6b68dac0d986 | 92 | * @returns |
embeddedartists | 0:6b68dac0d986 | 93 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 94 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 95 | */ |
embeddedartists | 10:1ac4b213f0f7 | 96 | virtual DisplayError backlight(int percent) = 0; |
embeddedartists | 0:6b68dac0d986 | 97 | |
embeddedartists | 10:1ac4b213f0f7 | 98 | virtual uint16_t width() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 99 | virtual uint16_t height() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 100 | virtual uint16_t bytesPerPixel() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 101 | virtual uint32_t fbSize() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 102 | virtual bool landscape() = 0; |
embeddedartists | 10:1ac4b213f0f7 | 103 | virtual bool isSupported(Resolution res) = 0; |
embeddedartists | 10:1ac4b213f0f7 | 104 | virtual Resolution currentResolution() = 0; |
embeddedartists | 9:a33326afd686 | 105 | |
embeddedartists | 9:a33326afd686 | 106 | /** Replaces the current framebuffer. |
embeddedartists | 9:a33326afd686 | 107 | * |
embeddedartists | 9:a33326afd686 | 108 | * Note that this requires the caller or someone else to have a |
embeddedartists | 9:a33326afd686 | 109 | * reference to the existing framebuffer, otherwise that memory |
embeddedartists | 9:a33326afd686 | 110 | * is lost. |
embeddedartists | 9:a33326afd686 | 111 | * |
embeddedartists | 9:a33326afd686 | 112 | * @param buff the new framebuffer |
embeddedartists | 9:a33326afd686 | 113 | */ |
embeddedartists | 10:1ac4b213f0f7 | 114 | virtual void setFramebuffer(void* buff) = 0; |
embeddedartists | 9:a33326afd686 | 115 | |
embeddedartists | 9:a33326afd686 | 116 | /** Replaces the current framebuffer with the specified one. |
embeddedartists | 9:a33326afd686 | 117 | * |
embeddedartists | 9:a33326afd686 | 118 | * This function as opposed to the setFramebuffer() one does return |
embeddedartists | 9:a33326afd686 | 119 | * the old framebuffer. This way the caller can save the old one and |
embeddedartists | 9:a33326afd686 | 120 | * then swap it back when done. |
embeddedartists | 9:a33326afd686 | 121 | * |
embeddedartists | 9:a33326afd686 | 122 | * @param buff the new framebuffer |
embeddedartists | 9:a33326afd686 | 123 | * @returns the old framebuffer |
embeddedartists | 9:a33326afd686 | 124 | */ |
embeddedartists | 10:1ac4b213f0f7 | 125 | virtual void* swapFramebuffer(void* buff) = 0; |
embeddedartists | 9:a33326afd686 | 126 | |
embeddedartists | 9:a33326afd686 | 127 | /** Allocate enough memory for one framebuffer |
embeddedartists | 9:a33326afd686 | 128 | * |
embeddedartists | 9:a33326afd686 | 129 | * This function is a to make it easier to allocate memory for framebuffers |
embeddedartists | 9:a33326afd686 | 130 | * as the number of bytes needed depends on width, height and bytes per pixel. |
embeddedartists | 9:a33326afd686 | 131 | * |
embeddedartists | 9:a33326afd686 | 132 | * Free the allocated memory when done using the free() function. |
embeddedartists | 9:a33326afd686 | 133 | * |
embeddedartists | 9:a33326afd686 | 134 | * @returns a new framebuffer or NULL if out of memory |
embeddedartists | 9:a33326afd686 | 135 | */ |
embeddedartists | 10:1ac4b213f0f7 | 136 | virtual void* allocateFramebuffer(Resolution res=Resolution_16bit_rgb565) = 0; |
embeddedartists | 0:6b68dac0d986 | 137 | }; |
embeddedartists | 0:6b68dac0d986 | 138 | |
embeddedartists | 0:6b68dac0d986 | 139 | #endif |