Research on Windows CE embedded Navigation System (application related)

Source: Internet
Author: User
1.1.1 tcpmp multimedia player

The multimedia player used in this system is tcpmp. tcpmp players play quickly and support up to dozens of multimedia formats. The open-source tcpmp project also supports the Windows CE operating system and provides excellent scalability. For example, to rewrite the tcpmp interface, you only need to rewrite interface. PLG. Tcpmp provides all the source code, which is very convenient for porting. You only need to copy the generated file to the target machine after compilation. The tcpmp multimedia player interface is very simple, as shown in Figure 5.35.

Figure 5.37 tcpmp Software Interface

In addition, tcpmp also supports application integration. You can move the core of tcpmp playback to the specified interface location of the specified application to achieve simultaneous multimedia playback and other tasks, it is often used on the elevator advertising player platform.

1.1.2 Kay lide navigation software

The system's navigation software adopts the navigation software of Kay lide, which has experienced more than 10 years of development and has developed into a mature navigation software platform. Kay lide has released a number of embedded, mobile phone and other platform navigation software versions, including support for Windows Mobile platform, Symbian platform, and of course Windows CE platform. Kailide navigation software interface 57 is shown.

In addition, compared with peers, the kailide navigation software prompts a wide range of information. On the expressway, there are prompts for the distance between the main entrances and exits, and the distance between the service areas, you can also plan where you can rest and where to refuel based on the distance between the service area.

Figure 5.38 Kay lide navigation software

1.1.3 tqshell Interface Design 1. Design Description

In order to provide system interaction and operability, an interactive interface software should be designed during system integration, and the software should be started at startup, with a resolution of 320 × 240. Considering that the functions of the system are relatively independent, the system mainly provides calling functions such as GPS navigation, Internet, tcpmp, games, common tools, and my devices when the interface is segmented, in this way, the interface is fresh and concise, as shown in Figure 5.39;

Figure 5.39 tqshell Interface

In addition, the key (5.40) is also supported on our development board to provide functions such as switching between left and right. Therefore, when designing the tashell interface, we also support the key function. The key-Pressing function is easy to support. You only need to respond to the onkeydown event.

Figure 5.40 key schematic

2. Image Rendering

The tqshell interface is designed by drawing BMP images. The effect of each button is displayed by switching one image. Image Rendering is the key to the tqshell interface design. The following describes the code implementation of Image Rendering. First, we will introduce the two important functions createcompatibledc [7] And bitblt.

(1) createcompatibledc Function

This function is used to create a memory device environment that is compatible with the device Environment pointed to by the PDC-also known as the memory device context. The memory device environment is a memory block used for display. It is used to store images before copying the memory image to the actual display device. This is exactly why the screen is not flashed, the function prototype is as follows;

Virtual bool createcompatibledc (CDC * PDC );

The PDC points to a device environment, which is often obtained by getdc () in MFC. If the PDC value is blank, the function creates a memory device environment compatible with the system display.

Call this function. After the memory device environment is created, GDI automatically loads a black/white bitmap for it. The output function of GDI can be output only when a bitmap canvas is available in the memory device environment. However, when using this function, you must note that this function can only be used to create compatible device environments for devices that support grating operations.

(2) bitblt Function

As mentioned above, the createcompatibledc function is used to create a memory device environment compatible with the device context. The bitblt function is used to copy bitmap from the source device context (that is, the memory device environment) to the current device context. The prototype of this function is as follows;

Bool bitblt (int x, int y, int nwidth, int nheight, CDC * psrcdc, int xsrc, int ysrc, DWORD dwrop );

L x specifies the logical X coordinate in the upper left corner of the target rectangle.

L y specifies the logical y coordinate in the upper left corner of the target rectangle.

L nwidth specifies the width (logical unit) of the target rectangle and source bitmap ).

L nheight specifies the height (logical unit) of the target rectangle and source bitmap ).

L psrcdc pointer to the CDC object, which identifies the device context of the bitmap to be copied. If dwrop specifies a grating operation that does not include the source, it must be null.

L xsrc specifies the logical X coordinate in the upper left corner of the source bitmap.

L ysrc specifies the logical y coordinate in the upper left corner of the source bitmap.

L dwdrop specifies the grating operation to be performed. The raster operation code defines how GDC merges colors in the output operation, including the current paint brush, possible source bitmap, and target bitmap.

With the bitblt function, the application can align the window or customer area on the byte boundary to ensure that bitblt operations occur on the byte alignment rectangle.

Bitblt operations on Byte-aligned rectangles are much faster than bitblt operations on non-byte-aligned rectangles. If you want to specify the byte alignment class style for your device context, you must register the window class instead of relying on the Microsoft basic class. You can use the global function afxregisterwndclass.

