created some new functions to enale GPS/Accel value polling. GPS wise demo2 was changed so that we can do both change GPS in non gps suported cases and in GPS supported cases red Gps via polling

This commit is contained in:
Fred Grott 2009-01-19 06:59:54 -06:00 committed by fredgrott
parent bcb7805006
commit 88b71cf553
2 changed files with 74 additions and 12 deletions

View File

@ -96,7 +96,11 @@ var Device = {
FNUUID: "", FNUUID: "",
FNGapVersion: "", FNGapVersion: "",
myLat: "",
myLon: "",
myGPSInterval: "30000",
myAccelInterval: "30000",

View File

@ -47,15 +47,35 @@ updateSettings = function() {
updateLocation = function(lat, lon) { updateLocation = function(lat, lon) {
// updateLocatin based on user input // updateLocatin based on user input
// $('lat') is already the dom object
// thus we need to
// associate with a Device.Location.lat var
$('lat').value = document.getElementById('lat').value;
$('lon').value = document.getElementById('lon').value;
Device.myLat = document.getElementById('lat').value;
Device.myLon = document.getElementById('lon').value;
}
readLocation = function() {
$('lat').value = lat; //assume that Device.Location.set ran once and thus
$('lon').value = lon; // Device.Location.lat and Device>location.lon are set
Device.Location.init();
$('userlat').value = Device.Location.lat;
$('userlon').value = Device.Location.lon;
//we need to poll but have poll of functions run more than once during specified interval
setInterval('readLocation()', Device.myGPSInterval);
} }
userSetIntervals = function() {
//allow user to set intervals for gps and accel polling
//otherwise mad user to do to excessive polling of GPS values and etc
//which reduces battery power
$('usersgpsInterval').value = document.getElementById('usergpsInterval').value;
Device.myGPSInterval = document.getElementById('usergpsInterval').value;
$('useraccelInterval').value = document.getElementById('useraccelInterval').value;
Device.myAccelInterval = document.getElementById('useraccelInterval').value;
}
updateAccel = function(){ updateAccel = function(){
$('accelx').value = accelX; $('accelx').value = accelX;
@ -77,7 +97,9 @@ addLoadEvent(initGap);
<ul id="home" title="Main" selected="true"> <ul id="home" title="Main" selected="true">
<li><a href="#system" onclick="updateSettings();return false;">System...</a></li> <li><a href="#system" onclick="updateSettings();return false;">System...</a></li>
<li><a href="#geo" onclick="">Geo-Location...</a></li> <li><a href="#geo" onclick="">Change Location...</a></li>
<li><a href="#readgeo" onclick="readLocation();">Read Location...</a></li>
<li><a href="#setintervals" onclick="">Set user Intervals...</a></li>
<!-- <li><a href="#geo" onclick="updateLocation();">Geo-Location...</a></li> --> <!-- <li><a href="#geo" onclick="updateLocation();">Geo-Location...</a></li> -->
<li><a href="#accel" onclick="updateAccel();">Accelerometer...</a></li> <li><a href="#accel" onclick="updateAccel();">Accelerometer...</a></li>
<li><a href="#vibration" onclick="Device.vibrate();">Vibration</a></li> <li><a href="#vibration" onclick="Device.vibrate();">Vibration</a></li>
@ -123,7 +145,7 @@ addLoadEvent(initGap);
<div id="geo" title="Geo Location" class="panel" > <div id="geo" title="Geo Location" class="panel" >
<h2>Location</h2> <h2>Change Location</h2>
<fieldset> <fieldset>
<div class="row"> <div class="row">
<label>Lat</label> <label>Lat</label>
@ -134,12 +156,48 @@ addLoadEvent(initGap);
<input name="lon" id="lon" value="000.000" type="text"/> <input name="lon" id="lon" value="000.000" type="text"/>
</div> </div>
<div class="row"> <div class="row">
<a class="button blueButton" type="submit" onclick="updateLocation(lat, lon);">Update Location</a> <a class="button blueButton" type="submit" onclick="updateLocation();">Update Location</a>
</div>
</fieldset>
</div>
<div id="readgeo" title="Read Location" class="panel" >
<h2>Read Location</h2>
<fieldset>
<div class="row">
<label>Lat</label>
<input disabled="enabled" name="lat" id="userlat" value="" type="text"/>
</div>
<div class="row">
<label>Lon</label>
<input disabled="enable" name="lon" id="userlon" value="" type="text"/>
</div> </div>
</fieldset> </fieldset>
</div> </div>
<div id="setintervals" title="Set Intervals" class="panel" >
<h2>Change Intervals</h2>
<fieldset>
<div class="row">
<label>GPS </label>
<input name="lat" id="lat" value="60000" type="text"/>
</div>
<div class="row">
<label>Accel</label>
<input name="lon" id="lon" value="60000" type="text"/>
</div>
<div class="row">
<a class="button blueButton" type="submit" onclick="userSetIntervals();">Set Intervals</a>
</div>
</fieldset>
</div>
<div id="accel" title="Accelerometer" class="panel"> <div id="accel" title="Accelerometer" class="panel">