|
The PC simulation of emWin allows you to compile the
same "C" source on your Windows PC using a native (typically Microsoft)
compiler and create an executable for your own application. Doing so allows
the following:
- Design of the user interface on your PC (no need for hardware!)
- Debugging of your user interface program.
- Creation of demos of your application, which can be used to discuss
the user interface.
The resulting executable can be easily sent via email.
Understanding the simulator
The emWin simulator uses Microsoft Visual C++ (version
6.00 or higher) and the integrated development environment which comes
with it. You will see a simulation of your LCD on your PC screen, which
will have the same resolution in X and Y and can display the exact same
colors as your LCD once it has been properly configured. The entire graphic
library API and window manager API of the simulation are identical to
those on your target system; all functions will behave in the very same
way as on the target hardware since the simulation uses the same "C" source
code as the target system. The difference lies only in the lower level
of the software: the LCD driver. Instead of using the actual LCD driver,
the PC simulation uses a simulation driver which writes into a bitmap.
The bitmap is then displayed on your screen using a second thread of the
simulation. This second thread is invisible to the application; it behaves
just as if the LCD routines were writing directly to the display.
Using the simulator
The simulation contains one or more application "C"
files, which can be modified. Typically you would want to at least change
the bitmap to your own company logo or image of choice. You should then
rebuild the program within the Visual C++ work-space in order to test/debug
it. Once you have reached a point where you are satisfied with the result
and want to use the program in your application, you should be able to
compile these same files on your target system and get the same result
on the target display. The general procedure for using the simulator would
be as follows:
- Step 1: Open the Visual C++ workspace by double-clicking on Simulation.dsw.
- Step 2: Compile and run the application program (located in the Application
directory).
- Step 3: Replace the bitmap with your own logo or image.
- Step 4: Make further modifications to the application program as necessary.
- Step 5: Compile and run the application program within Visual C++
to test the results. Continue to modify and debug as needed.
- Step 6: Compile and run the application program on your target system.
The viewer
If you use the simulator to debug your application,
you cannot see the LCD output when stepping through the source code. The
viewer solves this problem by showing the LCD window and the color window
of your simulation.
Using the simulator and the viewer
It is your choice if you want to start the viewer before
debugging your application or while you are debugging. Our suggestion:
- Step 1: Start the viewer. No LCD- or color window is shown until the
simulation has been started.
- Step 2: Open the Visual C++ workspace.
- Step 3: Compile and run the application program.
- Step 4: Debug the application as described previously.
The advantage is that you can now follow all drawing
operations step by step in the LCD window. Per default the viewer window
is always on top. You can change this behavior by selecting View\Always
on top from the menu.
Device simulation and other advanced features
The simulator can show the simulated LCD in a bitmap
of your choice, typically your target device. The bitmap can be dragged
over the screen and may, in certain applications, be used to simulate
the behavior of the entire target device.
Hardkey simulation
Hardkeys may also be simulated as part of the device,
and may be selected with the mouse pointer. The idea is to be able to
distinguish whether a key or button on the simulated device is pressed
or unpressed. A hardkey is considered "pressed" as long as the mouse button
is held down; releasing the mouse button or moving the pointer off of
the hardkey "unpresses" the key. A toggle behavior between pressed and
unpressed may also be specified with the routine SIM_HARDKEY_SetMode.
Simulator API
All of the simulator API functions must be called in
the setup phase. The calls should ideally be done from within the routine
SIM_X_Init(), which is
located in the file SIM_X.c.
The example below calls SIM_SetLCDPos()
in the setup:
#include
#include
#include "SIM.h"
void SIM_X_Init() {
SIM_SetLCDPos(0,0); // Define the position of the LCD in the bitmap
}
|
The table below lists the available simulation-related
routines in alphabetical order within their respective categories. Detailed
descriptions of the routines follow:
| SIM_SetLCDPos() |
Set the position for the simulated LCD within the target device
bit-map. |
| SIM_SetTransColor() |
Set the color to be used for transparent areas (default: 0xFF0000). |
| SIM_HARDKEY_GetNum() |
Return the number of available hardkeys. |
| SIM_HARDKEY_GetState() |
Return the state of a specified hardkey (0: unpressed, 1: pressed). |
| SIM_HARDKEY_SetCallback() |
Set a callback routine to be executed when the state of a specified hardkey changes. |
| SIM_HARDKEY_SetMode() |
Set the behavior for a specified hardkey (default = 0: no toggle). |
| SIM_HARDKEY_SetState() |
Set the state for a specified hardkey (0: unpressed, 1: pressed). |

Copyright SEGGER Microcontroller GmbH & Co.KG.
All rights reserved.
For more information, please visit our web site
www.segger.com or contact us at info@segger.com
Last update:
December 7, 2007
|