t
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos
Fork of DMSupport by
Diff: Display/Display.h
- Revision:
- 10:1ac4b213f0f7
- Parent:
- 9:a33326afd686
- Child:
- 22:1a58a518435c
--- a/Display/Display.h Thu Dec 11 18:23:07 2014 +0000 +++ b/Display/Display.h Fri Dec 19 09:03:25 2014 +0100 @@ -18,6 +18,7 @@ #define DISPLAY_H #include "mbed.h" +#include "bios.h" /** * Display example @@ -54,50 +55,29 @@ */ class Display { public: - enum Constants { - NumLEDs = 4, - }; - enum DisplayError { - Ok = 0, - ConfigError = 1, - WrongBPP = 2, - InvalidParam = 3, - NoInit = 4, + DisplayError_Ok = BiosError_Ok, + DisplayError_ConfigError = BiosError_ConfigError, + DisplayError_WrongBPP = BiosError_WrongBPP, + DisplayError_InvalidParam = BiosError_InvalidParam, + DisplayError_NoInit = BiosError_NoInit, + DisplayError_CalibrationError = BiosError_Calibration, + DisplayError_MemoryError, }; enum Resolution { - Resolution_16bit_rgb565 = 16, - Resolution_18bit_rgb666 = 18, - Resolution_24bit_rgb888 = 24, + Resolution_16bit_rgb565 = Res_16bit_rgb565, + Resolution_18bit_rgb666 = Res_18bit_rgb666, + Resolution_24bit_rgb888 = Res_24bit_rgb888, }; - /** Get the only instance of the Display - * - * @returns The display - */ - static Display& instance() - { - static Display singleton; - return singleton; - } - - - /** Initializes the display but does not turn it on - * - * @returns - * Ok on success - * An error code on failure - */ - DisplayError init(); - /** Turns the display on with the specified framebuffer showing * * @returns * Ok on success * An error code on failure */ - DisplayError powerUp(void* framebuffer, Resolution wanted = Resolution_16bit_rgb565); + virtual DisplayError powerUp(void* framebuffer, Resolution wanted = Resolution_16bit_rgb565) = 0; /** Turns the display off * @@ -105,7 +85,7 @@ * Ok on success * An error code on failure */ - DisplayError powerDown(); + virtual DisplayError powerDown() = 0; /** Sets the backlight level. 0% is off and 100% is fully on * @@ -113,14 +93,15 @@ * Ok on success * An error code on failure */ - DisplayError backlight(int percent); + virtual DisplayError backlight(int percent) = 0; - uint16_t width() { return _width; } - uint16_t height() { return _height; } - uint16_t bpp() { return _bpp; } - uint32_t fbSize() { return _fbSize; } - bool landscape() { return _landscape; } - bool isSupported(Resolution res); + virtual uint16_t width() = 0; + virtual uint16_t height() = 0; + virtual uint16_t bytesPerPixel() = 0; + virtual uint32_t fbSize() = 0; + virtual bool landscape() = 0; + virtual bool isSupported(Resolution res) = 0; + virtual Resolution currentResolution() = 0; /** Replaces the current framebuffer. * @@ -130,7 +111,7 @@ * * @param buff the new framebuffer */ - void setFramebuffer(void* buff); + virtual void setFramebuffer(void* buff) = 0; /** Replaces the current framebuffer with the specified one. * @@ -141,7 +122,7 @@ * @param buff the new framebuffer * @returns the old framebuffer */ - void* swapFramebuffer(void* buff); + virtual void* swapFramebuffer(void* buff) = 0; /** Allocate enough memory for one framebuffer * @@ -152,38 +133,7 @@ * * @returns a new framebuffer or NULL if out of memory */ - void* allocateFramebuffer(Resolution res=Resolution_16bit_rgb565); - -private: - - bool _initialized; - bool _poweredOn; - DigitalOut _pinWP; - DigitalOut _pin3v3; - DigitalOut _pin5v; - DigitalOut _pinDE; - DigitalOut _pinColDepth; - PwmOut _pinBacklight; - - uint16_t _width; - uint16_t _height; - uint16_t _bpp; - uint32_t _fbSize; - bool _landscape; - - explicit Display(); - // hide copy constructor - Display(const Display&); - // hide assign operator - Display& operator=(const Display&); - ~Display(); - - void pinInit(bool powerOn, Resolution res=Resolution_16bit_rgb565); - DisplayError regInit(void* info, Resolution res); - uint32_t getClockDivisor(uint32_t clock); - void set3v3(bool on); - void set5v(bool on); - void setDisplayEnable(bool enable); + virtual void* allocateFramebuffer(Resolution res=Resolution_16bit_rgb565) = 0; }; #endif