Other classes¶
Leds —
-
class
ev3dev.ev3.Led(address=None, name_pattern='*', name_exact=False, **kwargs)¶ Any device controlled by the generic LED driver. See https://www.kernel.org/doc/Documentation/leds/leds-class.txt for more details.
-
brightness¶ Sets the brightness level. Possible values are from 0 to max_brightness.
-
brightness_pct¶ Returns led brightness as a fraction of max_brightness
-
delay_off¶ The timer trigger will periodically change the LED brightness between 0 and the current brightness setting. The off time can be specified via delay_off attribute in milliseconds.
-
delay_on¶ The timer trigger will periodically change the LED brightness between 0 and the current brightness setting. The on time can be specified via delay_on attribute in milliseconds.
-
max_brightness¶ Returns the maximum allowable brightness value.
-
trigger¶ Sets the led trigger. A trigger is a kernel based source of led events. Triggers can either be simple or complex. A simple trigger isn’t configurable and is designed to slot into existing subsystems with minimal additional code. Examples are the ide-disk and nand-disk triggers.
Complex triggers whilst available to all LEDs have LED specific parameters and work on a per LED basis. The timer trigger is an example. The timer trigger will periodically change the LED brightness between 0 and the current brightness setting. The on and off time can be specified via delay_{on,off} attributes in milliseconds. You can change the brightness value of a LED independently of the timer trigger. However, if you set the brightness value to 0 it will also disable the timer trigger.
-
triggers¶ Returns a list of available triggers.
-
-
class
ev3dev.ev3.Leds¶ The EV3 LEDs.
-
static
all_off()¶ Turn all leds off
-
static
set(group, **kwargs)¶ Set attributes for each led in group.
Example:
Leds.set(LEFT, brightness_pct=0.5, trigger='timer')
-
static
set_color(group, color, pct=1)¶ Sets brigthness of leds in the given group to the values specified in color tuple. When percentage is specified, brightness of each led is reduced proportionally.
Example:
Leds.set_color(LEFT, AMBER)
-
static
Power Supply¶
-
class
ev3dev.ev3.PowerSupply(address=None, name_pattern='*', name_exact=False, **kwargs)¶ A generic interface to read data from the system’s power_supply class. Uses the built-in legoev3-battery if none is specified.
-
max_voltage¶
-
measured_amps¶ The measured current that the battery is supplying (in amps)
-
measured_current¶ The measured current that the battery is supplying (in microamps)
-
measured_voltage¶ The measured voltage that the battery is supplying (in microvolts)
-
measured_volts¶ The measured voltage that the battery is supplying (in volts)
-
min_voltage¶
-
technology¶
-
type¶
-
Button¶
-
class
ev3dev.ev3.Button¶ EV3 Buttons
-
any()¶ Checks if any button is pressed.
-
backspace¶ Check if ‘backspace’ button is pressed.
Returns list of names of pressed buttons.
Check if currently pressed buttons exactly match the given list.
-
down¶ Check if ‘down’ button is pressed.
-
enter¶ Check if ‘enter’ button is pressed.
-
left¶ Check if ‘left’ button is pressed.
-
static
on_backspace(state)¶ This handler is called by process() whenever state of ‘backspace’ button has changed since last process() call. state parameter is the new state of the button.
-
on_change(changed_buttons)¶ This handler is called by process() whenever state of any button has changed since last process() call. changed_buttons is a list of tuples of changed button names and their states.
-
static
on_down(state)¶ This handler is called by process() whenever state of ‘down’ button has changed since last process() call. state parameter is the new state of the button.
-
static
on_enter(state)¶ This handler is called by process() whenever state of ‘enter’ button has changed since last process() call. state parameter is the new state of the button.
-
static
on_left(state)¶ This handler is called by process() whenever state of ‘left’ button has changed since last process() call. state parameter is the new state of the button.
-
static
on_right(state)¶ This handler is called by process() whenever state of ‘right’ button has changed since last process() call. state parameter is the new state of the button.
-
static
on_up(state)¶ This handler is called by process() whenever state of ‘up’ button has changed since last process() call. state parameter is the new state of the button.
-
process()¶ Check for currenly pressed buttons. If the new state differs from the old state, call the appropriate button event handlers.
-
right¶ Check if ‘right’ button is pressed.
-
up¶ Check if ‘up’ button is pressed.
-
Sound¶
-
class
ev3dev.ev3.Sound¶ Sound-related functions. The class has only static methods and is not intended for instantiation. It can beep, play wav files, or convert text to speech.
Note that all methods of the class spawn system processes and return subprocess.Popen objects. The methods are asynchronous (they return immediately after child process was spawned, without waiting for its completion), but you can call wait() on the returned result.
Examples:
# Play ‘bark.wav’, return immediately: Sound.play(‘bark.wav’)
# Introduce yourself, wait for completion: Sound.speak(‘Hello, I am Robot’).wait()
-
static
beep(args='')¶ Call beep command with the provided arguments (if any). See beep man page and google ‘linux beep music’ for inspiration.
-
static
play(wav_file)¶ Play wav file.
-
static
speak(text)¶ Speak the given text aloud.
-
static
tone(*args)¶ tone(tone_sequence):
Play tone sequence. The tone_sequence parameter is a list of tuples, where each tuple contains up to three numbers. The first number is frequency in Hz, the second is duration in milliseconds, and the third is delay in milliseconds between this and the next tone in the sequence.
Here is a cheerful example:
Sound.tone([ (392, 350, 100), (392, 350, 100), (392, 350, 100), (311.1, 250, 100), (466.2, 25, 100), (392, 350, 100), (311.1, 250, 100), (466.2, 25, 100), (392, 700, 100), (587.32, 350, 100), (587.32, 350, 100), (587.32, 350, 100), (622.26, 250, 100), (466.2, 25, 100), (369.99, 350, 100), (311.1, 250, 100), (466.2, 25, 100), (392, 700, 100), (784, 350, 100), (392, 250, 100), (392, 25, 100), (784, 350, 100), (739.98, 250, 100), (698.46, 25, 100), (659.26, 25, 100), (622.26, 25, 100), (659.26, 50, 400), (415.3, 25, 200), (554.36, 350, 100), (523.25, 250, 100), (493.88, 25, 100), (466.16, 25, 100), (440, 25, 100), (466.16, 50, 400), (311.13, 25, 200), (369.99, 350, 100), (311.13, 250, 100), (392, 25, 100), (466.16, 350, 100), (392, 250, 100), (466.16, 25, 100), (587.32, 700, 100), (784, 350, 100), (392, 250, 100), (392, 25, 100), (784, 350, 100), (739.98, 250, 100), (698.46, 25, 100), (659.26, 25, 100), (622.26, 25, 100), (659.26, 50, 400), (415.3, 25, 200), (554.36, 350, 100), (523.25, 250, 100), (493.88, 25, 100), (466.16, 25, 100), (440, 25, 100), (466.16, 50, 400), (311.13, 25, 200), (392, 350, 100), (311.13, 250, 100), (466.16, 25, 100), (392.00, 300, 150), (311.13, 250, 100), (466.16, 25, 100), (392, 700) ]).wait()
tone(frequency, duration):
Play single tone of given frequency (Hz) and duration (milliseconds).
-
static
Screen¶
-
class
ev3dev.ev3.Screen¶ Bases:
ev3dev.core.FbMemA convenience wrapper for the FbMem class. Provides drawing functions from the python imaging library (PIL).
-
clear()¶ Clears the screen
-
draw¶ Returns a handle to PIL.ImageDraw.Draw class associated with the screen.
Example:
screen.draw.rectangle((10,10,60,20), fill='black')
-
shape¶ Dimensions of the screen.
-
update()¶ Applies pending changes to the screen. Nothing will be drawn on the screen until this function is called.
-
xres¶ Horizontal screen resolution
-
yres¶ Vertical screen resolution
-