controllables.Vacuum
- class controllables.Vacuum(port: Optional[int] = None)
Reference to a vacuum part.
If a Vacuum is assigned to port
0
in the properties tab of the microcontroller, then that vacuum can be accessed withVacuum(0)
.- run(power: float = 1)
Runs the vacuum.
from controllables import Vacuum import time vacuum = Vacuum(0) vacuum.run() time.sleep(1) vacuum.stop()
- stop()
Stops running the vacuum.
Note
This doesn’t prevent transmitters or properties from running the vacuum.
from controllables import Vacuum import time vacuum = Vacuum(0) vacuum.run() time.sleep(1) vacuum.stop()
- flip()
Reverses the air flow of the vacuum from normal to reverse or vice versa.
from controllables import Vacuum import time vacuum = Vacuum(0) vacuum.run() while True: time.sleep(1) vacuum.flip()
- property max_power: float
The max power property of the vacuum avaliable in the properties tab.
In the below example, the property is displayed on a
TextScreen
. It assumes that the screen is on port0
and the vacuum is assigned to port1
.from controllables import TextScreen, Vacuum screen = TextScreen(0) vacuum = Vacuum(1) while True: screen.text = f'vacuum.max_power: {vacuum.max_power : 0.0f}'
In the next example the property is set to 0 on start up. It assumes that the vacuum is assigned to port
0
.from controllables import Vacuum Vacuum(0).max_power = 0
- is_flipped() bool
Whether the vacuum’s air flow has been flipped to reverse.
In the below example, the flipped status is displayed on a
TextScreen
. It assumes that the screen is on port0
and the vacuum is assigned to port1
.from controllables import TextScreen, Vacuum screen = TextScreen(0) vacuum = Vacuum(1) while True: screen.text = f'vacuum.is_flipped(): {vacuum.is_flipped()}'
- is_running() bool
Whether the vacuum is activated.
In the below example, the running status is displayed on a
TextScreen
. It assumes that the screen is on port0
and the vacuum is assigned to port1
.from controllables import TextScreen, Vacuum screen = TextScreen(0) vacuum = Vacuum(1) while True: screen.text = f'vacuum.is_running(): {vacuum.is_running()}'
- name() str
Returns the user editable name of the controllable as found in the properties tab of the game.
The following example assumes that any controllable or sensor is assigned to port
0
and prints out its name.from ports import PortReference print(PortReference(0).name())