From Clomosy Docs
(Created page with "In Clomosy, a sensor is used in the context of mobile application development to detect the orientation of the device. The 'FormOrientationSensorType' property determines which type of sensor the mobile form will use to track the device's orientation. For example, if the 'FormOrientationSensorType' property is set to "ostTilt," it will track the tilt of the device. This property allows applications to track the position of the device, enabling operations like screen ro...") |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (13 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
In Clomosy, a sensor is used in the context of mobile application development to detect the orientation of the device. The 'FormOrientationSensorType' property determines which type of sensor the mobile form will use to track the device's orientation. | In Clomosy, a sensor is used in the context of mobile application development to detect the orientation of the device. The 'FormOrientationSensorType' property determines which type of sensor the mobile form will use to track the device's orientation.<br> | ||
For example, if the 'FormOrientationSensorType' property is set to "ostTilt," it will track the tilt of the device. | For example, if the 'FormOrientationSensorType' property is set to "ostTilt," it will track the tilt of the device.<br> | ||
This property allows applications to track the position of the device, enabling operations like screen rotation. This is particularly important for games, map applications, and other mobile applications.<br> | |||
<div class="table-responsive"> | |||
{| class="wikitable" style="border: 2px solid #c3d7e0" | {| class="wikitable" style="border: 2px solid #c3d7e0" | ||
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition | ! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition | ||
|- | |- | ||
| FormOrientationSensorType || MyForm.FormOrientationSensorType | | FormOrientationSensorType || MyForm.FormOrientationSensorType = ostTilt; ||It determines which type of sensor will be used to track the device's orientation. | ||
|- | |- | ||
|ostTilt || MyForm.FormOrientationSensorType | |ostTilt || MyForm.FormOrientationSensorType = ostTilt; || Specifies the amount the device tilts around an axis. | ||
|- | |- | ||
|ostHeading || MyForm.FormOrientationSensorType | |ostHeading || MyForm.FormOrientationSensorType = ostHeading; || Specifies the angle of the device towards north. | ||
|- | |- | ||
|Active || MyForm.FormOrientationSensor.Active | |Active || MyForm.FormOrientationSensor.Active = True; || Sensor usage is activated. | ||
|} | |} | ||
</div> | |||
<h2> Compass Sensor (ostHeading) </h2> | |||
"ostHeading" stands for "Orientation Sensor Heading." This term specifies the direction a device is facing. It indicates which way the device is oriented. | "ostHeading" stands for "Orientation Sensor Heading." This term specifies the direction a device is facing. It indicates which way the device is oriented.<br> | ||
For example, in a compass application, the ostHeading value may represent the angle at which the device is pointing towards the north direction. This indicates how much the device has turned relative to the north. | For example, in a compass application, the ostHeading value may represent the angle at which the device is pointing towards the north direction. This indicates how much the device has turned relative to the north.<br> | ||
In summary, ostHeading provides information about the device's orientation and which direction it is facing. This is particularly useful for applications that need to track the device's heading, such as compass or navigation applications. | In summary, ostHeading provides information about the device's orientation and which direction it is facing. This is particularly useful for applications that need to track the device's heading, such as compass or navigation applications.<br> | ||
You should write the following commands to obtain the X, Y, and Z position sensors. | You should write the following commands to obtain the X, Y, and Z position sensors.<br> | ||
<div class="alert alert-secondary" role="alert" data-bs-theme="light"> | |||
(currentXHeading, currentYHeading, currentZHeading : Double) | |||
</div> | |||
<b> Use of:</b><br> | |||
<pre> | |||
currentXHeading = MyForm.FormOrientationSensor.Sensor.HeadingX; | |||
currentYHeading = MyForm.FormOrientationSensor.Sensor.HeadingY; | |||
currentZHeading = MyForm.FormOrientationSensor.Sensor.HeadingZ; | |||
</pre> | |||
<b>Example</b><br> | |||
<pre> | |||
var | |||
MyForm: TCLForm; | MyForm: TCLForm; | ||
CompassImg,DirectionImg: TClProImage; | CompassImg,DirectionImg: TClProImage; | ||
GetTimer: TClTimer; | GetTimer: TClTimer; | ||
CompassXLabel,CompassYLabel,CompassZLabel : TclLabel; | CompassXLabel,CompassYLabel,CompassZLabel : TclLabel; | ||
void GetCompass; | |||
var | |||
currentYHeading,currentXHeading,currentZHeading: Double; | currentYHeading,currentXHeading,currentZHeading: Double; | ||
rotationAngle: Double; | rotationAngle: Double; | ||
{ | |||
if MyForm.FormOrientationSensor.Sensor | if (not MyForm.FormOrientationSensor.Sensor == nil) | ||
{ | |||
currentYHeading = MyForm.FormOrientationSensor.Sensor.HeadingY; | |||
currentXHeading = MyForm.FormOrientationSensor.Sensor.HeadingX; | |||
currentZHeading = MyForm.FormOrientationSensor.Sensor.HeadingZ; | |||
CompassXLabel.Text = 'X : '+FloatToStr(Abs(currentXHeading)); | |||
CompassYLabel.Text = 'Y : '+FloatToStr(Abs(currentYHeading)); | |||
CompassZLabel.Text = 'Z : '+FloatToStr(Abs(currentZHeading)); | |||
} | |||
CompassImg.RotationAngle = currentYHeading; | |||
} | |||
CompassImg.RotationAngle | |||
{ | |||
MyForm = TCLForm.Create(Self); | |||
MyForm.SetFormBGImage('https://clomosy.com/demos/compassbg.png'); | |||
MyForm | CompassXLabel = MyForm.AddNewLabel(MyForm,'CompassXLabel','--'); | ||
CompassXLabel.Align = alBottom; | |||
CompassXLabel.Margins.Bottom= 30; | |||
CompassXLabel | CompassXLabel.Height = 50; | ||
CompassXLabel.Align | CompassXLabel.Width = 150; | ||
CompassXLabel.Margins.Bottom | |||
CompassXLabel.Height | CompassYLabel = MyForm.AddNewLabel(MyForm,'CompassYLabel','--'); | ||
CompassXLabel.Width | CompassYLabel.Align = alBottom; | ||
CompassYLabel.Margins.Bottom= 20; | |||
CompassYLabel | CompassYLabel.Height = 50; | ||
CompassYLabel.Align | CompassYLabel.Width = 150; | ||
CompassYLabel.Margins.Bottom | |||
CompassYLabel.Height | CompassZLabel = MyForm.AddNewLabel(MyForm,'CompassZLabel','--'); | ||
CompassYLabel.Width | CompassZLabel.Align = alBottom; | ||
CompassZLabel.Margins.Bottom= 10; | |||
CompassZLabel | CompassZLabel.Height = 50; | ||
CompassZLabel.Align | CompassZLabel.Width = 150; | ||
CompassZLabel.Margins.Bottom | |||
CompassZLabel.Height | CompassImg = MyForm.AddNewProImage(MyForm,'CompassImg'); | ||
CompassZLabel.Width | CompassImg.Align = AlCenter; | ||
CompassImg.Height = 350; | |||
CompassImg | CompassImg.Width = 350; | ||
CompassImg.clProSettings.PictureSource = 'https://clomosy.com/demos/compass2.png'; | |||
CompassImg.clProSettings.PictureAutoFit = True; | |||
DirectionImg | CompassImg.SetclProSettings(CompassImg.clProSettings); | ||
DirectionImg = MyForm.AddNewProImage(MyForm,'DirectionImg'); | |||
MyForm.FormOrientationSensorType | DirectionImg.Align = AlCenter; | ||
MyForm.FormOrientationSensor.Active | DirectionImg.Height = 350; | ||
DirectionImg.Width = 350; | |||
GetTimer | DirectionImg.Margins.Right = 28; | ||
GetTimer.Enabled | DirectionImg.Margins.Bottom = 100; | ||
MyForm.AddNewEvent(GetTimer, tbeOnTimer, 'GetCompass'); | DirectionImg.clProSettings.PictureSource = 'https://clomosy.com/demos/compass_arrow2.png'; | ||
DirectionImg.clProSettings.PictureAutoFit = True; | |||
DirectionImg.SetclProSettings(DirectionImg.clProSettings); | |||
MyForm.FormOrientationSensorType = ostHeading; | |||
MyForm.FormOrientationSensor.Active = True; | |||
If (Clomosy.PlatformIsMobile) | |||
{ | |||
GetTimer = MyForm.AddNewTimer(MyForm, 'GetTimer', 500); | |||
GetTimer.Enabled = True; | |||
MyForm.AddNewEvent(GetTimer, tbeOnTimer, 'GetCompass'); | |||
} else ShowMessage('To use the feature, log in from your mobile device.'); | |||
MyForm.Run; | MyForm.Run; | ||
} | |||
</pre> | |||
<h2> Balance Sensor (ostTilt) </h2> | |||
"ostTilt" is the abbreviation for "Orientation Sensor Tilt." This term indicates the inclination or tilt of a device. It specifies how much the device is tilted around an axis.<br> | |||
For example, ostTilt can be used to determine the angle at which a device is inclined. This indicates how much the device is tilted in the horizontal plane.<br> | |||
You should write the following commands to obtain the X, Y, and Z position sensors.<br> | |||
<div class="alert alert-secondary" role="alert" data-bs-theme="light"> | |||
(currentYTilt,currentXTilt,currentZTilt: Double) | |||
</div> | |||
<b> Use of:</b><br> | |||
<pre> | |||
currentXTilt = MyForm.FormOrientationSensor.Sensor.TiltX; | |||
currentYTilt = MyForm.FormOrientationSensor.Sensor.TiltY; | |||
currentZTilt = MyForm.FormOrientationSensor.Sensor.TiltZ; | |||
</pre> | |||
<b>Example</b><br> | |||
<pre> | |||
var | |||
MyForm: TCLForm; | MyForm: TCLForm; | ||
CompassImg: TClProImage; | CompassImg: TClProImage; | ||
GetTimer: TClTimer; | GetTimer: TClTimer; | ||
TiltXLabel,TiltYLabel,TiltZLabel : TclLabel; | TiltXLabel,TiltYLabel,TiltZLabel : TclLabel; | ||
void GetTilt; | |||
var | |||
currentYTilt,currentXTilt,currentZTilt: Double; | currentYTilt,currentXTilt,currentZTilt: Double; | ||
rotationAngle: Double; | rotationAngle: Double; | ||
{ | |||
if MyForm.FormOrientationSensor.Sensor | if (not MyForm.FormOrientationSensor.Sensor==nil) | ||
{ | |||
currentXTilt = MyForm.FormOrientationSensor.Sensor.TiltX; | |||
currentYTilt = MyForm.FormOrientationSensor.Sensor.TiltY; | |||
currentZTilt = MyForm.FormOrientationSensor.Sensor.TiltZ; | |||
TiltXLabel.Text = 'X : '+FloatToStr(currentXTilt); | |||
TiltYLabel.Text = 'Y : '+FloatToStr(currentYTilt); | |||
TiltZLabel.Text = 'Z : '+FloatToStr(currentZTilt); | |||
} | |||
CompassImg.RotationAngle = currentXTilt; | |||
} | |||
{ | |||
MyForm = TCLForm.Create(Self); | |||
MyForm.SetFormBGImage('https://clomosy.com/demos/compassbg.png'); | |||
MyForm := | TiltXLabel = MyForm.AddNewLabel(MyForm,'TiltXLabel','--'); | ||
TiltXLabel.Align = alBottom; | |||
TiltXLabel.Margins.Bottom= 30; | |||
TiltXLabel.Height = 50; | |||
TiltXLabel.Width = 150; | |||
TiltYLabel = MyForm.AddNewLabel(MyForm,'TiltYLabel','--'); | |||
TiltYLabel.Align = alBottom; | |||
TiltYLabel.Margins.Bottom= 20; | |||
TiltYLabel.Height = 50; | |||
TiltYLabel.Width = 150; | |||
TiltZLabel = MyForm.AddNewLabel(MyForm,'TiltZLabel','--'); | |||
TiltZLabel.Align = alBottom; | |||
TiltZLabel.Margins.Bottom= 10; | |||
TiltZLabel.Height = 50; | |||
TiltZLabel.Width = 150; | |||
CompassImg = MyForm.AddNewProImage(MyForm,'CompassImg'); | |||
CompassImg.Align = AlCenter; | |||
CompassImg.Height = 350; | |||
CompassImg.Width = 350; | |||
CompassImg.clProSettings.PictureSource = 'https://clomosy.com/demos/balance.png'; | |||
CompassImg.clProSettings.PictureAutoFit = True; | |||
CompassImg.SetclProSettings(CompassImg.clProSettings); | |||
MyForm.FormOrientationSensorType = ostTilt; | |||
MyForm.FormOrientationSensor.Active = True; | |||
If(Clomosy.PlatformIsMobile) | |||
{ | |||
GetTimer = MyForm.AddNewTimer(MyForm, 'GetTimer', 500); | |||
GetTimer.Enabled = True; | |||
MyForm.AddNewEvent(GetTimer, tbeOnTimer, 'GetTilt'); | |||
} else ShowMessage('To use the feature, log in from your mobile device.'); | |||
MyForm.Run; | MyForm.Run; | ||
} | |||
</pre> | |||
<h2> See Also </h2> | |||
* [[Sensor Structures]] | |||
* [[Components]] | |||
* [[Object Properties]] | |||
* [[AddNewEvent]] | |||
{{#seo:|title=Device Sensor in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=Learn about Device Sensors in Clomosy Docs. A guide to integrating and utilizing sensors in your mobile apps for enhanced functionality.}} | |||
Latest revision as of 12:53, 24 December 2024
In Clomosy, a sensor is used in the context of mobile application development to detect the orientation of the device. The 'FormOrientationSensorType' property determines which type of sensor the mobile form will use to track the device's orientation.
For example, if the 'FormOrientationSensorType' property is set to "ostTilt," it will track the tilt of the device.
This property allows applications to track the position of the device, enabling operations like screen rotation. This is particularly important for games, map applications, and other mobile applications.
| Feature | Use of | Definition |
|---|---|---|
| FormOrientationSensorType | MyForm.FormOrientationSensorType = ostTilt; | It determines which type of sensor will be used to track the device's orientation. |
| ostTilt | MyForm.FormOrientationSensorType = ostTilt; | Specifies the amount the device tilts around an axis. |
| ostHeading | MyForm.FormOrientationSensorType = ostHeading; | Specifies the angle of the device towards north. |
| Active | MyForm.FormOrientationSensor.Active = True; | Sensor usage is activated. |
Compass Sensor (ostHeading)
"ostHeading" stands for "Orientation Sensor Heading." This term specifies the direction a device is facing. It indicates which way the device is oriented.
For example, in a compass application, the ostHeading value may represent the angle at which the device is pointing towards the north direction. This indicates how much the device has turned relative to the north.
In summary, ostHeading provides information about the device's orientation and which direction it is facing. This is particularly useful for applications that need to track the device's heading, such as compass or navigation applications.
You should write the following commands to obtain the X, Y, and Z position sensors.
(currentXHeading, currentYHeading, currentZHeading : Double)
Use of:
currentXHeading = MyForm.FormOrientationSensor.Sensor.HeadingX; currentYHeading = MyForm.FormOrientationSensor.Sensor.HeadingY; currentZHeading = MyForm.FormOrientationSensor.Sensor.HeadingZ;
Example
var
MyForm: TCLForm;
CompassImg,DirectionImg: TClProImage;
GetTimer: TClTimer;
CompassXLabel,CompassYLabel,CompassZLabel : TclLabel;
void GetCompass;
var
currentYHeading,currentXHeading,currentZHeading: Double;
rotationAngle: Double;
{
if (not MyForm.FormOrientationSensor.Sensor == nil)
{
currentYHeading = MyForm.FormOrientationSensor.Sensor.HeadingY;
currentXHeading = MyForm.FormOrientationSensor.Sensor.HeadingX;
currentZHeading = MyForm.FormOrientationSensor.Sensor.HeadingZ;
CompassXLabel.Text = 'X : '+FloatToStr(Abs(currentXHeading));
CompassYLabel.Text = 'Y : '+FloatToStr(Abs(currentYHeading));
CompassZLabel.Text = 'Z : '+FloatToStr(Abs(currentZHeading));
}
CompassImg.RotationAngle = currentYHeading;
}
{
MyForm = TCLForm.Create(Self);
MyForm.SetFormBGImage('https://clomosy.com/demos/compassbg.png');
CompassXLabel = MyForm.AddNewLabel(MyForm,'CompassXLabel','--');
CompassXLabel.Align = alBottom;
CompassXLabel.Margins.Bottom= 30;
CompassXLabel.Height = 50;
CompassXLabel.Width = 150;
CompassYLabel = MyForm.AddNewLabel(MyForm,'CompassYLabel','--');
CompassYLabel.Align = alBottom;
CompassYLabel.Margins.Bottom= 20;
CompassYLabel.Height = 50;
CompassYLabel.Width = 150;
CompassZLabel = MyForm.AddNewLabel(MyForm,'CompassZLabel','--');
CompassZLabel.Align = alBottom;
CompassZLabel.Margins.Bottom= 10;
CompassZLabel.Height = 50;
CompassZLabel.Width = 150;
CompassImg = MyForm.AddNewProImage(MyForm,'CompassImg');
CompassImg.Align = AlCenter;
CompassImg.Height = 350;
CompassImg.Width = 350;
CompassImg.clProSettings.PictureSource = 'https://clomosy.com/demos/compass2.png';
CompassImg.clProSettings.PictureAutoFit = True;
CompassImg.SetclProSettings(CompassImg.clProSettings);
DirectionImg = MyForm.AddNewProImage(MyForm,'DirectionImg');
DirectionImg.Align = AlCenter;
DirectionImg.Height = 350;
DirectionImg.Width = 350;
DirectionImg.Margins.Right = 28;
DirectionImg.Margins.Bottom = 100;
DirectionImg.clProSettings.PictureSource = 'https://clomosy.com/demos/compass_arrow2.png';
DirectionImg.clProSettings.PictureAutoFit = True;
DirectionImg.SetclProSettings(DirectionImg.clProSettings);
MyForm.FormOrientationSensorType = ostHeading;
MyForm.FormOrientationSensor.Active = True;
If (Clomosy.PlatformIsMobile)
{
GetTimer = MyForm.AddNewTimer(MyForm, 'GetTimer', 500);
GetTimer.Enabled = True;
MyForm.AddNewEvent(GetTimer, tbeOnTimer, 'GetCompass');
} else ShowMessage('To use the feature, log in from your mobile device.');
MyForm.Run;
}
Balance Sensor (ostTilt)
"ostTilt" is the abbreviation for "Orientation Sensor Tilt." This term indicates the inclination or tilt of a device. It specifies how much the device is tilted around an axis.
For example, ostTilt can be used to determine the angle at which a device is inclined. This indicates how much the device is tilted in the horizontal plane.
You should write the following commands to obtain the X, Y, and Z position sensors.
(currentYTilt,currentXTilt,currentZTilt: Double)
Use of:
currentXTilt = MyForm.FormOrientationSensor.Sensor.TiltX; currentYTilt = MyForm.FormOrientationSensor.Sensor.TiltY; currentZTilt = MyForm.FormOrientationSensor.Sensor.TiltZ;
Example
var
MyForm: TCLForm;
CompassImg: TClProImage;
GetTimer: TClTimer;
TiltXLabel,TiltYLabel,TiltZLabel : TclLabel;
void GetTilt;
var
currentYTilt,currentXTilt,currentZTilt: Double;
rotationAngle: Double;
{
if (not MyForm.FormOrientationSensor.Sensor==nil)
{
currentXTilt = MyForm.FormOrientationSensor.Sensor.TiltX;
currentYTilt = MyForm.FormOrientationSensor.Sensor.TiltY;
currentZTilt = MyForm.FormOrientationSensor.Sensor.TiltZ;
TiltXLabel.Text = 'X : '+FloatToStr(currentXTilt);
TiltYLabel.Text = 'Y : '+FloatToStr(currentYTilt);
TiltZLabel.Text = 'Z : '+FloatToStr(currentZTilt);
}
CompassImg.RotationAngle = currentXTilt;
}
{
MyForm = TCLForm.Create(Self);
MyForm.SetFormBGImage('https://clomosy.com/demos/compassbg.png');
TiltXLabel = MyForm.AddNewLabel(MyForm,'TiltXLabel','--');
TiltXLabel.Align = alBottom;
TiltXLabel.Margins.Bottom= 30;
TiltXLabel.Height = 50;
TiltXLabel.Width = 150;
TiltYLabel = MyForm.AddNewLabel(MyForm,'TiltYLabel','--');
TiltYLabel.Align = alBottom;
TiltYLabel.Margins.Bottom= 20;
TiltYLabel.Height = 50;
TiltYLabel.Width = 150;
TiltZLabel = MyForm.AddNewLabel(MyForm,'TiltZLabel','--');
TiltZLabel.Align = alBottom;
TiltZLabel.Margins.Bottom= 10;
TiltZLabel.Height = 50;
TiltZLabel.Width = 150;
CompassImg = MyForm.AddNewProImage(MyForm,'CompassImg');
CompassImg.Align = AlCenter;
CompassImg.Height = 350;
CompassImg.Width = 350;
CompassImg.clProSettings.PictureSource = 'https://clomosy.com/demos/balance.png';
CompassImg.clProSettings.PictureAutoFit = True;
CompassImg.SetclProSettings(CompassImg.clProSettings);
MyForm.FormOrientationSensorType = ostTilt;
MyForm.FormOrientationSensor.Active = True;
If(Clomosy.PlatformIsMobile)
{
GetTimer = MyForm.AddNewTimer(MyForm, 'GetTimer', 500);
GetTimer.Enabled = True;
MyForm.AddNewEvent(GetTimer, tbeOnTimer, 'GetTilt');
} else ShowMessage('To use the feature, log in from your mobile device.');
MyForm.Run;
}