I have a custom board made with STM32L471 controller.
At the minimum, i only wanted to see something in display.
It is a Black and white display, so i have configured Index8 in profile.
I have following things done.
Initialized the EmWiz app in main function. Check the code below.
tlsf_t MemPool;
extern BYTE LcdRam[LCD_RAM_BUFFER_SIZE];
#define LCD_FB_START_ADDRESS (LcdRam) // LcdRam is the LCD mirror data and it is copied to LCD display, by different raster(100ms)
static void EmWiMainLoop( const void* arg );
/* define pyhiscal dimension of the LCD framebuffer */
#define FRAME_BUFFER_WIDTH 255
#define FRAME_BUFFER_HEIGHT 160
/* calculated addresses for framebuffer(s) and memory manager */
#define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH * FRAME_BUFFER_HEIGHT * FRAME_BUFFER_DEPTH
#define FRAME_BUFFER_ADDR (void*)(LCD_FB_START_ADDRESS)
#define MEMORY_POOL_SIZE 0x1000
const BYTE memPool[MEMORY_POOL_SIZE]={0};
#define MEMORY_POOL_ADDR ((void*)memPool )
#define EW_SURFACE_ROTATION 0
#define FREE_RTOS 0
CoreRoot rootObject;
XViewport* viewport;
BYTE emWizInit(void)
{
SetBackLight(TRUE);
/* initialize tlsf memory manager */
MemPool = tlsf_create_with_pool( MEMORY_POOL_ADDR, MEMORY_POOL_SIZE );
/* initialize the Graphics Engine and Runtime Environment */
if ( EwInitGraphicsEngine( 0 ) != 0)
{
dontComeIn = TRUE;
return 1;
}
rootObject = (CoreRoot)EwNewObjectIndirect( EwApplicationClass, 0 );
EwLockObject( rootObject );
CoreRoot__Initialize( rootObject, EwScreenSize );
viewport = EwInitViewport( EwScreenSize, EwNewRect( 0, 0, FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT ),
0, 255, FRAME_BUFFER_ADDR, DOUBLE_BUFFER_ADDR, 0, 0 );
return 0;
}
void EmWiMainLoop( const void* arg ) // this is in 100ms raster.
{
Update( viewport, rootObject );
/* after each processed message start the garbage collection */
EwReclaimMemory();
}
void Update( XViewport* aViewport, CoreRoot aApplication )
{
XBitmap* bitmap = EwBeginUpdate( aViewport );
GraphicsCanvas canvas = EwNewObject( GraphicsCanvas, 0 );
XRect updateRect = {{ 0, 0 }, { 0, 0 }};
/* let's redraw the dirty area of the screen. Cover the returned bitmap
objects within a canvas, so Mosaic can draw to it. */
if ( bitmap && canvas )
{
GraphicsCanvas__AttachBitmap( canvas, (XUInt32)bitmap );
updateRect = CoreRoot__UpdateGE20( aApplication, canvas );
GraphicsCanvas__DetachBitmap( canvas );
}
/* complete the update */
if ( bitmap )
{
EwEndUpdate( aViewport, updateRect );
}
/* check if there is a dirty area so that the screen should be updated */
if (( updateRect.Point2.X - updateRect.Point1.X <= 0 ) || ( updateRect.Point2.Y - updateRect.Point1.Y <= 0 ))
{
return;
}
}
I have configured the EmWiSystemTicks to get updated on every 1ms.
I dont have a serial console to see the output.