pynq.lib.arduino Package

The pynq.lib.arduino package is a collection of drivers for controlling peripherals attached to an Arduino pin interface. The Arduino interface can control Arduino peripherals or Grove peripherals (via the PYNQ Grove shield)

pynq.lib.arduino.arduino_analog Module

class pynq.lib.arduino.arduino_analog.Arduino_Analog(mb_info, gr_pin)[source]

Bases: object

This class controls the Arduino Analog.

XADC is an internal analog controller in the hardware. This class provides API to do analog reads from IOP.

microblaze

Microblaze processor instance used by this module.

Type:Arduino
log_running

The state of the log (0: stopped, 1: started).

Type:int
log_interval_ms

Time in milliseconds between samples on the same channel.

Type:int
gr_pin

A group of pins on arduino-grove shield.

Type:list
num_channels

The number of channels sampled.

Type:int
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 analog device.
Return type:list
read()[source]

Read the voltage value from the analog peripheral.

Returns:The float values after translation.
Return type:list
read_raw()[source]

Read the analog raw value from the analog peripheral.

Returns:The raw values from the analog device.
Return type:list
reset()[source]

Resets the system monitor for analog devices.

Returns:
Return type:None
set_log_interval_ms(log_interval_ms)[source]

Set the length of the log for the analog 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 writing to the MMIO.

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 writing to the MMIO.

Returns:
Return type:None
stop_log()[source]

Stop recording the voltage values in the log.

This can be done by calling the stop_log_raw() method.

Returns:
Return type:None
stop_log_raw()[source]

Stop recording the raw values in the log.

Simply write 0xC to the MMIO to stop the log.

Returns:
Return type:None

pynq.lib.arduino.arduino_grove_adc Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
log_running

The state of the log (0: stopped, 1: started).

Type:int
log_interval_ms

Time in milliseconds between sampled reads.

Type:int
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
reset()[source]

Resets/initializes the ADC.

Returns:
Return type:None
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
stop_log()[source]

Stop recording the voltage values in the log.

Simply send the command 0xC to stop the log.

Returns:
Return type:None
stop_log_raw()[source]

Stop recording the raw values in the log.

Simply send the command 0xC to stop the log.

Returns:
Return type:None

pynq.lib.arduino.arduino_grove_buzzer Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
play_melody()[source]

Play a melody.

Returns:
Return type:None
play_tone(tone_period, num_cycles)[source]

Play a single tone with tone_period for num_cycles

Parameters:
  • tone_period (int) – The period of the tone in microsecond.
  • num_cycles (int) – The number of cycles for the tone to be played.
Returns:

Return type:

None

pynq.lib.arduino.arduino_grove_ear_hr Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
read()[source]

Read the heart rate from the sensor.

Returns:The heart rate as beats per minute
Return type:float
read_raw()[source]

Read the number of heart beats.

Read the number of beats since the sensor initialization; also read the time elapsed in ms between the latest two heart beats.

Returns:Number of heart beats and the time elapsed between 2 latest beats.
Return type:tuple

pynq.lib.arduino.arduino_grove_finger_hr Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
log_running

The state of the log (0: stopped, 1: started).

Type:int
log_interval_ms

Time in milliseconds between sampled reads.

Type:int
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
start_log(log_interval_ms=100)[source]

Start recording multiple heart rate values in a log.

This method will first call set the log interval before writing to the MMIO.

Parameters:log_interval_ms (int) – The time between two samples in milliseconds.
Returns:
Return type:None
stop_log()[source]

Stop recording the values in the log.

Simply write 0xC to the MMIO to stop the log.

Returns:
Return type:None

pynq.lib.arduino.arduino_grove_haptic_motor Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
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
stop()[source]

Stop an effect or a sequence on the motor peripheral.

Returns:
Return type:None

pynq.lib.arduino.arduino_grove_imu Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
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_altitude()[source]

Get the current altitude.

Returns:The altitude value.
Return type:float
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
get_tilt_heading()[source]

