summaryrefslogtreecommitdiffstatshomepage
path: root/tests/pyb/adc.py
diff options
context:
space:
mode:
authorDavid Lechner <david@lechnology.com>2020-03-22 21:26:08 -0500
committerDamien George <damien.p.george@gmail.com>2020-03-30 13:21:58 +1100
commit3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch)
tree94ff44f8eabba0039582c245b901173597edd11e /tests/pyb/adc.py
parent488613bca6c460340ed2995ae5cafafe22d0bfff (diff)
downloadmicropython-3dc324d3f1312e40d3a8ed87e7244966bb756f26.tar.gz
micropython-3dc324d3f1312e40d3a8ed87e7244966bb756f26.zip
tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
Diffstat (limited to 'tests/pyb/adc.py')
-rw-r--r--tests/pyb/adc.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/pyb/adc.py b/tests/pyb/adc.py
index ef42065388..875d31d732 100644
--- a/tests/pyb/adc.py
+++ b/tests/pyb/adc.py
@@ -1,8 +1,8 @@
from pyb import ADC, Timer
-adct = ADC(16) # Temperature 930 -> 20C
+adct = ADC(16) # Temperature 930 -> 20C
print(str(adct)[:19])
-adcv = ADC(17) # Voltage 1500 -> 3.3V
+adcv = ADC(17) # Voltage 1500 -> 3.3V
print(adcv)
# read single sample; 2.5V-5V is pass range
@@ -13,7 +13,7 @@ assert val > 1000 and val < 2000
tim = Timer(5, freq=500)
# read into bytearray
-buf = bytearray(b'\xff' * 50)
+buf = bytearray(b"\xff" * 50)
adcv.read_timed(buf, tim)
print(len(buf))
for i in buf:
@@ -21,21 +21,22 @@ for i in buf:
# read into arrays with different element sizes
import array
-arv = array.array('h', 25 * [0x7fff])
+
+arv = array.array("h", 25 * [0x7FFF])
adcv.read_timed(arv, tim)
print(len(arv))
for i in arv:
assert i > 1000 and i < 2000
-arv = array.array('i', 30 * [-1])
+arv = array.array("i", 30 * [-1])
adcv.read_timed(arv, tim)
print(len(arv))
for i in arv:
assert i > 1000 and i < 2000
# Test read_timed_multi
-arv = bytearray(b'\xff'*50)
-art = bytearray(b'\xff'*50)
+arv = bytearray(b"\xff" * 50)
+art = bytearray(b"\xff" * 50)
ADC.read_timed_multi((adcv, adct), (arv, art), tim)
for i in arv:
assert i > 60 and i < 125
@@ -43,8 +44,8 @@ for i in arv:
for i in art:
assert i > 15 and i < 200
-arv = array.array('i', 25 * [-1])
-art = array.array('i', 25 * [-1])
+arv = array.array("i", 25 * [-1])
+art = array.array("i", 25 * [-1])
ADC.read_timed_multi((adcv, adct), (arv, art), tim)
for i in arv:
assert i > 1000 and i < 2000
@@ -52,8 +53,8 @@ for i in arv:
for i in art:
assert i > 50 and i < 2000
-arv = array.array('h', 25 * [0x7fff])
-art = array.array('h', 25 * [0x7fff])
+arv = array.array("h", 25 * [0x7FFF])
+art = array.array("h", 25 * [0x7FFF])
ADC.read_timed_multi((adcv, adct), (arv, art), tim)
for i in arv:
assert i > 1000 and i < 2000