Windows Phone mango development practices-shake library application instance

Source: Internet
Author: User

Windows Phone mango development practices-shake library application instance

Explore the shake Mars of Mars

 

Directory

Overview-New Field 1

Microsoft's "Dallas" 2

A Preliminary Exploration of Dallas-exploring the shake Mars 2 of Mars

Gravity acceleration sensing 3

How shake library implements shaking detection 3

Shake Library call usage 4

Shake library Configuration Parameter 5

 

Overview-creating new fields

Zhou Yi: "Yun lei, tun. The gentleman goes through the wheel. "It means that the dark clouds are surging and the thunder is moving, indicating the hard time of the startup of the business. The gentleman shall shoulder the moral burden and take the righteousness of the world. Competition in the mobile Internet age is a battle of the ecosystem and a test of the ability to integrate resources. As the commanding heights of mobile Internet competition, the smart terminal operating system is fully established.Already formedAt this time, it was the time when the mountains and rain were surging, and it was the beginning of the hero's career.

Microsoft's Dallas"

Windows Phone mango development practicesProgram-- Exploring Mars is a very interesting application. The Mars exploration application communicates with Dallas on the Windows azure platform to present the National Aeronautics and Space Administration (NASA) images taken by the Mars probe operation provided.

Microsoft's "Dallas" is an information service built by Windows azure and SQL azure. It enables developers and information workers to use high-quality third-party data sets and content on any platform. After my publication of Windows Phone mango development practices, the Dallas Project (now windows azure marketplace) was upgraded recently.

