VCL.Sensors Sample
This sample demonstrates how to use different sensor components such as: TLocationSensor, TMotionSensor or TOrientationSensor.
Contents
Location
You can find the Sensors sample project at:
- Start | Programs | Embarcadero RAD Studio Alexandria | Samples and then navigate to:
Object Pascal\VCL\Sensors
CPP\VCL\Sensors
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
The Sensors sample demonstrates how to use sensor components on a VCL application. The sample uses TLocationSensor, TMotionSensor and TOrientationSensor to provide related sensor information.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi:
VCLSensors.dproj
. - C++:
VCLSensorsCpp.cbproj
.
- Delphi:
- Press F9 or choose Run > Run.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
|
|
The project itself. |
|
|
The main form. |
Classes
TForm5 is the main form that represents the main window of the sample. It contains the following components:
- A TGroupBox object, named GroupBox4, that contains:
- A TButton object named bSwitch.
- A TLocationSensor object named lsLocation.
- A TMotionSensor object named msAccelerometer.
- Two TOrientationSensor objects, named osCompass and osInclinometer.
- A TPanel object, named Panel1, that contains tree TGroupBox objects.
- Two TTimer objects, named tMotion and tOrientation.
Implementation
- The sample uses TLocationSensor to determine the location information of the device.
- The sample uses TMotionSensor to offer information about the acceleration in each coordinate axis.
- The sample uses TOrientationSensor to give information about the device inclination and compass heading.
- The sample uses TButton to enable the VCL sensors.
- The sample uses TTimer to repeat specific actions after a given time interval. Each TTimer specifies the time interval in which each sensor offers information to the user.
- The sample uses TLabel to display text on the form. Each label is used to display each sensor information.
- The sample uses TGroupBox to group related controls on a form. In this sample, each TGroupBox groups the labels that display information about the sample sensor.
When you run the application, the Active properties of the VCL sensors are set to False
, which means that all the sensors are disabled. Moreover, you see the form divided in four TGroupBox objects with the following captions: Location
, Motion
, Orientation
and Manage
. The GroupBox4, labeled as Manage
, contains the bSwitch button with its caption displaying the text Turn on
. When you click on the bSwitch button, its caption changes to Turn off
and the Active property of the VCL sensors changes to True
. Then, the information related with each sensor is displayed using the labels that contain each TGroupBox object.
Uses
See Also
Samples
- FireMonkey Sensor Info sample
- FireMonkey Accelerometer sample
- FireMonkey Location sample
- FireMonkey Orientation sample