Once the target device context is used and the source device context is used, GDI deformation nwidth and nheight. If the result extension does not match, if necessary, GDI uses the Windows stretchblt function to compress or stretch the source bitmap. If the color formats of the target, source, and feature bitmap are different, bitblt converts the source and feature bitmaps to match the target. The foreground and background colors of the target bitmap are used in the conversion.

When the bitblt function converts a monochrome bitmap to a color, it sets white (1) as the background color, and black (0) as the foreground color. Use the background and foreground color of the target device context. To convert the color to a monochrome color, bitblt sets the pixels that match the background color to white, and all other pixels to black. In the conversion from color to monochrome, bitblt uses the foreground and background color of the color device context.

Note that not all device context supports bitblt. To check whether the given device context supports bitblt, use the getdevicecaps member function and specify the rastercaps index.

After learning about the functions of these two functions, it is quite simple to compile the plotting program. The drawing program in the tqshell interface is shown in the 5 th 55 program;

Program list 5 Drawing Image Code

CDC * PDC = getdc ();

CDC memdc;

Memdc. createcompatibledc (PDC );

Cbitmap BMP, BMP 1;

Cbitmap * poldbitmap;

BMP 1.loadbitmap (m_map );

Poldbitmap = memdc. SelectObject (& BMP 1 );

PDC-> bitblt (m_rect [I]. topleft (). X, m_rect [I]. topleft (). Y, m_rect [I]. Width (),

M_rect [I]. Height (), & memdc, 0, 0, srccopy );

Memdc. SelectObject (poldbitmap );

Memdc. deletedc ();

Releasedc (PDC );

3. Button imitation

In the system, considering that all tqshell events are hard-implemented without dynamic effects, there is no loss of system interaction. Therefore, in tqshell, we use double-image switching to simulate button triggering, as shown in Figure 5.41 and figure 5.42.

Figure 5.41 before pressing

Figure 5.42 after pressing

Two events need to be responded to during key-press imitation, one being onlbuttondown and the other being onlbuttonup. When the onlbuttondown event occurs, the image is switched. When the onlbuttonup event occurs, the image is restored. The code is shown in program list 5, program list 5, and program list 57.

Program list 5 LISTEN 56 onlbuttondown event

BMP. loadbitmap (idb_gps_w );

Cbitmap * poldbitmap = memdc. SelectObject (& BMP );

PDC-> bitblt (m_rect [m_prepick]. topleft (). X, m_rect [m_prepick]. topleft (). Y, m_rect [m_prepick]. Width (),

M_rect [m_prepick]. Height (), & memdc, 0, 0, srccopy );

Memdc. SelectObject (poldbitmap );

Program list 5 LISTEN 57 onlbuttonup event

Copybmp (idb_gps_w, 0 );

4. Key-based response

During the design process of the hardware platform, the implementation of key keys is added for convenience of operations, mainly for functions such as upper, lower, and lower pages. Tqshell makes good use of such conditions to increase the system's interactivity. in the implementation process, it responds to key-press events. It is actually very easy to support key keys. You only need to implement the onkeydown event. When implementing the event, note that after the key is pressed, the previous key should be restored, the key-based response function is shown in listing 5, 58.

Program list 5 58 onkeydown event

Void cgpsdlg: onkeydown (uint nchar, uint nrepcnt, uint nflags)

{

M_prepick = m_currentpick;

If (nchar = vk_up | nchar = vk_left)

{

Switch (m_prepick)

{

Case 0:

// GPS black white

Copybmp (idb_gps_ B, 0 );

Copybmp (idb_mp3_w, 1 );

Copybmp (idb_mp4_w, 2 );

Copybmp (idb_picture_w, 3 );

Copybmp (idb_tool_w, 4 );

Copybmp (idb_set_w, 5 );

M_currentpick = 0;

Break;

......

}

}

If (nchar = vk_down | nchar = vk_right)

{

Switch (m_prepick)

{

Case 0:

// MP3 black white

Copybmp (idb_gps_w, 0 );

Copybmp (idb_mp3_ B, 1 );

Copybmp (idb_mp4_w, 2 );

Copybmp (idb_picture_w, 3 );

Copybmp (idb_tool_w, 4 );

Copybmp (idb_set_w, 5 );

M_currentpick = 1;

Break;

......

Default:

Break;

}

}

Cdialog: onkeydown (nchar, nrepcnt, nflags );

}

5. process call

The tqshell interface program is a system integration interface program. To ensure the system can run, tqshell must call the process and call sub-software to run the program, such as GPS navigation and multimedia playback. In MFC, there are many process-called functions, but this system supports the shellexecuteex function. The following describes the shellexecuteex function. Before we introduce shellexecuteex, I will first introduce the structure of shellexecuteinfo [8].

