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
built_in:sensors [2015/01/07 09:55]
octazid [Methods]
built_in:sensors [2018/01/03 10:23] (current)
Line 1: Line 1:
-====== Sensor control ====== +====== Sensors ====== 
-===== Create ===== + 
-Create Sensor objects using the CreateSensor function of the app object:+//(Information and examples taken from the DroidScript documentation). Information provided by Nick Weber// 
 + 
 +===== Description ===== 
 +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: "Accelerometer", "MagneticField", "Orientation""Lightand "Proximity".+Types available are:  
 +  * **Accelerometer** 
 +  * **MagneticField** 
 +  * **Orientation** 
 +  * **Light** 
 +  * **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. 
 + 
 +Change the rate that a sensor checks for changes by adding one the options **"Fastest"****"Fast"****"Medium"** or **"Slow"**. 
 +"Slowis the default.
  
-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. 
  
-Change the rate that a sensor checks for changes by adding one the options "Fastest", "Fast", "Medium" or "Slow". "Slow" is the default. 
 ===== Methods ===== ===== Methods =====
 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.GetAbsHeight() | | +| Sensor.GetHeight()                                                       
-|Sensor.GetAbsWidth() | | +| Sensor.GetNames()               returns a list of all available sensors  
-|Sensor.GetAzimuth() | | +| Sensor.GetPitch()                                                        
-|Sensor.GetHeight() | | +| Sensor.GetRoll()                                                         
-|Sensor.GetPitch() | | +| Sensor.GetType()                                                         
-|Sensor.GetPosition() | | +| Sensor.GetValues()                                                       
-|Sensor.GetRoll() | | +| Sensor.SetMaxRaterate       default 20ms                             
-|Sensor.GetType() | | +| Sensor.SetMinChange( value    a value between 0 and 1                  
-|Sensor.GetVisibility() | | +| Sensor.SetOnChange( callback                                           
-|Sensor.GetWidth() | +| Sensor.Start()                                                           
-|Sensor.Release() | | +| Sensor.Stop()                                                            |
-|Sensor.SetBackColor( p1 ) | | +
-|Sensor.SetBackGradient( p1,p2,p3,p4,p5,p6,p7 ) | | +
-|Sensor.SetBackGradientRadial( p1,p2,p3,p4,p5,p6,p7 ) | | +
-|Sensor.SetBackground( p1,p2 ) | | +
-|Sensor.SetMargins( left,top,right,bottom ) | +
-|Sensor.SetMinChange( p1 ) | | +
-|Sensor.SetOnChange( p1 ) | | +
-|Sensor.SetPadding( p1,p2,p3,p4 ) | | +
-|Sensor.SetPosition( p1,p2,p3,p4 ) | | +
-|Sensor.SetScale( x,y ) | | +
-|Sensor.SetSize( p1,p2 ) | | +
-|Sensor.SetVisibility( p1 ) | | +
-|Sensor.Start() | | +
-|Sensor.Stop() | |+
  
 ===== Examples ===== ===== Examples =====
 ^Sensor Type ^Code Example ^ ^Sensor Type ^Code Example ^
-|Accelerometer | <code>function OnStart()+|Accelerometer | <code javascript>function OnStart()
 { {
   lay = app.CreateLayout( "Linear", "VCenter,FillXY" );   lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
Line 58: 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>function OnStart()+|Orientation | <code javascript>function OnStart()
 { {
   lay = app.CreateLayout( "Linear", "VCenter,FillXY" );   lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
Line 81: Line 96:
 } }
 </code> | </code> |
-|Light | <code>function OnStart()+|Light | <code javascript>function OnStart()
 { {
   lay = app.CreateLayout( "Linear", "VCenter,FillXY" );   lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
built_in/sensors.1420624520.txt.gz · Last modified: 2015/01/07 17:55 (external edit)