Get the value of the tilt heading.

Returns:The tilt heading value.
Return type:float
reset()[source]

Reset all the sensors on the grove IMU.

Returns:
Return type:None

pynq.lib.arduino.arduino_grove_ledbar Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
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.arduino.arduino_grove_light Module

class pynq.lib.arduino.arduino_grove_light.Grove_Light(mb_info, gr_pin)[source]

Bases: pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
log_running

The state of the log (0: stopped, 1: started).

Type:int
log_interval_ms

Time in milliseconds between sampled reads.

Type:int
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
start_log()[source]

Start recording the light sensor resistance in a log.

This method will call the start_log_raw() in the parent class.

Returns:
Return type:None
stop_log()[source]

Stop recording light values in a log.

This method will call the stop_log_raw() in the parent class.

Returns:
Return type:None

pynq.lib.arduino.arduino_grove_oled Module

class pynq.lib.arduino.arduino_grove_oled.Grove_OLED(mb_info, gr_pin)[source]

Bases: object

This class controls the Grove IIC OLED.

Grove LED 128x64 Display module is an OLED monochrome 128x64 matrix display module. Model: OLE35046P. Hardware version: v1.1.

microblaze

Microblaze processor instance used by this module.

Type:Arduino
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
set_horizontal_mode()[source]

Set the display mode to horizontal.

Returns:
Return type:None
set_inverse_mode()[source]

Set the display mode to inverse.

Returns:
Return type:None
set_normal_mode()[source]

Set the display mode to normal.

Returns:
Return type:None
set_page_mode()[source]

Set the display mode to paged.

Returns:
Return type:None
set_position(row, column)[source]

Set the position of the display.

The position is indicated by (row, column).

Parameters:
  • row (int) – The row number to start the display.
  • column (int) – The column number to start the display.
Returns:

Return type:

None

write(text)[source]

Write a new text string on the OLED.

Clear the screen first to correctly show the new text.

Parameters:text (str) – The text string to be displayed on the OLED screen.
Returns:
Return type:None

pynq.lib.arduino.arduino_grove_pir Module

class pynq.lib.arduino.arduino_grove_pir.Grove_PIR(mb_info, gr_pin)[source]

Bases: pynq.lib.arduino.arduino_io.Arduino_IO

This class controls the PIR motion sensor.

Hardware version: v1.2.

microblaze

Microblaze processor instance used by this module.

Type:Arduino
read()[source]

Receive the value from the PIR sensor.

Returns 0 when there is no motion, and returns 1 otherwise.

Returns:The data (0 or 1) read from the PIR sensor.
Return type:int

pynq.lib.arduino.arduino_grove_th02 Module

class pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
log_running

The state of the log (0: stopped, 1: started).

Type:int
log_interval_ms

Time in milliseconds between sampled reads.

Type:int
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
start_log(log_interval_ms=100)[source]

Start recording multiple heart rate values in a log.

This method will first call set the log interval before sending the command.

Parameters:log_interval_ms (int) – The time between two samples in milliseconds.
Returns:
Return type:None
stop_log()[source]

Stop recording the values in the log.

Simply send the command 0xC to stop the log.

Returns:
Return type:None

pynq.lib.arduino.arduino_grove_tmp Module

class pynq.lib.arduino.arduino_grove_tmp.Grove_TMP(mb_info, gr_pin, version='v1.2')[source]

Bases: pynq.lib.arduino.arduino_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

Microblaze processor instance used by this module.

Type:Arduino
log_running

The state of the log (0: stopped, 1: started).

Type:int
log_interval_ms

Time in milliseconds between sampled reads.

Type:int
bValue

The thermistor constant.

Type:int
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
start_log()[source]

Start recording temperature in a log.

This method will call the start_log_raw() in the parent class.

stop_log()[source]

Stop recording temperature in a log.

This method will call the stop_log_raw() in the parent class.

Returns:
Return type:None

pynq.lib.arduino.arduino_io Module

