diff options
| author | microDev <70126934+microDev1@users.noreply.github.com> | 2021-03-15 19:27:36 +0530 |
|---|---|---|
| committer | microDev <70126934+microDev1@users.noreply.github.com> | 2021-03-15 19:27:36 +0530 |
| commit | a52eb88031620a81521b937f2a0651dbac2bb350 (patch) | |
| tree | 017cbf8f686b252241182ef61ce48e8457aa1577 /tests/circuitpython-manual | |
| parent | 090b6ba42fcdfbb16844f77892087f91aa6ea201 (diff) | |
run code formatting script
Diffstat (limited to 'tests/circuitpython-manual')
9 files changed, 21 insertions, 28 deletions
diff --git a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py index c0ee5de31..8b40e916d 100644 --- a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py +++ b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py @@ -24,8 +24,7 @@ for i in range(length): sample = audiocore.RawSample(s16, sample_rate=8000) -dac = audiobusio.I2SOut(bit_clock=board.D10, - word_select=board.D11, data=board.D12) +dac = audiobusio.I2SOut(bit_clock=board.D10, word_select=board.D11, data=board.D12) trigger.value = False dac.play(sample, loop=True) diff --git a/tests/circuitpython-manual/audiobusio/pdmin_rms.py b/tests/circuitpython-manual/audiobusio/pdmin_rms.py index 8d1595752..53a6fea15 100644 --- a/tests/circuitpython-manual/audiobusio/pdmin_rms.py +++ b/tests/circuitpython-manual/audiobusio/pdmin_rms.py @@ -8,19 +8,18 @@ import math trigger = digitalio.DigitalInOut(board.D4) trigger.switch_to_output(True) + def mean(values): return sum(values) / len(values) def normalized_rms(values): minbuf = int(mean(values)) - samples_sum = sum( - float(sample - minbuf) * (sample - minbuf) - for sample in values - ) + samples_sum = sum(float(sample - minbuf) * (sample - minbuf) for sample in values) return math.sqrt(samples_sum / len(values)) + # signed 16 bit s16 = array.array("H", [0] * 10000) diff --git a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py index dfac475b5..6013892a9 100644 --- a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py +++ b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py @@ -13,12 +13,7 @@ trigger.switch_to_output(True) length = 8000 // 440 samples = [] -sample_names = [ -"unsigned 8 bit", -"signed 8 bit", -"unsigned 16 bit", -"signed 16 bit" -] +sample_names = ["unsigned 8 bit", "signed 8 bit", "unsigned 16 bit", "signed 16 bit"] # unsigned 8 bit diff --git a/tests/circuitpython-manual/busio/uart_echo.py b/tests/circuitpython-manual/busio/uart_echo.py index f55d4db9e..d429c7781 100644 --- a/tests/circuitpython-manual/busio/uart_echo.py +++ b/tests/circuitpython-manual/busio/uart_echo.py @@ -9,10 +9,10 @@ u = busio.UART(tx=board.TX, rx=board.RX) while True: u.write(str(i).encode("utf-8")) time.sleep(0.1) - print(i, u.in_waiting) # should be the number of digits + print(i, u.in_waiting) # should be the number of digits time.sleep(0.1) - print(i, u.in_waiting) # should be the number of digits + print(i, u.in_waiting) # should be the number of digits r = u.read(64 + 10) - print(i, u.in_waiting) # should be 0 + print(i, u.in_waiting) # should be 0 print(len(r), r) i += 1 diff --git a/tests/circuitpython-manual/socketpool/client/cpy-client.py b/tests/circuitpython-manual/socketpool/client/cpy-client.py index dcc742c9f..a6e9e6b3e 100644 --- a/tests/circuitpython-manual/socketpool/client/cpy-client.py +++ b/tests/circuitpython-manual/socketpool/client/cpy-client.py @@ -4,7 +4,7 @@ import ssl import time TIMEOUT = None -HOST = '192.168.10.179' +HOST = "192.168.10.179" PORT = 5000 # Connect to wifi @@ -19,7 +19,7 @@ with pool.socket(pool.AF_INET, pool.SOCK_STREAM) as s: print("Connecting") s.connect((HOST, PORT)) print("Sending") - sent = s.send(b'Hello, world') + sent = s.send(b"Hello, world") print("Receiving") buff = bytearray(128) numbytes = s.recv_into(buff) diff --git a/tests/circuitpython-manual/socketpool/client/host-server.py b/tests/circuitpython-manual/socketpool/client/host-server.py index fd7ceb7f1..49da4055f 100644 --- a/tests/circuitpython-manual/socketpool/client/host-server.py +++ b/tests/circuitpython-manual/socketpool/client/host-server.py @@ -20,7 +20,7 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: with conn: s.settimeout(TIMEOUT) - print('Connected by', addr) + print("Connected by", addr) data = conn.recv(128) print("got: " + str(data)) conn.sendall(data) diff --git a/tests/circuitpython-manual/socketpool/datagram/ntp.py b/tests/circuitpython-manual/socketpool/datagram/ntp.py index 31d922858..df5fadb13 100644 --- a/tests/circuitpython-manual/socketpool/datagram/ntp.py +++ b/tests/circuitpython-manual/socketpool/datagram/ntp.py @@ -10,7 +10,7 @@ pool = socketpool.SocketPool(wifi.radio) # make socket print("Creating socket") -sock = pool.socket(pool.AF_INET,pool.SOCK_DGRAM) +sock = pool.socket(pool.AF_INET, pool.SOCK_DGRAM) # Fill packet packet = bytearray(48) diff --git a/tests/circuitpython-manual/socketpool/server/cpy-server.py b/tests/circuitpython-manual/socketpool/server/cpy-server.py index d865156bc..bce1f9d6a 100644 --- a/tests/circuitpython-manual/socketpool/server/cpy-server.py +++ b/tests/circuitpython-manual/socketpool/server/cpy-server.py @@ -11,21 +11,21 @@ pool = socketpool.SocketPool(wifi.radio) print("Finding IP address") print(wifi.radio.ipv4_address) HOST = str(wifi.radio.ipv4_address) -PORT = 80 # Port to listen on +PORT = 80 # Port to listen on print("Creating socket") -sock = pool.socket(pool.AF_INET,pool.SOCK_STREAM) +sock = pool.socket(pool.AF_INET, pool.SOCK_STREAM) sock.bind((HOST, PORT)) sock.listen(1) print("Accepting connections") conn, addr = sock.accept() with conn: - print('Connected by', addr) + print("Connected by", addr) buff = bytearray(128) print("Receiving") numbytes = conn.recvfrom_into(buff) - print(buff[:numbytes[0]]) + print(buff[: numbytes[0]]) if numbytes: print("Sending") - conn.send(buff[:numbytes[0]]) + conn.send(buff[: numbytes[0]]) diff --git a/tests/circuitpython-manual/socketpool/server/host-client.py b/tests/circuitpython-manual/socketpool/server/host-client.py index b482755d8..e2cc77c4e 100644 --- a/tests/circuitpython-manual/socketpool/server/host-client.py +++ b/tests/circuitpython-manual/socketpool/server/host-client.py @@ -1,7 +1,7 @@ import socket -HOST = '192.168.10.128' # The server's hostname or IP address -PORT = 80 # The port used by the server +HOST = "192.168.10.128" # The server's hostname or IP address +PORT = 80 # The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.settimeout(None) @@ -10,8 +10,8 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) print("Sending") - s.send(b'Hello, world') + s.send(b"Hello, world") print("Receiving") data = s.recv(1024) - print('Received', repr(data)) + print("Received", repr(data)) |