Unfortunately, images of the Mars probe operation provided by NASA are not found in the new windows azure marketplace. Fortunately, the original NASA Mars service of Windows azure Marketplace also exists, that is to say, the application to explore Mars can still run normally. In this way, the account key of Suo Mars has become a scarce resource out of print. If you have not run the account key for exploring Mars, as long as you are a reader of Windows Phone mango development practices or a developer who prefers to explore Mars applications, I would like to share with you my Windows Live ID and account key on the premise that it is only for technical research. You can leave a message in the blog or Sina Weibo (http://weibo.com/highcedar) private message to inform you of the email, I will send the account key to your mailbox.

The gravity sensor detection function is added to the new exploration Mars application. When you shake your phone gently, the application automatically switches the picture. If you shake the phone continuously, the effect is the animation of the lunar rover collecting samples on Mars.

Explore the Mars app, known as shake Mars, supports gravity sensing to detect mobile phone shaking and finger touch switching pictures, deep links in Windows Phone marketplace for http://www.windowsphone.com/en-US/apps/12bee48c-dee1-4cfb-b04e-135eb4e69b68.

Explore Mars and shake Library source code and documentation: https://skydrive.live.com/redir.aspx? Cid = 6cf62487c100b43d & resid = 6cf62487c100b43d! 508. Ask me for the Windows Live ID and account key before running. This method is not convenient because it may involve the privacy of the account key. I would like to reiterate my willingness to share with you my Windows Live ID and account key on the premise that it is only used for technical research. You can leave a message in the blog or Sina Weibo (http://weibo.com/highcedar) private message to inform you of the email, I will send the account key to your mailbox.

A Preliminary Exploration of Dallas-exploring the shake Mars of Mars

The part for creating applications and communicating with Windows azure marketplace is described in chapter 2 of Windows Phone mango development practices. This article focuses on how to implement gravity sensing detection and shaking.

Gravity acceleration sensing

The readingchanged event that handles changes in gravity acceleration is accelerometerreadingeventargs. The content value of its X, Y, and Z attributes indicates the acceleration direction of the smartphone on the X, Y, and Z axes, instead of the coordinates of three-dimensional space, the unit is the gravity unit, that is, G (1g = 9.81 m/s2 ). In addition to the X, Y, and Z attributes, there is also an attribute named timestamp, which records the time point at which the gravity acceleration reads data.

Note that when the smart phone is placed on a flat desktop and facing up on the front, the content value of the z field in the accelerometerreadingeventargs category is-1.0, indicating that the Z bearing is subject to the gravity of-1g, when the smart phone is placed on a flat desktop and faces down, the content value of the z field in the accelerometerreadingeventargs category is + 1.0, indicating that the Z bearing is subject to the gravity of 1g. The following figure shows the corresponding values:

Figure1Map of gravity acceleration values

How shake library implements shaking Detection

Shake library AccelerationThe sensor detects the movement of the mobile phone in 3D space:

    • Left-right (X direction)
    • Top-bottom (Y direction) top bottom (Y direction)
    • Forward-backward (z direction)

When you move the phone in 3D space, the app gets a lot of reading (the sensor is quite noisy ), the actual data obtained is a change of relative gravity on the mobile phone within a specific period of time.

With this in mind, the high-performance shake library processes data according to the following shaking gesture detection process:

    • Noise Reduction
    • It is divided into "Shake shake" and "Keep still" signal segments.
    • Shake direction Classification

The sensor readings of the application get three axes (x, y, and z values ). To ensure that the detected motion is indeed the shaking of the mobile phone, rather than just a random movement in one direction, we need to count the movements at multiple intervals. More importantly, changes in the vector direction.

For example, if we find that the main direction of our shaking signal is X, we will check the vector values of all x axes in the signal.

In, we see a real shaking state, we can clearly see that the Z axis is the main direction of the shaking, the gravity acceleration value is converted back and forth in the positive and negative directions of the Z axis.

Figure 2 shaking in the Z axis

If you are interested in the shake library, you can obtain the shake library on the app hub.CodeWindows Phone shake gesture library recipe page on apphub.

Shake Library call usage

Step 1:Add reference shake gesture LibraryShakegestures. dll

Step 2:AddUsingStatement File Header

UsingShakegestures;

 

Step 3 of event:RegisterShakegestureEvent, set parameters, and start mobile phone shaking Detection

// Register shake event

Shakegestureshelper. Instance. shakegesture + =New Eventhandler<Shakegestureeventargs> (Instance_shakegesture );

 

// Optional, set parameters

Shakegestureshelper. Instance. minimumrequiredmovesforshake = 2;

 

// Start shake Detection

Shakegestureshelper. Instance. Active =True;

 

Step 4: shakegestureEvent Handler,

 

When mobile phone shaking is detected in the exploration of Mars application, communicate with Windows azure marketplace to obtain the next exploration of Mars image.

Private VoidInstance_shakegesture (ObjectSender,ShakegestureeventargsE)

{

// _ Lastupdatetime. Dispatcher. begininvoke (

// () =>

//{

// _ Lastupdatetime. Text = datetime. Now. tostring ();

// Currentshaketype = E. shaketype;

//});

Deployment. Current. Dispatcher. begininvoke (Delegate{Getnextimage ();});

}

 

ShakegestureeventargsThe attribute holding the shaketype shaking posture direction, used for identification.

 

Shake library configuration parameters

These parameters control various aspects of the gesture detection algorithm. by changing these parameters, you can change your application's sensitivity to shakes and to the duration of a shake. by changing these parameters, you can change the sensitivity of your application and the duration of shaking. The following section describes the available parameters. The following section describes available parameters.

Shakemagnitudewithoutgravitationthreshold

Description: Any vector that has a magncing (after loading gravitation force) bigger than this parameter value is considered as a shake vector.

Default Value0.2

Stillcounterthreshold

Description: This parameter determines how many consecutive still vectors are required to stop a shake signal.

Default Value: 20 (about 400 msec)

Stillmagnitudewithoutgravitationthreshold

Description: This parameter determines the maximum allowed magnation (after clustering gravitation) for a still vector to be considered.

Default Value0.02

Maximumstillvectorsneededforaverage

Description: The maximum number of still vectors needed to create a still vector average. Instead of averaging the entire still signal, we just look at the top recent still vectors. This is already med as runtime optimization.

Default Value: 20

Minimumstillvectorsneededforaverage

Description: The minimum number of still vectors needed to create a still vector average. Without enough vectors, the average won't be stable and thus will be ignored.

Default Value: 5

Minimumshakevectorsneededforshake

Description: Determines the number of shake vectors needed in order to recognize a shake.

Default Value: 10

Weakmagnitudewithoutgravitationthreshold

Description: Shake vectors with a magn1_lower than this parameter won't be considered for gesture classification.

Default Value0.2

Minimumrequiredmovesforshake

Description: Determines the number of moves required to get a shake signal.

Default Value: 3

 

Windows Phone mango development practices

Windows Phone mango development practice

Author: Cedar

Related Article

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.