class pynq.lib.arduino.arduino_io.Arduino_IO(mb_info, index, direction)[source]

Bases: object

This class controls the Arduino 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.

Note

The index of the Arduino pins: upper row, from right to left: {0, 1, …, 13}. (D0 - D13) lower row, from left to right: {14, 15,…, 19}. (A0 - A5)

microblaze

Microblaze processor instance used by this module.

Type:Arduino
index

The index of the Arduino pin, from 0 to 19.

Type:int
direction

Input ‘in’ or output ‘out’.

Type:str
read()[source]

Receive the value from the offboard Arduino IO device.

Note

Only use this function when direction is ‘in’.

Returns:The data (0 or 1) on the specified Arduino IO pin.
Return type:int
singleton_instance = None
write(value)[source]

Send the value to the offboard Arduino IO device.

Note

Only use this function when direction is ‘out’.

Parameters:value (int) – The value to be written to the Arduino IO device.
Returns:
Return type:None

pynq.lib.arduino.arduino_lcd18 Module

class pynq.lib.arduino.arduino_lcd18.Arduino_LCD18(mb_info)[source]

Bases: object

This class controls the Adafruit 1.8” LCD shield from AdaFruit.

The LCD panel consists of ST7735 LCD controller, a joystick, and a microSD socket. This class uses the LCD panel (128x160 pixels) and the joystick. The joystick uses A3 analog channel. https://www.adafruit.com/product/802.

microblaze

Microblaze processor instance used by this module.

Type:Arduino
buf_manager

DDR management unit that provides the physical address of the image.

Type:Xlnk
clear()[source]

Clear the screen.

Returns:
Return type:None
display(img_path, x_pos=0, y_pos=127, orientation=3, background=None, frames=1)[source]

Animate the image at the desired location for multiple frames.

The maximum screen resolution is 160x128.

Users can specify the position to display the image. For example, to display the image in the center, x_pos can be (160-width/2), y_pos can be (128/2)+(height/2).

A typical orientation is 3. The origin of orientation 0, 1, 2, and 3 corresponds to upper right corner, lower right corner, lower left corner, and upper left corner, respectively. Currently, only 1 and 3 are valid orientations. If users choose orientation 1, the picture will be shown upside-down. If users choose orientation 3, the picture will be shown consistently with the LCD screen orientation.

Parameter background specifies the color of the background; it is a list of 3 elements: R, G, and B, each with 8 bits for color level.

Parameters:
  • img_path (str) – The file path to the image stored in the file system.
  • x_pos (int) – x position of a pixel where the image starts.
  • y_pos (int) – y position of a pixel where the image starts.
  • background (list) – A list of [R, G, B] components for background, each of 8 bits.
  • orientation (int) – orientation of the image; valid values are 1 and 3.
  • frames (int) – Number of frames the image is moved, must be less than 65536.
Returns:

Return type:

None

display_async(img_path, x_pos=0, y_pos=127, orientation=3, background=None, frames=1)[source]

Animate the image at the desired location for multiple frames.

The maximum screen resolution is 160x128.

Users can specify the position to display the image. For example, to display the image in the center, x_pos can be (160-width/2), y_pos can be (128/2)+(height/2).

A typical orientation is 3. The origin of orientation 0, 1, 2, and 3 corresponds to upper right corner, lower right corner, lower left corner, and upper left corner, respectively. Currently, only 1 and 3 are valid orientations. If users choose orientation 1, the picture will be shown upside-down. If users choose orientation 3, the picture will be shown consistently with the LCD screen orientation.

Parameter background specifies the color of the background; it is a list of 3 elements: R, G, and B, each with 8 bits for color level.

Parameters:
  • img_path (str) – The file path to the image stored in the file system.
  • x_pos (int) – x position of a pixel where the image starts.
  • y_pos (int) – y position of a pixel where the image starts.
  • background (list) – A list of [R, G, B] components for background, each of 8 bits.
  • orientation (int) – orientation of the image; valid values are 1 and 3.
  • frames (int) – Number of frames the image is moved, must be less than 65536.
