Sign in Join
Wiki copytemporary

LazDeviceAPIs: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-LazDeviceAPIs is a LCL unit which offers an interface to various hardware devices, such as the accelerometer, GPS positioning, SMS sending, etc. It is mostly designed for smartphone/mobile platforms, but it might eventually be ported to desktops too.
1+[![Android robot.svg](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Android_robot.svg/50px-Android_robot.svg.png)](</File:Android_robot.svg>)
22
3-## Introduction
3+This article applies to [Android](</Category:Android> "Category:Android") only.
44
5-LazDeviceAPIs was modeled to be similar to other APIs for hardware devices from the LCL. Historically we had two hardware global objects: Mouse and Screen, respectively for the pointing device (Mouse is also utilized for touch messages) and Screen for the display. In LazDeviceAPIs there are global objects: Accelerometer, PositionInfo, Messaging, etc.
5+See also: [[Multiplatform Programming Guide]]
66
7-## Accelerometer
7+│ **English (en)** │ **[[LazDeviceAPIs/ko|한국어 (ko)]]** │
88
9-The Accelerometer is very easy to use. Just call Accelerometer.StartReadingAccelerometerData to start listening to the accelerometer sensor and call Accelerometer.StopReadingAccelerometerData to stop listening to it:
9+LazDeviceAPIs is a LCL unit which offers an interface to various hardware devices, such as the accelerometer, GPS positioning, SMS sending, etc. It is mostly designed for smartphone/mobile platforms, but it might eventually be ported to desktops too.
1010
11-``` pascal
12-uses lazdeviceapis;
11+
1312
14-procedure TForm2.btnStartAccelClick(Sender: TObject);
15-begin
16- Accelerometer.OnSensorChanged := @HandleAccelerometerChanged;
17- Accelerometer.StartReadingAccelerometerData();
18-end;
13+## Introduction
1914
20-procedure TForm2.btnStopAccelClick(Sender: TObject);
21-begin
22- Accelerometer.StopReadingAccelerometerData();
23-end;
15+LazDeviceAPIs was modeled to be similar to other APIs for hardware devices from the LCL. Historically we had two hardware global objects: Mouse and Screen, respectively for the pointing device (Mouse is also utilized for touch messages) and Screen for the display. In LazDeviceAPIs there are global objects: Accelerometer, PositionInfo, Messaging, etc.
2416
25-procedure TForm2.HandleAccelerometerChanged(Sender: TObject);
26-begin
27- labelSensorData.Caption := Format('X=%f Y=%f Z=%f', [Accelerometer.xaxis,
28- Accelerometer.yaxis, Accelerometer.zaxis]);
29- DebugLn(labelSensorData.Caption);
30-end;
17+## Accelerometer
18+
19+The Accelerometer is very easy to use. Just call Accelerometer.StartReadingAccelerometerData to start listening to the accelerometer sensor and call Accelerometer.StopReadingAccelerometerData to stop listening to it:
3120```
21+uses lazdeviceapis;
22+
23+ procedure TForm2.btnStartAccelClick(Sender: TObject);
24+ begin
25+ Accelerometer.OnSensorChanged := @HandleAccelerometerChanged;
26+ Accelerometer.StartReadingAccelerometerData();
27+ end;
28+
29+ procedure TForm2.btnStopAccelClick(Sender: TObject);
30+ begin
31+ Accelerometer.StopReadingAccelerometerData();
32+ end;
33+
34+ procedure TForm2.HandleAccelerometerChanged(Sender: TObject);
35+ begin
36+ labelSensorData.Caption := Format('X=%f Y=%f Z=%f', [Accelerometer.xaxis,
37+ Accelerometer.yaxis, Accelerometer.zaxis]);
38+ DebugLn(labelSensorData.Caption);
39+ end;
40+```
3241
3342### Android Permissions
3443
35-This object requires no special permissions under Android.
44+This object requires no special permissions under Android.
3645
3746## PositionInfo
3847
3948### Android Permissions
4049
41-Using the PositionInfo global object in Android requires adding the following permissions to the AndroidManifest.xml file of the application, as can be seen below.
42-
43-``` pascal
50+Using the PositionInfo global object in Android requires adding the following permissions to the AndroidManifest.xml file of the application, as can be seen below.
51+```
4452<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
45-<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
53+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
4654```
4755
4856## Messaging
4957
5058### Android Permissions
5159
52-Using the Messaging global object in Android requires adding the following permissions to the AndroidManifest.xml file of the application, as can be seen below.
53-
54-``` pascal
60+Using the Messaging global object in Android requires adding the following permissions to the AndroidManifest.xml file of the application, as can be seen below.
61+```
5562<uses-permission android:name="android.permission.SEND_SMS" />
5663```
5764
5865## Possible Windows implementation
5966
60-Windows 7 and up has a sensors API that gives access to sensor info (e.g. GPS); see [[http://msdn.microsoft.com/en-us/library/windows/desktop/dd318936(v=vs.85).aspx|http://msdn.microsoft.com/en-us/library/windows/desktop/dd318936%28v=vs.85%29.aspx]]. Interested developers may be able to use those APIs to provide LazDeviceAPIs functionality.
67+Windows 7 and up has a sensors API that gives access to sensor info (e.g. GPS); see [[[1]](<http://msdn.microsoft.com/en-us/library/windows/desktop/dd318936%28v=vs.85%29.aspx>)]. Interested developers may be able to use those APIs to provide LazDeviceAPIs functionality.
6168
6269## Roadmap
6370
64-LazDeviceAPIs is currently implemented only for LCL-CustomDrawn-Android
71+LazDeviceAPIs is currently implemented only for LCL-CustomDrawn-Android
6572
6673## See Also
6774
68-- [[Custom Drawn Interface/Android]]
69-- Talk:LazDeviceAPIs
75+ * [[Custom Drawn Interface/Android]]
76+ * [Talk:LazDeviceAPIs](</Talk:LazDeviceAPIs> "Talk:LazDeviceAPIs")
7077
7178---
72-*From the Free Pascal wiki, page "LazDeviceAPIs", as it stood on 2020-02-18 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
79+*From the Free Pascal wiki, page "LazDeviceAPIs", as the Internet Archive kept it on 2024-09-20, last changed on 2020-02-19. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history