User Tools

Site Tools


built_in:sensors

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
built_in:sensors [2015/03/08 09:30]
octazid completed
built_in:sensors [2015/12/23 15:54]
193.81.107.52 Close function bracket
Line 4: Line 4:
  
 ===== Description ===== ===== Description =====
-Create Sensor objects using the **CreateSensor** function of the [[built_in:app|app]] object:+Create Sensor objects using the **CreateSensor** function of the **[[built_in:app|app]]** object:
 <code>sns = app.CreateSensor( type, options );</code> <code>sns = app.CreateSensor( type, options );</code>
 Types available are:  Types available are: 
-  * **"Accelerometer"** +  * **Accelerometer** 
-  * **"MagneticField"** +  * **MagneticField** 
-  * **"Orientation"** +  * **Orientation** 
-  * **"Light"** +  * **Light** 
-  * **"Proximity"**+  * **Proximity** 
 +  * **Temperature** 
 +  * **GameRotation** 
 +  * **GeomagneticRotation** 
 +  * **Gravity** 
 +  * **Gyroscope** 
 +  * **HeartRate** 
 +  * **Acceleration** 
 +  * **Pressure** 
 +  * **Humidity** 
 +  * **Rotation** 
 +  * **Motion** 
 +  * **StepCounter** 
 +  * **StepDetector** 
 + 
 +Try **sns.GetNames()** which lists all the sensor information. You can probably scan for certain keywords. 
 + 
 +You can also use a sensor id number instead of the name (just in case a future sensor is added).
  
 You can use the **SetOnChange** function of the Sensor to set the name of a function you want to be called when a the changes occur. You can use the **SetOnChange** function of the Sensor to set the name of a function you want to be called when a the changes occur.
Line 22: Line 39:
 Some controls use the same methods.\\ Some controls use the same methods.\\
 For examples of the **[[same methods]]** look here. For examples of the **[[same methods]]** look here.
-^Method ^Description ^ +^ Method                          ^ Description                              
-|Sensor.Destroy() | | +| Sensor.GetAzimuth()                                                      
-|Sensor.GetAzimuth() | | +| Sensor.GetHeight()                                                       
-|Sensor.GetHeight() | | +| Sensor.GetNames()               returns a list of all available sensors  
-|Sensor.GetPitch() | | +| Sensor.GetPitch()                                                        
-|Sensor.GetRoll() | | +| Sensor.GetRoll()                                                         
-|Sensor.GetType() | | +| Sensor.GetType()                                                         | 
-|Sensor.SetMinChange( value ) | a value between 0 and 1| +| Sensor.GetValues()              |                                          | 
-|Sensor.SetOnChange( callback ) | | +| Sensor.SetMaxRate( rate )       default 20ms                             
-|Sensor.Start() | | +| Sensor.SetMinChange( value )    | a value between 0 and 1                  
-|Sensor.Stop() | |+| Sensor.SetOnChange( callback )                                           
 +| Sensor.Start()                                                           
 +| Sensor.Stop()                                                            |
  
 ===== Examples ===== ===== Examples =====
Line 53: Line 72:
 { {
   txt.SetText( "x="+x + "\n y="+y + "\n z="+z );   txt.SetText( "x="+x + "\n y="+y + "\n z="+z );
 +}
 </code> | </code> |
 |Orientation | <code javascript>function OnStart() |Orientation | <code javascript>function OnStart()
built_in/sensors.txt · Last modified: 2018/01/03 10:23 (external edit)