User Tools

Site Tools


built_in:sensors

Differences

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

Link to this comparison view

built_in:sensors [2015/01/07 09:55]
octazid [Methods]
built_in:sensors [2018/01/03 10:23]
Line 1: Line 1:
-====== Sensor control ====== 
-===== Create ===== 
-Create Sensor objects using the CreateSensor function of the app object: 
-<code>sns = app.CreateSensor( type, options );</code> 
-Types available are: "Accelerometer", "MagneticField", "Orientation", "Light" and "Proximity". 
  
-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 ===== 
-Some controls use the same methods.\\ 
-For examples of the **[[same methods]]** look here. 
-^Method ^Description ^ 
-|Sensor.Destroy() | | 
-|Sensor.GetAbsHeight() | | 
-|Sensor.GetAbsWidth() | | 
-|Sensor.GetAzimuth() | | 
-|Sensor.GetHeight() | | 
-|Sensor.GetPitch() | | 
-|Sensor.GetPosition() | | 
-|Sensor.GetRoll() | | 
-|Sensor.GetType() | | 
-|Sensor.GetVisibility() | | 
-|Sensor.GetWidth() | | 
-|Sensor.Release() | | 
-|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 ===== 
-^Sensor Type ^Code Example ^ 
-|Accelerometer | <code>function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
- 
-  txt = app.CreateText( "", 0.8, 0.3, "Multiline" ); 
-  lay.AddChild( txt ); 
-  app.AddLayout( lay ); 
- 
-  sns = app.CreateSensor( "Accelerometer" ); 
-  sns.SetOnChange( sns_OnChange ); 
-  sns.Start(); 
- 
-} 
- 
-function sns_OnChange( x, y, z, time ) 
-{ 
-  txt.SetText( "x="+x + "\n y="+y + "\n z="+z ); 
-</code> | 
-|Orientation | <code>function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
- 
-  txt = app.CreateText( "", 0.8, 0.3, "Multiline" ); 
-  lay.AddChild( txt ); 
-  app.AddLayout( lay ); 
- 
-  sns = app.CreateSensor( "Orientation" ); 
-  sns.SetOnChange( sns_OnChange ); 
-  sns.Start(); 
- 
-} 
- 
-function sns_OnChange( azimuth, pitch, roll, time ) 
-{ 
-  var msg = " azimuth = " + azimuth.toFixed(1); 
-  msg += "\n pitch = " + pitch.toFixed(1); 
-  msg += "\n roll = " + roll.toFixed(1); 
-  txt.SetText( msg ); 
-} 
-</code> | 
-|Light | <code>function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
- 
-  txt = app.CreateText( "", 0.8, 0.3 ); 
-  lay.AddChild( txt ); 
-  app.AddLayout( lay ); 
- 
-  sns = app.CreateSensor( "Light" ); 
-  sns.SetOnChange( sns_OnChange ); 
-  sns.Start(); 
- 
-} 
- 
-function sns_OnChange( lux ) 
-{ 
-  txt.SetText( "level = " + lux + " lux" ); 
-} 
- 
-</code> | 
built_in/sensors.txt ยท Last modified: 2018/01/03 10:23 (external edit)