Support for the emWin GUI library from Segger.

Dependents:   lpc4088_displaymodule_emwin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EwHAL.h Source File

EwHAL.h

00001 
00002 #ifndef EWHAL_H
00003 #define EWHAL_H
00004 
00005 #include "mbed.h"
00006 #include "DMBoard.h"
00007 
00008 /**
00009  * This is the main class to get Segger's emwin library up-and-running
00010  * with the mbed online tools.
00011  *
00012  * This class handles the porting/integration layer in emwin.
00013  */
00014 class EwHAL {
00015 public:
00016 
00017     EwHAL(int numFB = 1, uint32_t extraMem = 1*1024*1024);
00018     ~EwHAL();
00019 
00020     /**
00021      * Returns the address to a memory block which may be used by emwin
00022      * to allocate objects. The memory block returned will be given to emwin
00023      * by calling GUI_ALLOC_AssignMemory.
00024      */
00025     void* getMemoryBlockAddress() { return (void*)_mem; }
00026     
00027     /**
00028      * Returns the size of the memory block returned by
00029      * getMemoryBlockAddress().
00030      */
00031     uint32_t getMemoryBlockSize() { return _memSz; }
00032     
00033     /**
00034      * Returns the width of the display.
00035      */
00036     uint32_t getDisplayWidth() { return _width; }
00037     
00038     /**
00039      * Returns the height of the display.
00040      */
00041     uint32_t getDisplayHeight() { return _height; }
00042     
00043     /**
00044      * Returns the address of the framebuffer (video RAM). This address will
00045      * be given to emwin by a call to LCD_SetVRAMAddrEx.
00046      */
00047     void* getFrameBufferAddress() { return (void*)_fb; }
00048     
00049     /**
00050      * Returns the size in bytes of the framebuffer (video RAM). 
00051      */
00052     uint32_t getFrameBufferSize() { return _fbSz; }
00053     
00054     /**
00055      * Returns the number of frame buffers to use, default is 1 meaning 
00056      * that drawing takes place on the same buffer that is being shown.
00057      * Double buffering is 2 and Tripple buffering is 3. No other values
00058      * should be used.
00059      */
00060     int getNumFrameBuffers() { return _numFB; }
00061     
00062     /**
00063      * Shows frame buffer number id. If getNumFrameBuffers() returns 1 then
00064      * this id will always be 0, if getNumFrameBuffers() returns N then this
00065      * function will be called with 0..(N-1). 
00066      */
00067     void showFrameBuffer(int id);
00068     
00069     /**
00070      * Returns the x coordinate of the latest touch event
00071      */
00072     int32_t getTouchX() {return _coord.x;}
00073 
00074     /**
00075      * Returns the y coordinate of the latest touch event
00076      */
00077     int32_t getTouchY() {return _coord.y;}
00078     
00079 
00080 private:
00081 
00082     /**
00083      * Called when a new touch event is available. Reads the coordinates and
00084      * forwards them to emWin
00085      */
00086     void handleTouchEvent();
00087 
00088     int _numFB;
00089     FunctionPointer* _fp;
00090     uint32_t _width;
00091     uint32_t _height;
00092     uint32_t _fb;
00093     uint32_t _fbSz;
00094     uint32_t _mem;
00095     uint32_t _memSz;
00096     Display*  _display;
00097     TouchPanel* _touch;
00098     touch_coordinate_t _coord;
00099 };
00100 
00101 #endif
00102