sig
type usb
type bluetooth
type 'a conn
val connect_bluetooth :
?check_status:bool -> string -> Mindstorm.bluetooth Mindstorm.conn
val connect_usb :
?check_status:bool -> string -> Mindstorm.usb Mindstorm.conn
val close : 'a Mindstorm.conn -> unit
type error =
No_more_handles
| No_space
| No_more_files
| EOF_expected
| Not_a_linear_file
| No_linear_space
| Undefined_error
| File_is_busy
| No_write_buffers
| Append_not_possible
| File_is_full
| File_exists
| Module_not_found
| Out_of_boundary
| Illegal_file_name
| Pending
| Empty_mailbox
| Failed
| Unknown
| Insane
| Out_of_range
| Bus_error
| Buffer_full
| Invalid_conn
| Busy_conn
| No_program
| Bad_size
| Bad_mailbox
| Bad_field
| Bad_io
| Out_of_memory
| Bad_arg
exception Error of Mindstorm.error
exception File_not_found
module Program :
sig
val start : ?check_status:bool -> 'a Mindstorm.conn -> string -> unit
val stop : ?check_status:bool -> 'a Mindstorm.conn -> unit
val name : 'a Mindstorm.conn -> string
end
module Motor :
sig
type port
val a : Mindstorm.Motor.port
val b : Mindstorm.Motor.port
val c : Mindstorm.Motor.port
val all : Mindstorm.Motor.port
type regulation = [ `Idle | `Motor_speed | `Motor_sync ]
type run_state = [ `Idle | `Ramp_down | `Ramp_up | `Running ]
type state = {
speed : int;
motor_on : bool;
brake : bool;
regulation : Mindstorm.Motor.regulation;
turn_ratio : int;
run_state : Mindstorm.Motor.run_state;
tach_limit : int;
}
val speed :
?tach_limit:int ->
?brake:bool ->
?sync:bool -> ?turn_ratio:int -> int -> Mindstorm.Motor.state
val set :
?check_status:bool ->
'a Mindstorm.conn ->
Mindstorm.Motor.port -> Mindstorm.Motor.state -> unit
val get :
'a Mindstorm.conn ->
Mindstorm.Motor.port -> Mindstorm.Motor.state * int * int * int
val reset_pos :
?check_status:bool ->
'a Mindstorm.conn -> ?relative:bool -> Mindstorm.Motor.port -> unit
end
module Sensor :
sig
type t
type port = [ `S1 | `S2 | `S3 | `S4 ]
type sensor_type =
[ `Angle
| `Custom
| `Highspeed
| `Light_active
| `Light_inactive
| `Lowspeed
| `Lowspeed_9v
| `No_sensor
| `Reflection
| `Sound_db
| `Sound_dba
| `Switch
| `Temperature ]
type mode =
[ `Angle_steps
| `Bool
| `Celsius
| `Fahrenheit
| `Pct_full_scale
| `Period_counter
| `Raw
| `Slope_mask
| `Transition_cnt ]
val set :
?check_status:bool ->
'a Mindstorm.conn ->
Mindstorm.Sensor.port ->
Mindstorm.Sensor.sensor_type -> Mindstorm.Sensor.mode -> unit
type data = {
sensor_type : Mindstorm.Sensor.sensor_type;
mode : Mindstorm.Sensor.mode;
valid : bool;
raw : int;
normalized : int;
scaled : int;
}
val get :
'a Mindstorm.conn -> Mindstorm.Sensor.port -> Mindstorm.Sensor.data
val reset_scaled :
?check_status:bool ->
'a Mindstorm.conn -> Mindstorm.Sensor.port -> unit
val get_status : 'a Mindstorm.conn -> Mindstorm.Sensor.port -> int
val write :
?check_status:bool ->
'a Mindstorm.conn ->
Mindstorm.Sensor.port -> ?rx_length:int -> string -> unit
val read : 'a Mindstorm.conn -> Mindstorm.Sensor.port -> string
module Ultrasonic :
sig
type t
val make :
'a Mindstorm.conn ->
Mindstorm.Sensor.port -> Mindstorm.Sensor.Ultrasonic.t
val set :
?check_status:bool ->
Mindstorm.Sensor.Ultrasonic.t ->
[ `Event
| `Meas
| `Meas_cont
| `Meas_interval of int
| `Off
| `Reset
| `Scale_div of int
| `Scale_mul of int
| `Zero of int ] -> unit
val get :
Mindstorm.Sensor.Ultrasonic.t ->
[ `Byte0
| `Byte1
| `Byte2
| `Byte3
| `Byte4
| `Byte5
| `Byte6
| `Byte7
| `Meas_interval
| `Scale_div
| `Scale_mul
| `Zero ] -> int
val get_state :
Mindstorm.Sensor.Ultrasonic.t ->
[ `Event | `Meas | `Meas_cont | `Off | `Reset ]
end
end
module Sound :
sig
val play :
?check_status:bool ->
'a Mindstorm.conn -> ?loop:bool -> string -> unit
val stop : ?check_status:bool -> 'a Mindstorm.conn -> unit
val play_tone :
?check_status:bool -> 'a Mindstorm.conn -> int -> int -> unit
end
module Message :
sig
type mailbox =
[ `B0 | `B1 | `B2 | `B3 | `B4 | `B5 | `B6 | `B7 | `B8 | `B9 ]
type remote =
[ `R0 | `R1 | `R2 | `R3 | `R4 | `R5 | `R6 | `R7 | `R8 | `R9 ]
val write :
?check_status:bool ->
'a Mindstorm.conn -> Mindstorm.Message.mailbox -> string -> unit
val read :
'a Mindstorm.conn ->
?remove:bool ->
[ `B0
| `B1
| `B2
| `B3
| `B4
| `B5
| `B6
| `B7
| `B8
| `B9
| `R0
| `R1
| `R2
| `R3
| `R4
| `R5
| `R6
| `R7
| `R8
| `R9 ] -> string
end
type in_channel
val open_in : 'a Mindstorm.conn -> string -> Mindstorm.in_channel
val in_channel_length : Mindstorm.in_channel -> int
val close_in : Mindstorm.in_channel -> unit
val input : Mindstorm.in_channel -> string -> int -> int -> int
type out_channel
type out_flag = [ `Append | `Data of int | `File of int | `Linear of int ]
val open_out :
'a Mindstorm.conn ->
Mindstorm.out_flag -> string -> Mindstorm.out_channel
val close_out : Mindstorm.out_channel -> unit
val output : Mindstorm.out_channel -> string -> int -> int -> int
val remove : 'a Mindstorm.conn -> string -> unit
module Find :
sig
type iterator
val patt : 'a Mindstorm.conn -> string -> Mindstorm.Find.iterator
val current : Mindstorm.Find.iterator -> string
val current_size : Mindstorm.Find.iterator -> int
val next : Mindstorm.Find.iterator -> unit
val close : Mindstorm.Find.iterator -> unit
val iter :
'a Mindstorm.conn -> f:(string -> int -> unit) -> string -> unit
val map :
'a Mindstorm.conn -> f:(string -> int -> 'b) -> string -> 'b list
val fold :
'a Mindstorm.conn ->
f:(string -> int -> 'b -> 'b) -> string -> 'b -> 'b
end
val firmware_version : 'a Mindstorm.conn -> int * int * int * int
val set_brick_name :
?check_status:bool -> 'a Mindstorm.conn -> string -> unit
type brick_info = {
brick_name : string;
bluetooth_addr : string;
signal_strength : int;
free_user_flash : int;
}
val get_device_info : 'a Mindstorm.conn -> Mindstorm.brick_info
val keep_alive : 'a Mindstorm.conn -> int
val battery_level : 'a Mindstorm.conn -> int
val delete_user_flash : 'a Mindstorm.conn -> unit
val bluetooth_reset : Mindstorm.usb Mindstorm.conn -> unit
val boot : Mindstorm.usb Mindstorm.conn -> unit
val poll_length :
'a Mindstorm.conn -> [ `High_speed_buffer | `Poll_buffer ] -> int
val poll_command :
'a Mindstorm.conn ->
[ `High_speed_buffer | `Poll_buffer ] -> int -> int * string
end