StateChanged(Connected As Boolean)
StateChangedEx(Connected As Boolean, Battery As Byte, Voltage As Double, Distance As Double, Color As Int)
BatteryLevel As Byte
Battery Level 0-100%.
Example:
Private moveHub As LegoinoBoost
moveHUB.Initialize("MoveHub_StateChanged", "00:16:53:AE:9B:27", False)
Sub MoveHub_StateChanged(Connected As Boolean)
If Connected Then
Log("BatteryLevel: ", moveHUB.BatteryLevel, "%")
End If
VoltageSensor As double
Voltage V from the sensor. Max voltage is 9.6 V.
Example:
Private moveHub As LegoinoBoost
moveHUB.Initialize("MoveHub_StateChanged", "00:16:53:AE:9B:27", False)
Sub MoveHub_StateChanged(Connected As Boolean)
If Connected Then
Log("VoltageSensor: ", moveHUB.VoltageSensor, "V")
End If
CurrentSensor As double
Current mA from the sensor. Max current is 2444 mA.
DistanceSensor As double
Distance sensor measuring in millimeter.
Example:
Private moveHub As LegoinoBoost
Private DistanceSensor As Double = -1
moveHUB.Initialize("MoveHub_StateChanged", "00:16:53:AE:9B:27", False)
Sub MoveHub_StateChanged(Connected As Boolean)
If Connected Then
Log("DistanceSensor: ", moveHub.DistanceSensor, "mm")
End If
ColorSensor As int
Color sensor with values: BLACK = 0, PINK = 1, PURPLE = 2, BLUE = 3, LIGHTBLUE = 4, CYAN = 5,
GREEN = 6, YELLOW = 7, ORANGE = 8, RED = 9, WHITE = 10, NONE = 255
Example:
Private moveHub As LegoinoBoost
Private colorSensor As Int = -1
moveHUB.Initialize("MoveHub_StateChanged", "00:16:53:AE:9B:27", False)
If moveHUB.Connected Then
colorSensor = moveHub.ColorSensor
moveHub.SetLedColor(colorSensor)
End If
TiltSensorX As int
Tilt sensor degrees of rotation/tilt around the x axis.
TiltSensorY As int
Tilt sensor degrees of rotation/tilt around the y axis.
LED_COLOR_BLACK As Byte
MoveHUB LED Color BLACK = 0
LED_COLOR_PINK As Byte
MoveHUB LED Color PINK = 1
LED_COLOR_PURPLE As Byte
MoveHUB LED Color PURPLE = 2
LED_COLOR_BLUE As Byte
MoveHUB LED Color BLUE = 3
LED_COLOR_LIGHTBLUE As Byte
MoveHUB LED Color LIGHTBLUE = 4
LED_COLOR_CYAN As Byte
MoveHUB LED Color CYAN = 5
LED_COLOR_GREEN As Byte
MoveHUB LED Color GREEN = 6
LED_COLOR_YELLOW As Byte
MoveHUB LED Color YELLOW = 7
LED_COLOR_ORANGE As Byte
MoveHUB LED Color ORANGE = 8
LED_COLOR_RED As Byte
MoveHUB LED Color RED = 9
LED_COLOR_WHITE As Byte
MoveHUB LED Color WHITE = 10
LED_COLOR_NONE As Byte
MoveHUB LED Color NONE = 255
BRAKINGSTYLE_BRAKE As Byte
Braking style BRAKE = 127
BRAKINGSTYLE_HOLD As Byte
Braking style HOLD = 126
BRAKINGSTYLE_FLOAT As Byte
Braking style FLOAT = 0
MOVEHUBPORT_A As Byte
MoveHUB Port A = 0x00 = Tacho Motor A
MOVEHUBPORT_B As Byte
MoveHUB Port B = 0x01 = Tacho Motor B
MOVEHUBPORT_AB As Byte
MoveHUB Port AB = 0x10 = Tacho Motors A and B
MOVEHUBPORT_C As Byte
MoveHUB Port C = 0x02 = Basic Motor or Color Distance Sensor
MOVEHUBPORT_D As Byte
MoveHUB Port D = 0x03 = Basic Motor or Color Distance Sensor
MOVEHUBPORT_LED As Byte
MoveHUB Port LED = 0x32 = Hub LED
MOVEHUBPORT_TILT As Byte
MoveHUB Port TILT = 0x3A = Tilt X or Z Sensor
MOVEHUBPORT_CURRENT As Byte
MoveHUB Port CURRENT = 0x3B = Hub Current - Max current is 2444 mA
MOVEHUBPORT_VOLTAGE As Byte
MoveHUB Port CURRENT = 0x3C = Hub Voltage - Max Voltage is 9.6V
Connected As bool
Hub connection state.
Returns:
Boolean True (Connected) or False (Disconnected).
Name As B4R::B4RString*
Name of the hub.
Returns:
String with the hub name.
Debug(debug As bool) As {}
Debug.
Set debug on or off.
Returns:
None
Initialize(StateChangedSub As SubVoidBool, Addr As B4R::B4RString*, Debug As bool) As bool
Initializes the hub object.
StateChangedSub - The sub to call when the hub connection has changed.
Addr - Device MAC address - a4:c1:38:38:a9:0c.
Debug - Set to true to log the various steps from init to getting data.
Returns:
None
Example:
Private moveHub As LegoinoBoost
moveHub.Initialize("MoveHub_StateChangedSub", "00:16:53:AE:9B:27", False)
Sub MoveHub_StateChanged(Connected As Boolean)
Log("MoveHUB StateChanged: Connected to ", moveHub.Name)
End Sub
InitializeEx(StateChangedExSub As SubVoidBoost, Addr As B4R::B4RString*, Debug As bool) As bool
Initializes the hub object.
StateChangedExSub - The sub to call when the hub connection or any of the sensor values has changed.
Addr - Device MAC address - a4:c1:38:38:a9:0c.
Debug - Set to true to log the various steps from init to getting data.
Returns:
None
Example:
Private moveHub As LegoinoBoost
Private ConnectionStatePrev As Boolean = False
moveHub.InitializeEx("MoveHub_StateChangedExSub", "00:16:53:AE:9B:27", False)
Sub MoveHub_StateChangedEx(Connected As Boolean, Battery As Byte, Voltage As Double, Distance As Double, Color As Int)
If Connected <> ConnectionStatePrev Then
If Connected Then
Log("MoveHUB StateChanged: Connected to ", moveHub.Name)
Else
Log("MoveHUB StateChanged: Disconnected")
End If
ConnectionStatePrev = Connected
End If
If Connected And Distance <= 0 Then Return
If Connected Then Log("Distance: ", Distance, "mm")
End Sub
MoveForward(steps As int) As B4R::void
Move forward (port AB) with the default speed and stop after the number of steps.
steps - Number of steps (Boost grid).
Returns:
None
MoveBack(steps As int) As B4R::void
Move back (port AB) with the default speed and stop after the number of steps.
steps - Number of steps (Boost grid).
Returns:
None
Rotate(degrees As int) As B4R::void
Rotate (port AB) with the default speed and stop after the degrees.
degrees - negative: left, positive: right.
Returns:
None
RotateLeft(degrees As int) As B4R::void
RotateRight(degrees As int) As B4R::void
MoveArc(degrees As int) As B4R::void
Move an arc (port AB) with the default speed and stop after degrees.
degrees - negative: left, positive: right.
MoveArcLeft(degrees As int) As B4R::void
MoveArcRight(degrees As int) As B4R::void
SetLEDColor(color As Byte) As B4R::void
Set the color of the hub LED with predefined colors.
color - one of the available hub colors.
Color values if set direct:
BLACK = 0,PINK = 1,PURPLE = 2,BLUE = 3,LIGHTBLUE = 4,CYAN = 5,
GREEN = 6,YELLOW = 7,ORANGE = 8,RED = 9,WHITE = 10,NONE = 255
Returns:
None
Example:
Private moveHub As LegoinoBoost
Private DEBUG As Boolean = False
Private Const MOVEHUB_ADDRESS As String = "00:16:53:AE:9B:27"
moveHub.Initialize("MoveHub_StateChanged", MOVEHUB_ADDRESS, DEBUG)
If moveHUB.Connected Then
moveHub.SetLEDColor(moveHub.LED_COLOR_GREEN)
End If
SetLEDRGBColor(red As Byte, green As Byte, blue As Byte) As B4R::void
Set the color of the hub LED with RGB values .
red - 0..255.
green - 0..255.
blue - 0..255.
Returns:
None
Example:
Private moveHub As LegoinoBoost
Private DEBUG As Boolean = False
Private Const MOVEHUB_ADDRESS As String = "00:16:53:AE:9B:27"
moveHub.Initialize("MoveHub_StateChanged", MOVEHUB_ADDRESS, DEBUG)
If moveHUB.Connected Then
moveHub.SetLEDRGBColor(255, 125, 125)
End If
SetLEDHSVColor(hue As int, saturation As double, value As double) As B4R::void
Set the color of the hub LED with HSV values.
hue - 0..360.
saturation - 0..1.
value - 0..1.
Returns:
None
Example:
Private moveHub As LegoinoBoost
Private DEBUG As Boolean = False
Private Const MOVEHUB_ADDRESS As String = "00:16:53:AE:9B:27"
moveHub.Initialize("MoveHub_StateChanged", MOVEHUB_ADDRESS, DEBUG)
Log("HSV CYAN 180°, 100%, 50%")
If moveHUB.Connected Then
moveHub.SetLEDHSVColor(180, 1, 0.5)
End If
StopBasicMotor(port As Byte) As B4R::void
Stop the motor on a defined port. Calls SetBasicMotorSpeed with speed 0.
port - Port of the hub on which the motor will be stopped (A, B) or (0, 1).
Returns:
None
SetBasicMotorSpeed(port As Byte, speed As int) As B4R::void
Set the motor speed on a defined port.
port - Port of the hub on which the speed of the motor will set (A, B, AB).
speed - Speed of the motor -100..0..100 negative values will reverse the rotation.
Returns:
None
SetAccelerationProfile(port As Byte, time As int) As B4R::void
Set the acceleration profile.
port - Port of the hub on which the speed of the motor will set (A, B, AB).
time - Time value in ms of the acceleration from 0-100% speed/Power.
Returns:
None
SetDecelerationProfile(port As Byte, time As int) As B4R::void
Set the deceleration profile.
port - Port of the hub on which the speed of the motor will set (A, B, AB).
time - Time value in ms of the deceleration from 100-0% speed/Power.
Returns:
None
StopTachoMotor(port As Byte) As B4R::void
Stop the motor on a defined port.
port - Port of the hub on which the motor will be stopped (A, B, AB, C, D).
Returns:
None
Example:
Private moveHub As LegoinoBoost
Private DEBUG As Boolean = False
Private Const MOVEHUB_ADDRESS As String = "00:16:53:AE:9B:27"
moveHub.Initialize("MoveHub_StateChanged", MOVEHUB_ADDRESS, DEBUG)
If moveHUB.Connected Then
moveHUB.StopTachoMotor(moveHUB.MOVEHUBPORT_A)
End If
SetTachoMotorSpeed(port As Byte, speed As int, maxPower As Byte, brakingStyle As Byte) As B4R::void
Set the motor speed on a defined port.
port - Port of the hub on which the speed of the motor will set.
speed - Speed of the motor -100..0..100 negative values will reverse the rotation.
maximum - Power of the motor 0..100.
brakingStyle - Braking style how the motor will stop = Brake (default), Float, Hold.
Returns:
None
Example:
Private moveHub As LegoinoBoost
Private DEBUG As Boolean = False
Private Const MOVEHUB_ADDRESS As String = "00:16:53:AE:9B:27"
moveHub.Initialize("MoveHub_StateChanged", MOVEHUB_ADDRESS, DEBUG)
If moveHUB.Connected Then
moveHUB.SetTachoMotorSpeed(moveHUB.MOVEHUBPORT_A, 20, 100, moveHUB.BRAKINGSTYLE_BRAKE)
End If
SetTachoMotorSpeedForTime(port As Byte, speed As int, time As int, maxPower As Byte, brakingStyle As Byte) As B4R::void
Set the motor speed on a defined port.
port - Port of the hub on which the speed of the motor will set.
speed - Speed of the motor -100..0..100 negative values will reverse the rotation.
time - Time in miliseconds for running the motor on the desired speed.
maximum - Power of the motor 0..100.
brakingStyle - Braking style how the motor will stop = Brake (default), Float, Hold.
Returns:
None
SetTachoMotorSpeedForDegrees(port As Byte, speed As int, degrees As long, maxPower As Byte, brakingStyle As Byte) As B4R::void
Set the motor speed on a defined port.
port - Port of the hub on which the speed of the motor will set (A, B, AB).
speed - Speed of the motor -100..0..100 negative values will reverse the rotation.
degrees - Till which rotation in degrees the motors should run.
maximum - Power of the motor 0..100 (default value=100).
brakingStyle - Braking style how the motor will stop. Brake (default), Float, Hold.
Returns:
None
SetTachoMotorSpeedsForDegrees(speedLeft As int, speedRight As int, degrees As long, maxPower As Byte, brakingStyle As Byte) As B4R::void
Set the speed of the hub motors (port A and B).
speedLeft - Speed of the left motor.
speedRight - Speed of the right motor.
degrees - Till which rotation in degrees the hub motors should run.
maximum - Power of the motor 0..100 (default value = 100).
brakingStyle - Braking style how the motor will stop = Brake (default), Float, Hold.
Returns:
None
SetAbsoluteMotorPosition(port As Byte, speed As int, position As long, maxPower As Byte, brakingStyle As Byte) As B4R::void
Set the motor absolute position on a defined port.
port - Port of the hub on which the speed of the motor will set (A, B, AB).
speed - Speed of the motor 0..100 = positive values only.
position - Position in degrees (relative to zero point on power up, or encoder reset) -2,147,483,648..0..2,147,483,647.
maximum - Power of the motor 0..100 (default value=100).
brakingStyle - Braking style how the motor will stop = Brake (default), Float, Hold.
Returns:
None
SetAbsoluteMotorEncoderPosition(port As Byte, position As long) As B4R::void
Set the motor encoded position on a defined port.
port - Port of the hub on which the speed of the motor will set (A, B, AB).
position - Position in degrees to encode (0=Reset) -2,147,483,648..0..2,147,483,647.
Returns:
None
SetMotorCalibration(port As Byte) As B4R::void
Calibrate the motor on a defined port.
This should be done once.
During calibration, approx 5 seconds, the LED turns orange and to yellow if finished.
port - Port of the hub the motor will calibrated (A, B, AB for Tacho motor; C or D for Basic motor).
Returns:
None
PlaySound(sound As Byte) As B4R::void
Play a predefined sound on the Duplo train hub.
sound - value. Could be set via the DuploTrainBaseSound enum.
Returns:
None
PlayTone(number As Byte) As B4R::void
Play a predefined tone on the Duplo train hub.
tone - value. Different bieps on different number 0..10 Which number is which.
beep is not really clear right now.
Returns:
None
ShutDownHub As B4R::void
Send shutdown command to the hub.
Returns:
None