Simulation
Principle
The simulation part of the UI port requires the creation (or extension) of a Front Panel project which is compatible with the UI Pack.
First, if no Front Panel project exists, follow the steps described here: Front Panel Mock. Then, follow the next chapters to extend the Front Panel project with UI Pack notions.
Project Extension
The Front Panel project must depend on the UI Pack. Add the following dependency to the project build file:
implementation("ej.tool.frontpanel:framework:1.1.0")
implementation("com.microej.pack.ui:ui-pack:[UI Pack version]") {
artifact {
name = "frontpanel"
extension = "jar"
}
}
<dependency org="com.microej.pack.ui" name="ui-pack" rev="[UI Pack version]">
<artifact name="frontpanel" type="jar"/>
</dependency>
See Simulation for more information about the Front Panel project dependencies.
LEDs
When the VEE Port Configuration project LEDs module is checked, the Front Panel project should add a widget LED
for each led.
With an image editor, create an image for the LED off and an image for the LED on. Both images must have the same size.
Create a couple of images for each LED.
In the Front Panel description file, add this line for each LED:
<ej.fp.widget.LED label="0" x="170" y="753" ledOff="Led-0.png" ledOn="Led-GREEN.png" overlay="false"/>
The label must have an integer value from 0 to NUMBER_OF_LEDS - 1
.
The ej.microui.led.Leds
class uses this value as the LED identifier in setLedOff(int ledId)
, setLedOn(int ledId)
, and other methods of the class.
Touch Panel
Contrary to the other input devices, no image is required because a touch panel covers the display area.
Retrieve the display size in pixels.
In the Front Panel description file, add this line:
<ej.fp.widget.Pointer x="185" y="395" width="480" height="272" touch="true"/>
By default, the widget sends a MicroUI Pointer event to the Pointer Event Generator, whose name is TOUCH
(a touch panel is considered a Pointer with only dragged events).
To target another Pointer Event Generator, refer to the chapter Inputs Extensions.
A snippet of application code that handles Pointer events:
// [...]
Pointer[] pointerHandlers = (Pointer[]) EventGenerator.get(Pointer.class);
for (EventGenerator pointerHandler : generators) {
pointerHandler.setEventHandler(this);
}
// [...]
@Override
public boolean handleEvent(int event) {
Pointer pointer = (Pointer) Event.getGenerator(event);
int x = pointer.getX();
int y = pointer.getY();
System.out.println("(" + x + "," + y + ")");
}
Display
The widget Display features a lot of options to simulate the hardware specificities.
Retrieve the display size in pixels.
In the Front Panel description file, add this line:
<ej.fp.widget.Display x="185" y="395" width="480" height="272"/>
For more information, refer to the java-doc of the widget Display and the chapter Display Widget.
Build
Once the Front Panel project is created or modified, the VEE Port must be built again (the front panel is built simultaneously with the VEE Port; see VEE Port Build).