Returns:

Return type:

None

draw_filled_rectangle(x_start_pos, y_start_pos, width, height, color=None, background=None, orientation=3)[source]

Draw a filled rectangle.

Parameter color specifies the color of the text; it is a list of 3 elements: R, G, and B, each with 8 bits for color level.

Parameter background is similar to parameter color, except that it specifies the background color.

A typical orientation is 3. The origin of orientation 0, 1, 2, and 3 corresponds to upper right corner, lower right corner, lower left corner, and upper left corner, respectively. Currently, only 1 and 3 are valid orientations. If users choose orientation 1, the picture will be shown upside-down. If users choose orientation 3, the picture will be shown consistently with the LCD screen orientation.

Parameters:
  • x_start_pos (int) – x position (in pixels) where the rectangle starts.
  • y_start_pos (int) – y position (in pixels) where the rectangle starts.
  • width (int) – Width of the rectangle (in pixels).
  • height (int) – Height of the rectangle (in pixels).
  • color (list) – A list of [R, G, B] components for line color, each of 8 bits.
  • background (list) – A list of [R, G, B] components for background, each of 8 bits.
  • orientation (int) – orientation of the image; valid values are 1 and 3.
Returns:

Return type:

None

draw_line(x_start_pos, y_start_pos, x_end_pos, y_end_pos, color=None, background=None, orientation=3)[source]

Draw a line from starting point to ending point.

The maximum screen resolution is 160x128.

Parameter color specifies the color of the line; it is a list of 3 elements: R, G, and B, each with 8 bits for color level.

Parameter background is similar to parameter color, except that it specifies the background color.

A typical orientation is 3. The origin of orientation 0, 1, 2, and 3 corresponds to upper right corner, lower right corner, lower left corner, and upper left corner, respectively. Currently, only 1 and 3 are valid orientations. If users choose orientation 1, the picture will be shown upside-down. If users choose orientation 3, the picture will be shown consistently with the LCD screen orientation.

Parameters:
  • x_start_pos (int) – x position (in pixels) where the line starts.
  • y_start_pos (int) – y position (in pixels) where the line starts.
  • x_end_pos (int) – x position (in pixels ) where the line ends.
  • y_end_pos (int) – y position (in pixels) where the line ends.
  • color (list) – A list of [R, G, B] components for line color, each of 8 bits.
  • background (list) – A list of [R, G, B] components for background, each of 8 bits.
  • orientation (int) – orientation of the image; valid values are 1 and 3.
Returns:

Return type:

None

print_string(x_start_pos, y_start_pos, text, color=None, background=None, orientation=3)[source]

Draw a character with a specific color.

The maximum screen resolution is 160x128.

Parameter color specifies the color of the text; it is a list of 3 elements: R, G, and B, each with 8 bits for color level.

Parameter background is similar to parameter color, except that it specifies the background color.

A typical orientation is 3. The origin of orientation 0, 1, 2, and 3 corresponds to upper right corner, lower right corner, lower left corner, and upper left corner, respectively. Currently, only 1 and 3 are valid orientations. If users choose orientation 1, the picture will be shown upside-down. If users choose orientation 3, the picture will be shown consistently with the LCD screen orientation.

Parameters:
  • x_start_pos (int) – x position (in pixels) where the line starts.
  • y_start_pos (int) – y position (in pixels) where the line starts.
  • text (str) – printable ASCII characters.
  • color (list) – A list of [R, G, B] components for line color, each of 8 bits.
  • background (list) – A list of [R, G, B] components for background, each of 8 bits.
  • orientation (int) – orientation of the image; valid values are 1 and 3.
Returns:

Return type:

None

read_joystick()[source]

Read the joystick values.

The joystick values can be read when user is pressing the button toward a specific direction.

The returned values can be: 1: left; 2: down; 3: center; 4: right; 5: up; 0: no button pressed.

Returns:Indicating the direction towards which the button is pushed.
Return type:int