module Sensor:Input ports.sig..end
The NXT brick also accepts the sensors for the previous version of
the mindstorm brick, called RCX, so several options refer to RCX.
type t
typeport =[ `S1 | `S2 | `S3 | `S4 ]
port through let bindings.typesensor_type =[ `Angle
| `Custom
| `Highspeed
| `Light_active
| `Light_inactive
| `Lowspeed
| `Lowspeed_9v
| `No_sensor
| `Reflection
| `Sound_db
| `Sound_dba
| `Switch
| `Temperature ]
`Raw, but some values have other side effects.
`No_sensor: No sensor configured`Switch: NXT or RCX touch sensor`Temperature: RCX temperature sensor`Reflection: RCX light sensor`Angle: RCX rotation sensor`Light_active: NXT light sensor with floodlight enabled`Light_inactive: NXT light sensor with floodlight disabled`Sound_db: NXT sound sensor; includes sounds too high
or too low for our ears.`Sound_dba: NXT sound sensor; focuses on sounds within
human hearing.`Custom`Lowspeed: I2C digital sensor`Lowspeed_9v: I2C digital sensor, 9V power (e.g. ultrasonic).`Highspeed: Set `S4 to highspeed mode. This is currently
unused by LEGOŽ sensors. This targets the P-Net communication
protocol (www.P-net.org).typemode =[ `Angle_steps
| `Bool
| `Celsius
| `Fahrenheit
| `Pct_full_scale
| `Period_counter
| `Raw
| `Slope_mask
| `Transition_cnt ]
`Raw: Report scaled value equal to raw value.
`Bool: Report scaled value as 1 (TRUE) or 0 (FALSE).
Note that for the switch sensor, the value is 1 of the
button is pressed at the moment the data is requested.
Use `Transition_cnt if you want not to miss button
presses between two requests.
The firmware uses inverse Boolean logic to match the
physical characteristics of NXT sensors. Readings
are FALSE if raw value exceeds 55% of total range;
readings are TRUE if raw value is less than 45% of
total range.
`Transition_cnt: Report scaled value as number of
transitions between TRUE and FALSE. May not be fully exact
if transitions are fast.
`Period_counter: Report scaled value as number of
transitions from FALSE to TRUE, then back to FALSE.
`Pct_full_scale: Report scaled value as percentage of full
scale reading for configured sensor type.`Celsius: Scale temperature reading to degrees Celsius.`Fahrenheit: Scale temperature reading to degrees Fahrenheit.`Angle_steps: Report scaled value as count of ticks on
RCX-style rotation sensor.val set : ?check_status:bool ->
'a Mindstorm.conn ->
port ->
sensor_type -> mode -> unitset conn p ty m set the sensor connected to port p to type
ty and mode m.check_status : whether to check the status returned by
the brick. Default: see Mindstorm.connect_bluetooth.type data = {
|
sensor_type : |
|||
|
mode : |
|||
|
valid : |
(* | true if new data value should be seen as valid | *) |
|
raw : |
(* | Raw A/D value. Device dependent. Range: 0 .. 1023 | *) |
|
normalized : |
(* | Normalized A/D value. Range: 0 .. 1023 | *) |
|
scaled : |
(* | Scaled value. Its range depend on the Mindstorm.Sensor.mode
chosen:
| *) |
val get : 'a Mindstorm.conn -> port -> dataget conn p returns the data read on port p. Before using
this function, you must set the sensor type with
Mindstorm.Sensor.set.val reset_scaled : ?check_status:bool -> 'a Mindstorm.conn -> port -> unitreset_scaled conn portcheck_status : whether to check the status returned by
the brick. Default: see Mindstorm.connect_bluetooth.val get_status : 'a Mindstorm.conn -> port -> intget_status conn port returns the number of bytes ready to be
read.val write : ?check_status:bool ->
'a Mindstorm.conn ->
port -> ?rx_length:int -> string -> unitwrite conn port data writes data to lowspeed I2C sensor
connected to the port. This is the protocol (e.g. for
talking to the ultrasonic sensor). Communication errors will
be reported by raising Error Bus_error; your application
should be ready to handle such exceptions.check_status : whether to check the status returned by
the brick. Default: see Mindstorm.connect_bluetooth.rx_length : gives the number of bytes to receive.
Default: 0 i.e. no answer expected.val read : 'a Mindstorm.conn -> port -> stringError Bus_error; your application should
be ready to handle such exceptions.module Ultrasonic:sig..end