hBasic > hManual > Commands > Sensors

hBasic Manual
Sensors command changes


Overview
Changes to the sensors system
SENSORS.LIST
SENSORS.OPEN / READ
Changes made.


Pseudo Sensor type -3
A special sensor to replace type 3 Orientation

Overview
The minimum sensor type was changed to 1
The maximum sensor type was changed to 42
There is a special sensor allowed -3

Officially, Android does not support sensors outside this range and also a few inside the range.
(For supported sensors, search this Android developer page of the Sensor object.)

SENSORS.LIST {size_nvar,} sensor_array$[]

Gets a list of sensors returned in sensor_array$[].

Any sensors reported from SENSORS.LIST beginning with "Unknown"
is not supported by Android. However, those that are still within the range 1-42 can still be OPENed and READ.
"Unknown" sensors will also try to print their names after "Unknown".
Also (now), this command will remove any duplicate types reported.

If size is given, the array size is returned in size and may be zero.
If size is omitted, and there are no detected sensors, (array size is zero) then there will be a RunTimeError.

SENSORS.OPEN and SENSORS.READ both check (now) if the sensor falls within the allowed range. "Unknown" sensors that are inside this range are also let through. Special sensors e.g -3 are also allowed through.

Unknown Sensors
Here is a list of "Unknown" sensors within range 1-42, which may be of interest.
They are by no means definitive, since each manufacturer can choose their own numbers.
They may or may not work.
Unknown Types
Type      Reported  
comment
17
Significant Motion
(samsung, xiaomi)
18
Step Detect
(xiaomi)
19 pedometer
(xiaomi)
22
Tilt detector
(samsung, xiaomi)
27
Orientation
discrete orientation
(samsung, xiaomi)
29
Stationary detect
(xiaomi)
30
Motion detect
(xiaomi)
35
Accelerometer-Uncalibrated
(xiaomi)

Pseudo Sensor type -3 Orientation

Sensor Type (+)3 was deprecated since Android 4.4W (API 20).
This special type of -3 is an hBasic replacement.

The  SENSORS commands do not normally allow a negative type, but will
treat this request as a special case.
SENSORS.OPEN and SENSORS.READ will not error for special type of -3.

Type -3 uses the Acceleration and Magnetic Field sensors.
Both sensors must be available in hardware to work.

SENSORS.OPEN -3 is the same as SENSORS.OPEN 1,2 (with common delay) 

    e.g
    SENSORS.Open -3        % or SENSORS.open 1,2
    SENSORS.Read -3, azimuth, pitch, roll


An example of using this sensor is found in the sample program h06_compass.bas.

Notes
This pseudo sensor follows the guideline found here ;
Also, the old sensor type 3 had the roll reversed, this one doesn't.



Leading Cloud Surveillance, Recording and Storage service; IP camera live viewing

Leading Enterprise Cloud IT Service; cloud file server, FTP Hosting, Online Storage, Backup and Sharing

Powered by FirstCloudIT.com, a division of DriveHQ, the leading Cloud IT and Cloud Surveillance Service provider since 2003.