Support for the emWin GUI library from Segger.

Dependents:   lpc4088_displaymodule_emwin

This library contains the porting layer needed to start working with emWin from Segger. Details about emWin can be found both segger.com as well as lpcware.com.

The high performance emWin embedded graphics library developed by SEGGER Microcontroller is now offered by NXP Semiconductors in library form for free commercial use with NXP microcontrollers.

For a better description of what is included and the limitations, see emWin Graphics Library.

Note

The emWin library and PNG support files must be downloaded as the downloaders contains the license info. The steps are described in the readme.h file.

EwHAL.h

Committer:
embeddedartists
Date:
2015-03-27
Revision:
1:2847cc35a84f
Parent:
0:582739e02e4d

File content as of revision 1:2847cc35a84f:


#ifndef EWHAL_H
#define EWHAL_H

#include "mbed.h"
#include "DMBoard.h"

/**
 * This is the main class to get Segger's emwin library up-and-running
 * with the mbed online tools.
 *
 * This class handles the porting/integration layer in emwin.
 */
class EwHAL {
public:

    EwHAL(int numFB = 1, uint32_t extraMem = 1*1024*1024);
	~EwHAL();

    /**
     * Returns the address to a memory block which may be used by emwin
     * to allocate objects. The memory block returned will be given to emwin
     * by calling GUI_ALLOC_AssignMemory.
     */
    void* getMemoryBlockAddress() { return (void*)_mem; }
	
    /**
     * Returns the size of the memory block returned by
     * getMemoryBlockAddress().
     */
    uint32_t getMemoryBlockSize() { return _memSz; }
    
    /**
     * Returns the width of the display.
     */
    uint32_t getDisplayWidth() { return _width; }
	
    /**
     * Returns the height of the display.
     */
    uint32_t getDisplayHeight() { return _height; }
    
    /**
     * Returns the address of the framebuffer (video RAM). This address will
     * be given to emwin by a call to LCD_SetVRAMAddrEx.
     */
    void* getFrameBufferAddress() { return (void*)_fb; }
	
    /**
     * Returns the size in bytes of the framebuffer (video RAM). 
     */
    uint32_t getFrameBufferSize() { return _fbSz; }
	
    /**
     * Returns the number of frame buffers to use, default is 1 meaning 
     * that drawing takes place on the same buffer that is being shown.
     * Double buffering is 2 and Tripple buffering is 3. No other values
     * should be used.
     */
    int getNumFrameBuffers() { return _numFB; }
	
    /**
     * Shows frame buffer number id. If getNumFrameBuffers() returns 1 then
     * this id will always be 0, if getNumFrameBuffers() returns N then this
     * function will be called with 0..(N-1). 
     */
    void showFrameBuffer(int id);
    
    /**
     * Returns the x coordinate of the latest touch event
     */
    int32_t getTouchX() {return _coord.x;}

    /**
     * Returns the y coordinate of the latest touch event
     */
    int32_t getTouchY() {return _coord.y;}
	

private:

    /**
     * Called when a new touch event is available. Reads the coordinates and
	 * forwards them to emWin
     */
	void handleTouchEvent();

	int _numFB;
	FunctionPointer* _fp;
    uint32_t _width;
    uint32_t _height;
    uint32_t _fb;
    uint32_t _fbSz;
    uint32_t _mem;
    uint32_t _memSz;
    Display*  _display;
    TouchPanel* _touch;
	touch_coordinate_t _coord;
};

#endif