diff --git a/Adafruit_BBIO/sysfs.py b/Adafruit_BBIO/sysfs.py index 43fd078..f2273a1 100644 --- a/Adafruit_BBIO/sysfs.py +++ b/Adafruit_BBIO/sysfs.py @@ -41,7 +41,7 @@ # Print all block devices in /sys, with their sizes for block_dev in sys.block: - print block_dev, str(int(block_dev.size) / 1048576) + ' M' + print(block_dev, str(int(block_dev.size) / 1048576) + ' M') >>> import sysfs >>> # Read/write Beaglebone Black's eQEP module attributes diff --git a/README.md b/README.md index d3ddf1a..cc179c2 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ Detecting events: #your amazing code here #detect wherever: if GPIO.event_detected("P9_12"): - print "event detected!" + print("event detected!") ### PWM **The PWM Duty Cycle range was reversed in 0.0.15 from 100(off)-0(on) to 0(off)-100(on). Please update your code accordingly.** @@ -198,13 +198,10 @@ import serial UART.setup("UART1") -ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600) -ser.close() -ser.open() -if ser.isOpen(): - print "Serial is open!" - ser.write("Hello World!") -ser.close() +with serial.Serial(port = "/dev/ttyO1", baudrate=9600) as ser: + print("Serial is open!") + ser.write(b"Hello World!") + ``` * Available UART names on BeagleBone * `UART1`: /dev/ttyO1, Rx: P9_26, Tx: P9_24 diff --git a/docs/UART.rst b/docs/UART.rst index 3566803..c3d238d 100644 --- a/docs/UART.rst +++ b/docs/UART.rst @@ -14,13 +14,9 @@ Example:: UART.setup("UART1") - ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600) - ser.close() - ser.open() - if ser.isOpen(): - print "Serial is open!" - ser.write("Hello World!") - ser.close() + with serial.Serial(port = "/dev/ttyO1", baudrate=9600) as ser: + print("Serial is open!") + ser.write(b"Hello World!") .. module:: Adafruit_BBIO.UART diff --git a/source/examples/python/i2ctmp101.py b/source/examples/python/i2ctmp101.py index 923c0f9..ab916c0 100755 --- a/source/examples/python/i2ctmp101.py +++ b/source/examples/python/i2ctmp101.py @@ -8,5 +8,5 @@ while True: temp = bus.read_byte_data(address, 0) - print (temp, end="\r") + print(temp, end="\r") time.sleep(0.25) diff --git a/test/notes/spi_loopback_test.md b/test/notes/spi_loopback_test.md index 0f93d0c..7041852 100644 --- a/test/notes/spi_loopback_test.md +++ b/test/notes/spi_loopback_test.md @@ -46,7 +46,7 @@ from Adafruit_BBIO.SPI import SPI #spi = SPI(1,1) #/dev/spidev2.1 spi = SPI(0,0) -print spi.xfer2([32, 11, 110, 22, 220]) +print(spi.xfer2([32, 11, 110, 22, 220])) spi.close() ``` diff --git a/test/start_all_pwm.py b/test/start_all_pwm.py index 58d02f5..f19ef97 100644 --- a/test/start_all_pwm.py +++ b/test/start_all_pwm.py @@ -20,7 +20,7 @@ # /sys/devices/platform/ocp/48304000.epwmss/48304100.ecap/pwm/pwmchip5/pwm-5:0/duty_cycle for pin in pins: - print pin + print(pin) PWM.start(pin, 50, 2000, 1) PWM.stop(pin) PWM.cleanup() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy