pynq.lib.pmod Package¶
The pynq.lib.pmod package is a collection of drivers for controlling peripherals attached to a PMOD port. The PMOD interface can control PMOD peripherals or Grove peripherals (via the PYNQ Grove shield)
pynq.lib.pmod.pmod_adc Module¶
-
class
pynq.lib.pmod.pmod_adc.
Pmod_ADC
(mb_info)[source]¶ Bases:
object
This class controls an Analog to Digital Converter Pmod.
The Pmod AD2 (PB 200-217) is an analog-to-digital converter powered by AD7991. Users may configure up to 4 conversion channels at 12 bits of resolution.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_running
¶ int – The state of the log (0: stopped, 1: started).
-
get_log
()[source]¶ Get the log of voltage values.
First stop the log before getting the log.
Returns: List of voltage samples from the ADC. Return type: list
-
get_log_raw
()[source]¶ Get the log of raw values.
First stop the log before getting the log.
Returns: List of raw samples from the ADC. Return type: list
-
read
(ch1=1, ch2=0, ch3=0)[source]¶ Get the voltage from the Pmod ADC.
When ch1, ch2, and ch3 values are 1 then the corresponding channel is included.
For each channel selected, this method reads and returns one sample.
Note
The 4th channel is not available due to the jumper setting on ADC.
Note
This method reads the voltage values from ADC.
Parameters: - ch1 (int) – 1 means include channel 1, 0 means do not include.
- ch2 (int) – 1 means include channel 2, 0 means do not include.
- ch3 (int) – 1 means include channel 3, 0 means do not include.
Returns: The voltage values read from the 3 channels of the Pmod ADC.
Return type: list
-
read_raw
(ch1=1, ch2=0, ch3=0)[source]¶ Get the raw value from the Pmod ADC.
When ch1, ch2, and ch3 values are 1 then the corresponding channel is included.
For each channel selected, this method reads and returns one sample.
Note
The 4th channel is not available due to the jumper (JP1) setting on ADC.
Note
This method reads the raw value from ADC.
Parameters: - ch1 (int) – 1 means include channel 1, 0 means do not include.
- ch2 (int) – 1 means include channel 2, 0 means do not include.
- ch3 (int) – 1 means include channel 3, 0 means do not include.
Returns: The raw values read from the 3 channels of the Pmod ADC.
Return type: list
-
start_log
(ch1=1, ch2=0, ch3=0, log_interval_us=100)[source]¶ Start the log of voltage values with the interval specified.
This parameter log_interval_us can set the time interval between two samples, so that users can read out multiple values in a single log.
Parameters: - ch1 (int) – 1 means include channel 1, 0 means do not include.
- ch2 (int) – 1 means include channel 2, 0 means do not include.
- ch3 (int) – 1 means include channel 3, 0 means do not include.
- log_interval_us (int) – The length of the log in milliseconds, for debug only.
Returns: Return type: None
-
start_log_raw
(ch1=1, ch2=0, ch3=0, log_interval_us=100)[source]¶ Start the log of raw values with the interval specified.
This parameter log_interval_us can set the time interval between two samples, so that users can read out multiple values in a single log.
Parameters: - ch1 (int) – 1 means include channel 1, 0 means do not include.
- ch2 (int) – 1 means include channel 2, 0 means do not include.
- ch3 (int) – 1 means include channel 3, 0 means do not include.
- log_interval_us (int) – The length of the log in milliseconds, for debug only.
Returns: Return type: None
-
pynq.lib.pmod.pmod_als Module¶
-
class
pynq.lib.pmod.pmod_als.
Pmod_ALS
(mb_info)[source]¶ Bases:
object
This class controls a light sensor Pmod.
The Digilent Pmod ALS demonstrates light-to-digital sensing through a single ambient light sensor. This is based on an ADC081S021 analog-to-digital converter and a TEMT6000X01 ambient light sensor.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
get_log
()[source]¶ Return list of logged samples.
Returns: Return type: List of valid samples from the ALS sensor [0-255]
-
read
()[source]¶ Read current light value measured by the ALS Pmod.
Returns: The current sensor value. Return type: int
-
set_log_interval_ms
(log_interval_ms)[source]¶ Set the length of the log in the ALS Pmod.
This method can set the length of the log, so that users can read out multiple values in a single log.
Parameters: log_interval_ms (int) – The length of the log in milliseconds, for debug only. Returns: Return type: None
-
pynq.lib.pmod.pmod_cable Module¶
-
class
pynq.lib.pmod.pmod_cable.
Pmod_Cable
(mb_info, index, direction, cable)[source]¶ Bases:
pynq.lib.pmod.pmod_io.Pmod_IO
This class can be used for a cable connecting Pmod interfaces.
This class inherits from the Pmod IO class.
Note
When 2 Pmods are connected using a cable, the parameter ‘cable’ decides whether the cable is a ‘loopback’ or ‘straight’ cable. The default is a straight cable (no internal wire twisting). For pin mapping, please check the Pmod IO class.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
index
¶ int – The index of the Pmod pin, from 0 to 7.
-
direction
¶ str – Input ‘in’ or output ‘out’.
-
cable
¶ str – Either ‘straight’ or ‘loopback’.
-
read
()[source]¶ Receive the value from the Pmod cable.
This method overrides the read() method in the Pmod IO class. There are no new write() method defined in this class, so the read() will be inherited from Pmod IO class.
Note
Only use this function when direction = ‘in’.
When two Pmods are connected on the same board, for any received raw value, a “straignt” cable flips the upper 4 pins and the lower 4 pins: A Pmod interface <=> Another Pmod interface {vdd,gnd,3,2,1,0} <=> {vdd,gnd,7,6,5,4} {vdd,gnd,7,6,5,4} <=> {vdd,gnd,3,2,1,0}
A “loop-back” cable satisfies the following mapping between two Pmods: A Pmod interface <=> Another Pmod interface {vdd,gnd,3,2,1,0} <=> {vdd,gnd,3,2,1,0} {vdd,gnd,7,6,5,4} <=> {vdd,gnd,7,6,5,4}
Returns: The data (0 or 1) on the specified Pmod IO pin. Return type: int
-
pynq.lib.pmod.pmod_dac Module¶
-
class
pynq.lib.pmod.pmod_dac.
Pmod_DAC
(mb_info, value=None)[source]¶ Bases:
object
This class controls a Digital to Analog Converter Pmod.
The Pmod DA4 (PB 200-245) is an 8 channel 12-bit digital-to-analog converter run via AD5628.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
pynq.lib.pmod.pmod_dpot Module¶
-
class
pynq.lib.pmod.pmod_dpot.
Pmod_DPOT
(mb_info)[source]¶ Bases:
object
This class controls a digital potentiometer Pmod.
The Pmod DPOT (PB 200-239) is a digital potentiometer powered by the AD5160. Users may set a desired resistance between 60 ~ 10k ohms.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
write
(val, step=0, log_ms=0)[source]¶ Write the value into the DPOT.
This method will write the parameters “value”, “step”, and “log_ms” all together into the DPOT Pmod. The parameter “log_ms” is only used for debug; users can ignore this parameter.
Parameters: - val (int) – The initial value to start, in [0, 255].
- step (int) – The number of steps when ramping up to the final value.
- log_ms (int) – The length of the log in milliseconds, for debug only.
Returns: Return type: None
-
pynq.lib.pmod.pmod_iic Module¶
-
class
pynq.lib.pmod.pmod_iic.
Pmod_IIC
(mb_info, scl_pin, sda_pin, iic_addr)[source]¶ Bases:
pynq.lib.pmod.pmod_devmode.Pmod_DevMode
This class controls the Pmod IIC pins.
Note
The index of the Pmod pins: upper row, from left to right: {vdd,gnd,3,2,1,0}. lower row, from left to right: {vdd,gnd,7,6,5,4}.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
scl_pin
¶ int – The SCL pin number.
-
sda_pin
¶ int – The SDA pin number.
-
iic_addr
¶ int – The IIC device address.
-
sr_addr
¶ int – The IIC device SR address (base address + 0x104).
-
dtr_addr
¶ int – The IIC device DTR address (base address + 0x108).
-
cr_addr
¶ int – The IIC device CR address (base address + 0x100).
-
rfd_addr
¶ int – The IIC device RFD address (base address + 0x120).
-
drr_addr
¶ int – The IIC device DRR address (base address + 0x10C).
-
receive
(num_bytes)[source]¶ This method receives IIC bytes from the device.
Parameters: num_bytes (int) – Number of bytes to be received from the device. Returns: iic_bytes – A list of 8-bit bytes received from the driver. Return type: list Raises: RuntimeError
– Timeout when waiting for the RX FIFO to fill.
-
pynq.lib.pmod.pmod_io Module¶
-
class
pynq.lib.pmod.pmod_io.
Pmod_IO
(mb_info, index, direction)[source]¶ Bases:
pynq.lib.pmod.pmod_devmode.Pmod_DevMode
This class controls the Pmod IO pins as inputs or outputs.
Note
The parameter ‘direction’ determines whether the instance is input/output: ‘in’ : receiving input from offchip to onchip. ‘out’ : sending output from onchip to offchip. The index of the Pmod pins: upper row, from left to right: {vdd,gnd,3,2,1,0}. lower row, from left to right: {vdd,gnd,7,6,5,4}.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
index
¶ int – The index of the Pmod pin, starting from 0.
-
direction
¶ str – Input ‘in’ or output ‘out’.
-
pynq.lib.pmod.pmod_led8 Module¶
-
class
pynq.lib.pmod.pmod_led8.
Pmod_LED8
(mb_info, index)[source]¶ Bases:
pynq.lib.pmod.pmod_devmode.Pmod_DevMode
This class controls a single LED on the LED8 Pmod.
The Pmod LED8 (PB 200-163) has eight high-brightness LEDs. Each LED can be individually illuminated from a logic high signal.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
iop_switch_config
¶ list – Microblaze processor IO switch configuration (8 integers).
-
index
¶ int – Index of the pin on LED8, starting from 0.
-
read
()[source]¶ Retrieve the LED state.
Returns: The data (0 or 1) read out from the selected pin. Return type: int
-
pynq.lib.pmod.pmod_oled Module¶
-
class
pynq.lib.pmod.pmod_oled.
Pmod_OLED
(mb_info, text=None)[source]¶ Bases:
object
This class controls an OLED Pmod.
The Pmod OLED (PB 200-222) is 128x32 pixel monochrome organic LED (OLED) panel powered by the Solomon Systech SSD1306.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
clear
()[source]¶ Clear the OLED screen.
This is done by sending the clear command to the IOP.
Returns: Return type: None
-
draw_line
(x1, y1, x2, y2)[source]¶ Draw a straight line on the OLED.
Parameters: - x1 (int) – The x-position of the starting point.
- y1 (int) – The y-position of the starting point.
- x2 (int) – The x-position of the ending point.
- y2 (int) – The y-position of the ending point.
Returns: Return type: None
-
pynq.lib.pmod.pmod_pwm Module¶
-
class
pynq.lib.pmod.pmod_pwm.
Pmod_PWM
(mb_info, index)[source]¶ Bases:
object
This class uses the PWM of the IOP.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
pynq.lib.pmod.pmod_tc1 Module¶
-
class
pynq.lib.pmod.pmod_tc1.
Pmod_TC1
(mb_info)[source]¶ Bases:
object
This class controls a thermocouple Pmod.
The Digilent PmodTC1 is a cold-junction thermocouple-to-digital converter module designed for a classic K-Type thermocouple wire. With Maxim Integrated’s MAX31855, this module reports the measured temperature in 14-bits with 0.25 degC resolution.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
get_log
()[source]¶ Return list of logged samples.
Note
The logged samples are raw 32-bit samples captured from the sensor.
Returns: List of valid samples from the TC1 sensor Return type: list
-
read_alarm_flags
()[source]¶ Read the alarm flags from the raw value.
Returns: The alarm flags from the TC1. bit 0 = 1 if thermocouple connection is open-circuit; bit 1 = 1 if thermocouple connection is shorted to generated; bit 2 = 1 if thermocouple connection is shorted to VCC; bit 16 = 1 if any if bits 0-2 are 1. Return type: u32
-
read_junction_temperature
()[source]¶ Read the reference junction temperature.
Returns: The reference junction temperature in degC. Return type: float
-
read_raw
()[source]¶ Read full 32-bit register of TC1 Pmod.
Returns: The current register contents. Return type: int
-
read_thermocouple_temperature
()[source]¶ Read the reference junction temperature.
Returns: The thermocouple temperature in degC. Return type: float
-
set_log_interval_ms
(log_interval_ms)[source]¶ Set the length of the log in the TC1 Pmod.
This method can set the length of the log, so that users can read out multiple values in a single log.
Parameters: log_interval_ms (int) – The length of the log in milliseconds, for debug only. Returns: Return type: None
-
-
pynq.lib.pmod.pmod_tc1.
reg_to_alarms
(reg_val)[source]¶ Extracts Alarm flags from 32-bit register value.
Parameters: reg_val (int) – 32-bit TC1 register value Returns: The alarm flags from the TC1. bit 0 = 1 if thermocouple connection is open-circuit; bit 1 = 1 if thermocouple connection is shorted to generated; bit 2 = 1 if thermocouple connection is shorted to VCC; bit 16 = 1 if any if bits 0-2 are 1. Return type: u32
pynq.lib.pmod.pmod_timer Module¶
-
class
pynq.lib.pmod.pmod_timer.
Pmod_Timer
(mb_info, index)[source]¶ Bases:
object
This class uses the timer’s capture and generation capabilities.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
clk_period_ns
¶ int – The clock period of the IOP in ns.
-
event_count
(period)[source]¶ Count the number of rising edges detected in (period) clocks.
Parameters: period (int) – The period of the generated signals. Returns: The number of events detected. Return type: int
-
event_detected
(period)[source]¶ Detect a rising edge or high-level in (period) clocks.
Parameters: period (int) – The period of the generated signals. Returns: 1 if any event is detected, and 0 if no event is detected. Return type: int
-
generate_pulse
(period, times=0)[source]¶ Generate pulses every (period) clocks for a number of times.
The default is to generate pulses every (period) IOP clocks forever until stopped. The pulse width is equal to the IOP clock period.
Parameters: - period (int) – The period of the generated signals.
- times (int) – The number of times for which the pulses are generated.
Returns: Return type: None
-
pynq.lib.pmod.pmod_tmp2 Module¶
-
class
pynq.lib.pmod.pmod_tmp2.
Pmod_TMP2
(mb_info)[source]¶ Bases:
object
This class controls a temperature sensor Pmod.
The Pmod TMP2 (PB 200-221) is an ambient temperature sensor powered by ADT7420.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
get_log
()[source]¶ Return list of logged samples.
Returns: Return type: List of valid samples from the temperature sensor in Celsius.
-
read
()[source]¶ Read current temperature value measured by the Pmod TMP2.
Returns: The current sensor value. Return type: float
-
set_log_interval_ms
(log_interval_ms)[source]¶ Set the sampling interval for the Pmod TMP2.
Parameters: log_interval_ms (int) – Time in milliseconds between sampled reads of the TMP2 sensor Returns: Return type: None
-
pynq.lib.pmod.pmod_grove_adc Module¶
-
class
pynq.lib.pmod.pmod_grove_adc.
Grove_ADC
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove IIC ADC.
Grove ADC is a 12-bit precision ADC module based on ADC121C021. Hardware version: v1.2.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_running
¶ int – The state of the log (0: stopped, 1: started).
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
get_log
()[source]¶ Return list of logged samples.
Returns: List of valid voltage samples (floats) from the ADC sensor. Return type: list
-
get_log_raw
()[source]¶ Return list of logged raw samples.
Returns: List of valid raw samples from the ADC sensor. Return type: list
-
read
()[source]¶ Read the ADC voltage from the Grove ADC peripheral.
Returns: The float value after translation. Return type: float
-
read_raw
()[source]¶ Read the ADC raw value from the Grove ADC peripheral.
Returns: The raw value from the sensor. Return type: int
-
set_log_interval_ms
(log_interval_ms)[source]¶ Set the length of the log for the Grove ADC peripheral.
This method can set the time interval between two samples, so that users can read out multiple values in a single log.
Parameters: log_interval_ms (int) – The time between two samples in milliseconds, for logging only. Returns: Return type: None
-
start_log
()[source]¶ Start recording multiple voltage values (float) in a log.
This method will first call set_log_interval_ms() before sending the command.
Returns: Return type: None
-
start_log_raw
()[source]¶ Start recording raw data in a log.
This method will first call set_log_interval_ms() before sending the command.
Returns: Return type: None
-
pynq.lib.pmod.pmod_grove_buzzer Module¶
-
class
pynq.lib.pmod.pmod_grove_buzzer.
Grove_Buzzer
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove Buzzer.
The grove buzzer module has a piezo buzzer as the main component. The piezo can be connected to digital outputs, and will emit a tone when the output is HIGH. Alternatively, it can be connected to an analog pulse-width modulation output to generate various tones and effects. Hardware version: v1.2.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
pynq.lib.pmod.pmod_grove_color Module¶
pynq.lib.pmod.pmod_grove_dlight Module¶
-
class
pynq.lib.pmod.pmod_grove_dlight.
Grove_Dlight
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove IIC color sensor.
Grove Color sensor based on the TCS3414CS. Hardware version: v1.3.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
pynq.lib.pmod.pmod_grove_ear_hr Module¶
-
class
pynq.lib.pmod.pmod_grove_ear_hr.
Grove_EarHR
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove ear clip heart rate sensor.
Sensor model: MED03212P.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
pynq.lib.pmod.pmod_grove_finger_hr Module¶
-
class
pynq.lib.pmod.pmod_grove_finger_hr.
Grove_FingerHR
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove finger clip heart rate sensor.
Grove Finger sensor based on the TCS3414CS. Hardware version: v1.3.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_running
¶ int – The state of the log (0: stopped, 1: started).
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
get_log
()[source]¶ Return list of logged samples.
Returns: List of integers containing the heart rate. Return type: list
-
read
()[source]¶ Read the heart rate value from the Grove Finger HR peripheral.
Returns: An integer representing the heart rate frequency. Return type: int
-
pynq.lib.pmod.pmod_grove_haptic_motor Module¶
-
class
pynq.lib.pmod.pmod_grove_haptic_motor.
Grove_HapticMotor
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove Haptic Motor based on the DRV2605L. Hardware version v0.9.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
is_playing
()[source]¶ Check if a vibration effect is running on the motor.
Returns: True if a vibration effect is playing, false otherwise Return type: bool
-
play
(effect)[source]¶ Play a vibration effect on the Grove Haptic Motor peripheral.
Valid effect identifiers are in the range [1, 127].
Parameters: effect (int) – An integer that specifies the effect. Returns: Return type: None
-
play_sequence
(sequence)[source]¶ Play a sequence of effects possibly separated by pauses.
At most 8 effects or pauses can be specified at a time. Pauses are defined using negative integer values in the range [-1, -127] that correspond to a pause length in the range [10, 1270] ms
Valid effect identifiers are in the range [1, 127]
As an example, in the following sequence example: [4,-20,5] effect 4 is played and after a pause of 200 ms effect 5 is played
Parameters: sequence (list) – At most 8 values specifying effects and pauses. Returns: Return type: None
-
pynq.lib.pmod.pmod_grove_imu Module¶
-
class
pynq.lib.pmod.pmod_grove_imu.
Grove_IMU
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove IIC IMU.
Grove IMU 10DOF is a combination of grove IMU 9DOF (MPU9250) and grove barometer sensor (BMP180). MPU-9250 is a 9-axis motion tracking device that combines a 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer and a Digital Motion Processor (DMP). BMP180 is a high precision, low power digital pressure sensor. Hardware version: v1.1.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
get_accl
()[source]¶ Get the data from the accelerometer.
Returns: A list of the acceleration data along X-axis, Y-axis, and Z-axis. Return type: list
-
get_atm
()[source]¶ Get the current pressure in relative atmosphere.
Returns: The related atmosphere. Return type: float
-
get_compass
()[source]¶ Get the data from the magnetometer.
Returns: A list of the compass data along X-axis, Y-axis, and Z-axis. Return type: list
-
get_gyro
()[source]¶ Get the data from the gyroscope.
Returns: A list of the gyro data along X-axis, Y-axis, and Z-axis. Return type: list
-
get_heading
()[source]¶ Get the value of the heading.
Returns: The angle deviated from the X-axis, toward the positive Y-axis. Return type: float
-
get_pressure
()[source]¶ Get the current pressure in Pa.
Returns: The pressure value. Return type: float
-
get_temperature
()[source]¶ Get the current temperature in degree C.
Returns: The temperature value. Return type: float
-
pynq.lib.pmod.pmod_grove_ledbar Module¶
-
class
pynq.lib.pmod.pmod_grove_ledbar.
Grove_LEDbar
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove LED BAR.
Grove LED Bar is comprised of a 10 segment LED gauge bar and an MY9221 LED controlling chip. Model: LED05031P. Hardware version: v2.0.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
read
()[source]¶ Reads the current status of LEDbar.
Reads the current status of LED bar and returns 10-bit binary string. Each bit position corresponds to a LED position in the LEDbar, and bit value corresponds to the LED state.
Red LED corresponds to the LSB, while green LED corresponds to the MSB.
Returns: String of 10 binary bits. Return type: str
-
reset
()[source]¶ Resets the LEDbar.
Clears the LED bar, sets all LEDs to OFF state.
Returns: Return type: None
-
write_binary
(data_in)[source]¶ Set individual LEDs in the LEDbar based on 10 bit binary input.
Each bit in the 10-bit data_in points to a LED position on the LEDbar. Red LED corresponds to the LSB, while green LED corresponds to the MSB.
Parameters: data_in (int) – 10 LSBs of this parameter control the LEDbar. Returns: Return type: None
-
write_brightness
(data_in, brightness=[170, 170, 170, 170, 170, 170, 170, 170, 170, 170])[source]¶ Set individual LEDs with 3 level brightness control.
Each bit in the 10-bit data_in points to a LED position on the LEDbar. Red LED corresponds to the LSB, while green LED corresponds to the MSB.
Brightness of each LED is controlled by the brightness parameter. There are 3 perceivable levels of brightness: 0xFF : HIGH 0xAA : MED 0x01 : LOW
Parameters: - data_in (int) – 10 LSBs of this parameter control the LEDbar.
- brightness (list) – Each element controls a single LED.
Returns: Return type: None
-
write_level
(level, bright_level, green_to_red)[source]¶ Set the level to which the leds are to be lit in levels 1 - 10.
Level can be set in both directions. set_level operates by setting all LEDs to the same brightness level.
There are 4 preset brightness levels: bright_level = 0: off bright_level = 1: low bright_level = 2: medium bright_level = 3: maximum
green_to_red indicates the direction, either from red to green when it is 0, or green to red when it is 1.
Parameters: - level (int) – 10 levels exist, where 1 is minimum and 10 is maximum.
- bright_level (int) – Controls brightness of all LEDs in the LEDbar, from 0 to 3.
- green_to_red (int) – Sets the direction of the sequence.
Returns: Return type: None
-
pynq.lib.pmod.pmod_grove_light Module¶
-
class
pynq.lib.pmod.pmod_grove_light.
Grove_Light
(mb_info, gr_pin)[source]¶ Bases:
pynq.lib.pmod.pmod_grove_adc.Grove_ADC
This class controls the grove light sensor.
This class inherits from the grove ADC class. To use this module, grove ADC has to be used as a bridge. The light sensor incorporates a Light Dependent Resistor (LDR) GL5528. Hardware version: v1.1.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_running
¶ int – The state of the log (0: stopped, 1: started).
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
get_log
()[source]¶ Return list of logged light sensor resistances.
Returns: List of valid light sensor resistances. Return type: list
-
read
()[source]¶ Read the light sensor resistance in from the light sensor.
This method overrides the definition in grove ADC.
Returns: The light reading in terms of the sensor resistance. Return type: float
-
pynq.lib.pmod.pmod_grove_oled Module¶
-
class
pynq.lib.pmod.pmod_grove_oled.
Grove_OLED
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove IIC OLED.
Grove LED 128×64 Display module is an OLED monochrome 128×64 matrix display module. Model: OLE35046P. Hardware version: v1.1.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
clear
()[source]¶ Clear the OLED screen.
This is done by writing empty strings into the OLED in Microblaze.
Returns: Return type: None
-
set_contrast
(brightness)[source]¶ Set the contrast level for the OLED display.
The contrast level is in [0, 255].
Parameters: brightness (int) – The brightness of the display. Returns: Return type: None
-
pynq.lib.pmod.pmod_grove_pir Module¶
-
class
pynq.lib.pmod.pmod_grove_pir.
Grove_PIR
(mb_info, gr_pin)[source]¶ Bases:
pynq.lib.pmod.pmod_io.Pmod_IO
This class controls the PIR motion sensor.
Hardware version: v1.2.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
index
¶ int – The index of the Pmod pin, from 0 to 7.
-
direction
¶ str – Can only be ‘in’ for PIR sensor.
-
pynq.lib.pmod.pmod_grove_th02 Module¶
-
class
pynq.lib.pmod.pmod_grove_th02.
Grove_TH02
(mb_info, gr_pin)[source]¶ Bases:
object
This class controls the Grove I2C Temperature and Humidity sensor.
Temperature & humidity sensor (high-accuracy & mini). Hardware version: v1.0.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_running
¶ int – The state of the log (0: stopped, 1: started).
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
get_log
()[source]¶ Return list of logged samples.
Returns: List of tuples containing (temperature, humidity) Return type: list
-
read
()[source]¶ Read the temperature and humidity values from the TH02 peripheral.
Returns: Tuple containing (temperature, humidity) Return type: tuple
-
pynq.lib.pmod.pmod_grove_tmp Module¶
-
class
pynq.lib.pmod.pmod_grove_tmp.
Grove_TMP
(mb_info, gr_pin, version='v1.2')[source]¶ Bases:
pynq.lib.pmod.pmod_grove_adc.Grove_ADC
This class controls the grove temperature sensor.
This class inherits from the Grove_ADC class. To use this module, grove ADC has to be used as a bridge. The temperature sensor uses a thermistor to detect the ambient temperature. Hardware version: v1.2.
-
microblaze
¶ Pmod – Microblaze processor instance used by this module.
-
log_running
¶ int – The state of the log (0: stopped, 1: started).
-
log_interval_ms
¶ int – Time in milliseconds between sampled reads.
-
bValue
¶ int – The thermistor constant.
-
get_log
()[source]¶ Return list of logged temperature samples.
Returns: List of valid temperature readings from the temperature sensor. Return type: list
-
read
()[source]¶ Read temperature values in Celsius from temperature sensor.
This method overrides the definition in Grove_ADC.
Returns: The temperature reading in Celsius. Return type: float
-