Module Mindstorm.Sensor.Ultrasonic


module Ultrasonic: sig .. end
Ultrasonic sensor. Convenience functions to interact with the ultrasonic sensor through the I2C protocol.

type t 
Represent an initialized ultrasonic sensor connected to a given port.
val make : 'a Mindstorm.conn -> Mindstorm.Sensor.port -> t
make conn port initialize the sensor on port port as being an ultrasonic one.
val set : ?check_status:bool ->
t ->
[ `Event
| `Meas
| `Meas_cont
| `Meas_interval of int
| `Off
| `Reset
| `Scale_div of int
| `Scale_mul of int
| `Zero of int ] -> unit
Ultrasonic.set us cmd set the state or parameters for the ultrasonic sensor us. cmd may be:


check_status : check the return status. Exceptionally, the default is true because the sensor needs to time to set itself up anyway and this avoids Mindstorm.Buffer_full errors if we try to get values from the sensor.
val get : t ->
[ `Byte0
| `Byte1
| `Byte2
| `Byte3
| `Byte4
| `Byte5
| `Byte6
| `Byte7
| `Meas_interval
| `Scale_div
| `Scale_mul
| `Zero ] -> int
Ultrasonic.get us var returns the content of the variable var on the sensor (detailed underneath). All values are between 0 and 255. Communication errors will be reported by raising Error Bus_error; your application should be ready to handle such exceptions.


val get_state : t ->
[ `Event | `Meas | `Meas_cont | `Off | `Reset ]
get_state us get the current state of the ultrasonic sensor us.