class
pylnlib.Throttle.
Throttle
(
scrollkeeper
, locaddress
)
A class to control a single locomotive.
Parameters
scrollkeeper
(Scrollkeeper) — used to send messages and retrieve slot informationlocaddress
(int) — the address of the locomotive
Methods
forward
(
speed
)
— Changes the speed of a locomotive to forward and a given value.</>lights
(
on
,duration
)
— Turn directional lights on or off.</>reverse
(
speed
)
— Changes the speed of a locomotive to reverse and a given value.</>sound
(
on
,duration
)
— Turn sound on or off.</>whistle
(
on
,duration
)
— Sound the whistle.</>
method
forward
(
speed=0.0
)
Changes the speed of a locomotive to forward and a given value.
Parameters
speed
(float, optional) — speed is a float in the range [0.0, 1.0], setting it to zero will initiate an inertial stop. Defaults to 0.0.
Two LocoNet messages may be generated:
- Only if the direction is changed: a LocoNet direction message is generated for the slot that controls this loco.
- Only if the speed is changed: a LocoNet speed message is generated for the slot that controls this loco.
method
reverse
(
speed=0.0
)
Changes the speed of a locomotive to reverse and a given value.
Parameters
speed
(float, optional) — speed is a float in the range [0.0, 1.0], setting it to zero will initiate an inertial stop. Defaults to 0.0.
Two LocoNet messages may be generated:
- Only if the direction is changed, a LocoNet direction message is generated for the slot that controls this loco.
- Only if the speed is changed, a LocoNet speed message is generated for the slot that controls this loco.
method
lights
(
on=True
, duration=0
)
Turn directional lights on or off.
Parameters
on
(bool, optional) — new state of the directional lights. Defaults to True.duration
(int, optional) — if larger than zero will revert the lights to the previous state after duration seconds. Defaults to 0.
method
sound
(
on=True
, duration=0
)
Turn sound on or off.
Parameters
on
(bool, optional) — new state of the sound. Defaults to True.duration
(int, optional) — if larger than zero will revert the sound to the previous state after duration seconds. Defaults to 0.
Returns
None
method
whistle
(
on=True
, duration=0.5
)
Sound the whistle.
A loc decoder will typically use a short whistle sound that is silent after a short while, but it still needs to be turned off explicitely by the throttle, therefore the function defaults to 0.5 seconds.
Parameters
on
(bool, optional) — new state of the whistle. Defaults to True.duration
(float, optional) — if larger than zero will revert the whistle to the previous state after duration seconds. Defaults to 0.5.