@@ -35,26 +35,27 @@ <h1>devicemotion</h1>
3535
3636< script >
3737 const warn = ( ...x ) => document . getElementById ( "warn" ) . innerHTML = x
38- const startSensors = async ( addDatapoint ) => {
38+ const startSensors = async ( addDataPoint ) => {
3939 function handleMotionEvent ( event ) {
4040 const x = event . accelerationIncludingGravity . x ;
4141 const y = event . accelerationIncludingGravity . y ;
4242 const z = event . accelerationIncludingGravity . z ;
4343 const alpha = event . rotationRate . alpha ;
44+ const time = Math . floor ( event . timeStamp + performance . timeOrigin ) ;
4445
45- addDatapoint ( 'x' , x )
46- addDatapoint ( 'y' , y )
47- addDatapoint ( 'z' , z )
48- addDatapoint ( 'alpha' , alpha )
46+ addDataPoint ( time , 'x' , x )
47+ addDataPoint ( time , 'y' , y )
48+ addDataPoint ( time , 'z' , z )
49+ addDataPoint ( time , 'alpha' , alpha )
4950 }
5051
5152 window . addEventListener ( "devicemotion" , handleMotionEvent , true ) ;
5253 }
5354</ script >
5455
5556< script >
56- const addDatapoint = ( ...x ) => {
57- p . addDatapoint ( ...x )
57+ const addDataPoint = ( ...x ) => {
58+ p . addDataPoint ( ...x )
5859 document . getElementById ( "numberadded" ) . innerHTML = parseInt ( document . getElementById ( "numberadded" ) . innerHTML ) + 1
5960 }
6061
@@ -63,7 +64,7 @@ <h1>devicemotion</h1>
6364 }
6465
6566 document . getElementById ( "startsense" ) . onclick = ( ) => {
66- startSensors ( addDatapoint )
67+ startSensors ( addDataPoint )
6768 }
6869
6970 document . getElementById ( "predict" ) . onclick = ( ) => {
@@ -80,4 +81,4 @@ <h1>devicemotion</h1>
8081</ script >
8182
8283</ body >
83- </ html >
84+ </ html >
0 commit comments