mbed support for LPC4088 Display Module

Dependencies:   DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src

Dependents:   emptyProgram

Fork of DMSupport by Embedded Artists

Committer:
embeddedartists
Date:
Fri Nov 21 11:42:51 2014 +0000
Revision:
0:6b68dac0d986
Child:
9:a33326afd686
First version

Who changed what in which revision?

UserRevisionLine numberNew 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 0:6b68dac0d986 21
embeddedartists 0:6b68dac0d986 22 class Display {
embeddedartists 0:6b68dac0d986 23 public:
embeddedartists 0:6b68dac0d986 24 enum Constants {
embeddedartists 0:6b68dac0d986 25 NumLEDs = 4,
embeddedartists 0:6b68dac0d986 26 };
embeddedartists 0:6b68dac0d986 27
embeddedartists 0:6b68dac0d986 28 enum DisplayError {
embeddedartists 0:6b68dac0d986 29 Ok = 0,
embeddedartists 0:6b68dac0d986 30 ConfigError = 1,
embeddedartists 0:6b68dac0d986 31 WrongBPP = 2,
embeddedartists 0:6b68dac0d986 32 InvalidParam = 3,
embeddedartists 0:6b68dac0d986 33 NoInit = 4,
embeddedartists 0:6b68dac0d986 34 };
embeddedartists 0:6b68dac0d986 35
embeddedartists 0:6b68dac0d986 36 enum Resolution {
embeddedartists 0:6b68dac0d986 37 Resolution_16bit_rgb565 = 16,
embeddedartists 0:6b68dac0d986 38 Resolution_18bit_rgb666 = 18,
embeddedartists 0:6b68dac0d986 39 Resolution_24bit_rgb888 = 24,
embeddedartists 0:6b68dac0d986 40 };
embeddedartists 0:6b68dac0d986 41
embeddedartists 0:6b68dac0d986 42 static Display& instance()
embeddedartists 0:6b68dac0d986 43 {
embeddedartists 0:6b68dac0d986 44 static Display singleton;
embeddedartists 0:6b68dac0d986 45 return singleton;
embeddedartists 0:6b68dac0d986 46 }
embeddedartists 0:6b68dac0d986 47
embeddedartists 0:6b68dac0d986 48
embeddedartists 0:6b68dac0d986 49 /** Initializes the wanted features
embeddedartists 0:6b68dac0d986 50 *
embeddedartists 0:6b68dac0d986 51 * @returns
embeddedartists 0:6b68dac0d986 52 * Ok on success
embeddedartists 0:6b68dac0d986 53 * An error code on failure
embeddedartists 0:6b68dac0d986 54 */
embeddedartists 0:6b68dac0d986 55 DisplayError init();
embeddedartists 0:6b68dac0d986 56
embeddedartists 0:6b68dac0d986 57 /** Initializes the wanted features
embeddedartists 0:6b68dac0d986 58 *
embeddedartists 0:6b68dac0d986 59 * @returns
embeddedartists 0:6b68dac0d986 60 * Ok on success
embeddedartists 0:6b68dac0d986 61 * An error code on failure
embeddedartists 0:6b68dac0d986 62 */
embeddedartists 0:6b68dac0d986 63 DisplayError powerUp(void* framebuffer, Resolution wanted = Resolution_16bit_rgb565);
embeddedartists 0:6b68dac0d986 64
embeddedartists 0:6b68dac0d986 65 /** Initializes the wanted features
embeddedartists 0:6b68dac0d986 66 *
embeddedartists 0:6b68dac0d986 67 * @returns
embeddedartists 0:6b68dac0d986 68 * Ok on success
embeddedartists 0:6b68dac0d986 69 * An error code on failure
embeddedartists 0:6b68dac0d986 70 */
embeddedartists 0:6b68dac0d986 71 DisplayError powerDown();
embeddedartists 0:6b68dac0d986 72
embeddedartists 0:6b68dac0d986 73 /** Sets the backlight level. 0% is off and 100% is fully on
embeddedartists 0:6b68dac0d986 74 *
embeddedartists 0:6b68dac0d986 75 * @returns
embeddedartists 0:6b68dac0d986 76 * Ok on success
embeddedartists 0:6b68dac0d986 77 * An error code on failure
embeddedartists 0:6b68dac0d986 78 */
embeddedartists 0:6b68dac0d986 79 DisplayError backlight(int percent);
embeddedartists 0:6b68dac0d986 80
embeddedartists 0:6b68dac0d986 81 uint16_t width() { return _width; }
embeddedartists 0:6b68dac0d986 82 uint16_t height() { return _height; }
embeddedartists 0:6b68dac0d986 83 uint16_t bpp() { return _bpp; }
embeddedartists 0:6b68dac0d986 84 uint32_t fbSize() { return _fbSize; }
embeddedartists 0:6b68dac0d986 85 bool landscape() { return _landscape; }
embeddedartists 0:6b68dac0d986 86 bool isSupported(Resolution res);
embeddedartists 0:6b68dac0d986 87 void setFramebuffer(void* buff);
embeddedartists 0:6b68dac0d986 88 void* swapFramebuffer(void* buff);
embeddedartists 0:6b68dac0d986 89 void* allocateFramebuffer(Resolution res=Resolution_16bit_rgb565);
embeddedartists 0:6b68dac0d986 90
embeddedartists 0:6b68dac0d986 91 private:
embeddedartists 0:6b68dac0d986 92
embeddedartists 0:6b68dac0d986 93 bool _initialized;
embeddedartists 0:6b68dac0d986 94 bool _poweredOn;
embeddedartists 0:6b68dac0d986 95 DigitalOut _pinWP;
embeddedartists 0:6b68dac0d986 96 DigitalOut _pin3v3;
embeddedartists 0:6b68dac0d986 97 DigitalOut _pin5v;
embeddedartists 0:6b68dac0d986 98 DigitalOut _pinDE;
embeddedartists 0:6b68dac0d986 99 DigitalOut _pinColDepth;
embeddedartists 0:6b68dac0d986 100 PwmOut _pinBacklight;
embeddedartists 0:6b68dac0d986 101
embeddedartists 0:6b68dac0d986 102 uint16_t _width;
embeddedartists 0:6b68dac0d986 103 uint16_t _height;
embeddedartists 0:6b68dac0d986 104 uint16_t _bpp;
embeddedartists 0:6b68dac0d986 105 uint32_t _fbSize;
embeddedartists 0:6b68dac0d986 106 bool _landscape;
embeddedartists 0:6b68dac0d986 107
embeddedartists 0:6b68dac0d986 108 explicit Display();
embeddedartists 0:6b68dac0d986 109 // hide copy constructor
embeddedartists 0:6b68dac0d986 110 Display(const Display&);
embeddedartists 0:6b68dac0d986 111 // hide assign operator
embeddedartists 0:6b68dac0d986 112 Display& operator=(const Display&);
embeddedartists 0:6b68dac0d986 113 ~Display();
embeddedartists 0:6b68dac0d986 114
embeddedartists 0:6b68dac0d986 115 void pinInit(bool powerOn, Resolution res=Resolution_16bit_rgb565);
embeddedartists 0:6b68dac0d986 116 DisplayError regInit(void* info, Resolution res);
embeddedartists 0:6b68dac0d986 117 uint32_t getClockDivisor(uint32_t clock);
embeddedartists 0:6b68dac0d986 118 void set3v3(bool on);
embeddedartists 0:6b68dac0d986 119 void set5v(bool on);
embeddedartists 0:6b68dac0d986 120 void setDisplayEnable(bool enable);
embeddedartists 0:6b68dac0d986 121 };
embeddedartists 0:6b68dac0d986 122
embeddedartists 0:6b68dac0d986 123 #endif
embeddedartists 0:6b68dac0d986 124