Modifying Phone Gap Accelerometer Code to identify when the axis is being tilted

Hi there, I am currently trying to create a phone application, one of the features that I am working on is using the Phone Gap Accelerometer function, and viewing it through Ripple.
Currently I can view the position of the X, Y and Z axis, and they change when you drag the device around, but what I want to do is create an IF statement, that will show what positions the axis has been tilted, and for the text to be displayed on the screen.
<!DOCTYPE html>
<html>
  <head>
    <title>Acceleration Example</title>
    <script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
    <script type="text/javascript" charset="utf-8">
        // The watch id references the current `watchAcceleration`
        var watchID = null;
        // Wait for PhoneGap to load
        document.addEventListener("deviceready", onDeviceReady, false);
        // PhoneGap is ready
        function onDeviceReady() {
            startWatch();
        // Start watching the acceleration
        function startWatch() {
            // Update acceleration every 3 seconds
            var options = { frequency: 3000 };
            watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
        // Stop watching the acceleration
        function stopWatch() {
            if (watchID) {
                navigator.accelerometer.clearWatch(watchID);
                watchID = null;
        // onSuccess: Get a snapshot of the current acceleration
        function onSuccess(acceleration) {
            var element = document.getElementById('accelerometer');
            element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' +
                            'Acceleration Y: ' + acceleration.y + '<br />' +
                            'Acceleration Z: ' + acceleration.z + '<br />' +
                            'Timestamp: ' + acceleration.timestamp + '<br />';
                                                                                                                    <---- I think here is where I need the IF statement!
        // onError: Failed to get the acceleration
        function onError() {
            alert('onError!');
    </script>
  </head>
  <body>
    <div id="accelerometer">Waiting for accelerometer...</div>
    <button onclick="stopWatch();">Stop Watching</button>
  </body>
</html>
Thanks in advance for any help, I am still at a very basic level in terms of creating mobile applications!

You should be able to get some more precise information from your Xorg logs, but I would bet it is related to the evdev driver. Some of the options in your xorg.conf no longer work with the latest version. For now you should be able to either map your mouse directly to the appropriate /dev/event* entry or change to the standard mouse driver, both of those methods should be in the wiki.
You are supposed to be able to use the evdev driver without the input section of your xorg.conf by using dbus/hal autodetection, but AFAIK at the moment the xorg-server package still isn't compiled with hal support, so you would have to patch and rebuild the package.

Similar Messages

  • HT201401 My iPhone3GS has started crashing. I'll be mid-phone call, or using an app, when the screen will go dark. I have to restart it. Then it shows low battery sign (even though it was 100%). Within 1 minute of charging, iphone starts. Pl. resolve.

    My iPhone3GS has started crashing. I'll be mid-phone call, or using an app, when the screen will go dark. I'll have to do a restart. It dumps to the warning screen that there's no power and needs to be plugged in.
    Once I connect the phone to a power source, in a couple of minutes it's ready to roll again, and displaying a "full battery" icon.
    The phone is almost always fully charged when this happens, and I don't get a crash when the phone is plugged into a power source.
    Took my iphone to apple store, they informed that battery is very good and there is no need for replacement. Might be there is a problem with iphone motherboard. But they can't repair it as my 3GS crossed warranty.
    Where should I go to repair this. Within 2 years...this 32GB 3GS is almost garbage for me with no support from apple. I am ready to send it to apple for repairs and pay the repair charges.
    I tried everything... deep reset ... factory settings .... nothing is working... Apple staff pl. take care of your customers ...

    This is a User to User Forum... You are Not Addressing Apple here...
    iPhone User Guide
    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414

  • My i phone 3g turns it self off when the battery power gets to about 50 % is there a few for this?

    My i phone 3g turns it self off when the battery power gets to about 50% is there a fix for this

    This is often due to faulty battery. Make Genius reservation and take iPhone to Apple Store for free quick battery diagnostic testing.

  • HT1414 My i phone 4 is factory unlocked but when the sim card is entered the service provider is not shown

    My i phone 4 is factory unlocked but when the sim card is entered the service provider is not shown

    Hello hskod,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    iOS: Troubleshooting encrypted backups
    http://support.apple.com/kb/TS5162
    You can keep trying to restore the device from backup until you remember the password. If you're having trouble, try:
    Leaving the password field blank
    Your Apple ID password
    Your computer account password, if you have one
    Email passwords you may have used
    Your Wi-Fi network password
    Website passwords you may have used
    A password for hard-disk encryption software, if you use it
    Have a nice day,
    Mario

  • Since I downloaded iOS6.1 I can not hear my messages/phone calls/emails or any sounds when the phone is lock. Any setting I can change?

    Since I downloaded iOS6.1 I can not hear my messages/phone calls/emails or any sounds when the phone is lock. It doesnt connect to bluetooth either. Any setting I have to change?
    My sounds settings are ON and my side mute button is NOT pushed down to orange.
    When the phone is unlock all the sounds are fine, but as soon as it locks it goes dead silent mode!

    http://support.apple.com/kb/TS1630

  • Phone freezes and turn itself off when the "Ph. se...

    I got a Nokia n97 mini 2 weeks ago and the phone works great except that sometimes it would turn itself off and when I turn it back on it lags and freezes. I notice every time the phone freezes and turn itself off when the "Ph. setup" in the App menu is running. Is the device updating itself? How can I make it stop? Everything freezes as soon as the Ph. setup starts running. 
    I try waiting it out (if the phone is setting something up it shouldn't take more than a few minutes) but I leave it there for several hours and it's still frozen.
    Thanks for reading -sorry if my English sucks-

    Fireemt125 wrote:
    Is there a way to turn Siri off when phone is locked
    Settings > General > Passcode Lock.
    FYI: Siri can only do certain things when locked. It will not do anything that requires the iPhone to be unlocked (without first unlocking the iPhone).

  • TS3694 I cant get my ipad 2 out of recovery. The apple icon stays on and nothing happens. I tried restoring it through Itunes but it comes up with a 3194 error code. I have the latest Itunes being 10.6.1.7 and the latest windows update.Can someone please

    I cant get my ipad 2 out of recovery. The apple icon stays on and nothing happens. I tried restoring it through Itunes but it comes up with a 3194 error code. I have the latest Itunes being 10.6.1.7 and the latest windows update.Can someone please help?

    Recovery Mode
    1. Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
    2. Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.
    3.While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
    4. Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears, release the Home button. iTunes should alert you that it has detected a device in recovery mode. Click OK, and then click Restore to restore the device.
    Note: Data will be lost. You may have to repeat the above many times.

  • When the app is being downloaded it doesnt show the icon its like gray icon

    When the app is being downloaded it doesnt show the icon, its like a gray icon that appears... does that happen to anyone?

    Yes - did not used to happen this way, but started after one of the updates. Once the download completes, the 'regular' app icon should show up. Nothing to worry about.

  • Sending IPM attachments to BPM when the instance is being Invoked

    Is it possible to send attched documents in IPM to Oracle business process workspace when the instance is being invoked ? (In 11.1.1.3.0 - PS2). Thanks.

    I don't see any error handing in the Main.VI. Are you performing any error handling that might be able to provide information about communications or update failures?
    Jeff L
    National Instruments

  • SRM PO- BBP_DOC_CHANGE_BADI - Code not effective when the SRM PO is created

    Hi Experts,
    We are using SRM 5.0 Classic and Extended classic scenario and the SRM local PO(Extended classic scenario) is created for special cateogries only. The SRM Local PO is created automatically after the SC is completely approved.
    The SC(one line item) with these special cateogies(chosen from catalogs) do and can have the currency different from the Org stucture currency and hence based on user selection the currency on the Item level(Currency selected in catalog) can be  different from the Item Overview total.
    Now we need to have the SC item level currency at the SRM PO header level which is created from this SC automatically. The code has been written in the BBP_DOC_CHANGE_BADI implementation of method BBP_PO_CHANGE
    With the code implementation, the currency is PO currency is not changed to SC item level currency when the PO is initially created from the SC automatically. However if the same SRM PO is changed and ordered again, the currency gets changed to the SC item level currency in the SRM PO, i.e. executes the BADI code as desired.
    Can anybody guide how can the currency be changed when the PO is first created automatically from the SC ?
    Many thanks in advance.
    Best Regards,
    Khaja.
    Edited by: Moulail Shaik on Dec 28, 2011 3:59 PM

    Soumyaprakash Mishra wrote:
    i thought doc_change would have worked... but anyways, did you try doc_save badi?
    Hi Soumyaprakash,
    Thanks for the reply.
    In the doc_save BADI there are no export parameters which can be modified.
    Neverthless, please suggest if there is an way to change/influence the PO data using the doc_save badi in your view ?
    Many thanks in advance.
    Best Regards,
    Khaja.

  • ALV: OOPS: How to identify when the BACK button is hit?

    Hi All,
    I have a requirement in which when the BACK button on the ALV output is hit, i have to leave to the Original Selection Screen.
    I know that using SET SCREEN 0. this can be done. But i'm unable to find the point at which the Event about the BACK button is triggered.
    How can i identify if the button hit was the back button?
    Thanks in advance,
    Jr.

    Hi Jr,
    u declare sy-ucomm in data decla.
    in code try this out.
    Case sy-ucomm.
    when 'BACK'.
    leave to screen#. " # For the selection screen (i dnt think it is 0).
    u obviously have to set the PF status for the same by SE41 and in Aplication, u give name as BACK for the back symbol.
    I hope is will help.
    Reward if useful
    Thanks
    Sujay

  • Can I stop SMS notification when the iPhone is being used as a phone?

    I love my iPhone, but the one thing that is driving me mad is SMS notifications coming through when I'm talking on the phone - a startling loud alert when the phone is pressed hard against my ear makes me jump every time, and actually hurts a bit too! I don't want to have my SMS alerts as silent, I'd just like the phone to realise that shouting 'PING!' in my ear when I'm on the phone is not good for my hearing or nerves!

  • My phone won't use IMessage even when the person I'm txting has an iPhone why?

    Why won't my phone use iMessage even when the person in txting has an iphone

    I'm having same problem with sending to 3 people from a particular WiFi Network. For two people the iMessage i write is sending, but stops just before Delivery and then says not delivered. For the third person it immediately sends as text message.
    Answered to questions above.
    Can I send to others... Intermittent. Usually no, but then at some point a lot of iMessages comes at once.
    Settings have been enabled.
    Also other persons settings/Messages are enabling iMessage.
    Enabled for WiFi + non roaming cellular ( at my end it should mean only wifi as I am in roaming area with wifi available).
    Numbers are all enabled as we have used them a lot of times, an no changes or upgrades this month.
    So: it seems to me to be a WiFi issue here, but the odd thing is that it sometimes lets iMessages through.
    e-mail and browsing works fine.
    Any suggestions?

  • Will iMessage say delivered when the message is being sent to a dead device

    My iPad was dead and someone messaged me and it said delivered, is it normal to say delivered even when the device it's sent to is dead?

    This exact thing also happened to me.  Additionally when other iMessage users responded to me, they also got a Not Delivered message even though I did receive it. 
    I tried resetting Network settings, turning iMessage on and off, restarting, etc.
    Finally this morning I went all out.  I made sure I was backed up to iCloud and then did a full reset and erased all data.  I restored from an iCloud backup and now things are working. 
    There was a little glitch at first, although it may have been user error.  I have two iPhones - personal and corporate and I sync my iMessages between them.  (Personal is the one with the problems that I reset.)   I found that in my iMessage settings (under Send & Receive Addresses), my personal phone wasn't selected after the restore, and it wasn't using it as the source for sending a new message.  I had to put a checkmark back in front of the personal phone number and select it as the new message number.  It's possible I messed up when setting up the phone, but I didn't think so. 
    Anyway, I have done multiple tests and my iMessages are now all sending correctly and seem to be working.
    Hope that helps someone.  I've found a few reports of this since the 7.0.3 upgrade rolled out, but nothing with a fix.  May not work for everyone, but it may be worth a shot.
    Janice

  • Sending an email when the report is being refreshed

    Hi All,
    Is it possible, in Answers, to send an email automatically when a report is being refreshed ?
    Thanks in advance,
    Lau

    You can do this multiple ways, As you mentioned using conditional ibot also. You should have flag or indicator in your database saying that ETL load was done. Then based on conditional request run a ibot. But the trick is after completing this ibot you need to turn of the flag.
    Other easiest way is Create a report which runs ibot, Make sure you checked Oracle BI Server Cache feed check box, save the ibot. At the end of ETL execute a command which runs the ibot job for you. There is a command mode application available in Oracle BI called SASchInvoke.exe. This application will run the ibot for you.
    here is the blog which explains more about it.
    http://oraclebizint.wordpress.com/2008/03/06/oracle-bi-ee-101332-integrating-schedulerdelivers-into-other-applications/
    - Madan

Maybe you are looking for

  • How do I transfer itunes library to new hard drive running lion os

    I have a Mac Pro with 2 hard drives in it. Hard drive #1 has Leopard OS and my iTunes library on it Hard drive #2 has Lion 10.7.4 OS and this is where I want to move my iTunes library to from hard drive #1. How can I due this insuring that all playli

  • Opening a PDF file in 100% view.

    I need to know how to change the view when opening up a PDF file.  Everytime I open a file it opens in 200% view. How do I get them to always open in 100% view?

  • Error about HKEY_LOCAL_MACHINE when trying to install QuickTime 7.2

    This is the error I receive when trying to install Quicktime: "Could not open key: HKEYLOCALMACHINE|Software|Classes|QuickTimePlayerLib.QuickTimePlayerApp|CLSID. Verify that you have access to that key." I have manually edited the Regedit permissions

  • How to change the order of fields when exported to csv

    I am using LiveCycle Designer 8 and have created a great form with the correct tab order. However, when the form is filled in and returned to me, the fields in the CSV file are all over the place. How can I make sure the fields in the CSV file are di

  • Error: "AppleMobileDeviceHelper has stopped working"

    I repeatedly get this error anytime I leave iTunes opened for more than 30 seconds (if that) and it will not quit, I've uninstalled and reinstalled iTunes, as well as trying the repair function... I've tried the uninstall and reinstall from both the