(1) shellexecuteinfo struct

This struct serves as a parameter to assist the call process of the shellexecuteex function and specifies the parameters related to the process to be called. The prototype of this struct is shown in the program list 5, 59;

Program list 5 59 shellexecuteinfo struct

Typedef struct _ shellexecuteinfo {

DWORD cbsize;

Ulong fmask;

Hwnd;

Lpctstr lpverb;

Lptstr lpfile;

Lptstr lpparameters;

Lpctstr lpdirectory;

Int nshow;

Hinstance hinstapp;

Lpvoid lpidlist;

Lpctstr lpclass;

Hkey hkeyclass;

DWORD dwhotkey;

Union {

Handle hicon;

Handle hmonitor;

} Dummyunionname;

Handle hprocess;} shellexecuteinfo, * lpshellexecuteinfo;

During a process call, the parameters in the shellexecuteinfo struct can be set selectively, as described in the following.

L lpdirectory: Optional. Specifies the name of the working directory. If the Member is not described, the current directory is used by default.

L nshow: required. Specifies the display mode of the opened program, which is one of the SW _ values.

L hinstapp: used for output. If see_mask_nocloseprocess S is set and shellexecuteex is called successfully, the value of this item is greater than 32. If the call fails, it is set to the error value of se_err_xxx.

L lpidlist: an address in the itemidlist structure to store the special identifier of a member. This parameter is ignored when fmask does not include see_mask_idlist or see_mask_invokeidlist.

L lpclass: indicates the name or GUID of a file class. This parameter is ignored when fmask does not include see_mask_classname.

L hkeyclass: obtains the handle of the file type registered in the system. This parameter is ignored when fmask does not include see_mask_hotkey.

L dwhotkey: The Hot Key Association of the program, the virtual key code (key code) of the low-level storage, the hotkeyf _) of the High-level storage, and the modifier flags) for a detailed list of wm_sethotkey messages, see the description of the wm_sethotkey message. This item is ignored when fmask does not include see_mask_hotkey.

L hicon: gets the handle of the icon of the corresponding file type. This item is ignored when fmask does not include see_mask_icon.

L hmonitor: handle that displays the document on the monitor. This item is ignored when fmask does not include see_mask_hmonitor.

L hprocess: the handle to the newly started program. If fmask is not set to see_mask_nocloseprocess, the value is null. However, if the program is not started, this value is still null even if fmask is set to see_mask_nocloseprocess.

(2) shellexecuteex Function

The shellexecuteex function takes the shellexecuteinfo struct as the parameter and is used to call the process specified in the shellexecuteinfo struct. The prototype of this function is as follows;

Bool shellexecuteex (lpshellexecuteinfo lpexecinfo );

After learning about the shellexecuteinfo struct and the shellexecuteex function, tqshell calls the shellexecuteex function to implement the process call. The code implementation is actually very simple, as shown in the program list 5-60;

Procedure 5: 60 process calls

TEM = l "// storage card // KLD // navione.exe ";

Exeshell. cbsize = sizeof (shellexecuteinfo );

Exeshell. lpfile = TEM;

Exeshell. hwnd = NULL;

Exeshell. nshow = sw_show;

Shellexecuteex (& exeshell );

Optional topbar =: findwindow (L "hhtaskbar", null );

: Showwindow (export topbar, sw_hide );

6. kernel Loading

After tqshell is compiled, tqshell is obtained. EXE and tqshell. after the Lib file, we need to add the two files to the kernel to start the interface easily at startup. The steps for loading the files to the kernel are as follows;

(1) edit the lnk file

This file is actually a shortcut file. You can click it to directly run the application under the specified directory. The content of this file is 5.43;

Figure 5.43 content of the lnk file

(2) load to the kernel

In Windows CE, to load an application to the kernel, you only need to edit the pratfrom. bib file, as shown in Figure 5.44;

Figure 5.44 export tqsheel.exe to Kernel

(3) run the tqshell.exe program directly after Windows cestarts.

Windows CE supports running the user program directly. The setting is very simple, because after Windows cestarts, The assumer.exe program is started. To replace the program with the specified application, you only need to set the relevant registry, see program list 5, 60;

Procedure 5-61 start the Registry

[HKEY_LOCAL_MACHINE/init]

"Launch50" = "Windows // tqshell. EXE"

"Depend50" = HEX: 14,00, 1e, 00

After Windows CE is started, the tqshell. EXE running interface is much clearer than the original Windows CE interface, as shown in Figure 5.45 and 5.46;

Figure 5.45 Main Interface

Figure 5.46 common tool interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.