Skip to content

Commit 45b6b6d

Browse files
committed
Merge branch 'staging'
2 parents f0c6e71 + 8a30eeb commit 45b6b6d

38 files changed

+1233
-510
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[bumpversion]
22
tag_name = rc/v{new_version}
3-
current_version = 1.2.17
3+
current_version = 1.2.21

.github/workflows/build-and-publish-PyPI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
python -m build
2929
- name: Publish Package to PyPI
30-
uses: pypa/gh-action-pypi-publish@v1.5.0
30+
uses: pypa/gh-action-pypi-publish@v1.9.0
3131
with:
3232
user: __token__
3333
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/build-and-publish-TestPyPI.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: |
4747
python -m build
4848
- name: Publish Distribution to TestPyPI
49-
uses: pypa/gh-action-pypi-publish@master
49+
uses: pypa/gh-action-pypi-publish@v1.9.0
5050
with:
5151
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
5252
repository_url: https://test.pypi.org/legacy/
@@ -69,26 +69,28 @@ jobs:
6969
git config user.email ${{ env.commit_email }}
7070
git cherry-pick ${{ env.bump_commit }}
7171
git push origin dev
72-
Hardware_Test:
73-
needs: publish
74-
name: Hardware Tests
75-
runs-on: [self-hosted, linux, ARM64, hw-test]
76-
strategy:
77-
fail-fast: false
78-
matrix:
79-
python-version: ["3.9"]
8072
81-
steps:
82-
- name: Checkout
83-
uses: actions/checkout@v3
84-
- name: Install Dependencies
85-
run: |
86-
python -m venv venv_hardware_test
87-
source venv_hardware_test/bin/activate
88-
python -m pip install --upgrade pip
89-
python -m pip install pytest
90-
if [ -f requirements_hw_test.txt ]; then pip install -r requirements_hw_test.txt; fi
91-
- name: Test with pytest
92-
run: |
93-
source venv_hardware_test/bin/activate
94-
python -m pytest ./tests/hardware_tests
73+
74+
# Hardware_Test:
75+
# needs: publish
76+
# name: Hardware Tests
77+
# runs-on: [self-hosted, linux, ARM64, hw-test]
78+
# strategy:
79+
# fail-fast: false
80+
# matrix:
81+
# python-version: ["3.9"]
82+
83+
# steps:
84+
# - name: Checkout
85+
# uses: actions/checkout@v3
86+
# - name: Install Dependencies
87+
# run: |
88+
# python -m venv venv_hardware_test
89+
# source venv_hardware_test/bin/activate
90+
# python -m pip install --upgrade pip
91+
# python -m pip install pytest
92+
# if [ -f requirements_hw_test.txt ]; then pip install -r requirements_hw_test.txt; fi
93+
# - name: Test with pytest
94+
# run: |
95+
# source venv_hardware_test/bin/activate
96+
# python -m pytest ./tests/hardware_tests

.pylintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ disable=logging-fstring-interpolation,
55
too-many-arguments,
66
fixme,
77
too-few-public-methods,
8-
duplicate-code
8+
duplicate-code,
9+
no-else-return,
10+
no-else-raise,
11+
logging-fstring-interpolation
912

1013
[LOGGING]
1114

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,27 @@ password: <token-value>
107107
```
108108
Make sure to include the `pypi-` prefix for your token value.
109109

110+
# Performance
111+
112+
The following benchmarks were measured on the Rasberry Pi 4, with all edgepi daemons disabled. They're also the slowest average of 3 runs.
113+
114+
The **Performance** column represents how long it takes to call one function, while the **Max Read Frequency** column represents how many times that function could be called every second.
115+
116+
| Feature | Performance | Max Read Frequency | Function | Example | Description |
117+
| -- | -- | -- | -- | -- | -- |
118+
| Single DIN | 0.85ms per 8 DIN | 1171 Hz | `digital_input_state(...)` | [examples/single_din.py](https://github.com/EdgePi-Cloud/edgepi-python-sdk/tree/main/examples/single_din.py) | |
119+
| Batched DIN | 0.52ms per 8 DIN | 1936 Hz | `digital_input_state_batch(...)` | [examples/batched_din.py](https://github.com/EdgePi-Cloud/edgepi-python-sdk/tree/main/examples/batched_din.py) | |
120+
| Single ADC | 97.3 ms per 8 ADC | 10.3 Hz | `set_config(...)` <br><br> `single_sample()` | [examples/single_adc.py](https://github.com/EdgePi-Cloud/edgepi-python-sdk/tree/main/examples/single_adc.py) | Reads from ADC1 only |
121+
| Batched ADC | 6.49 ms per 8 ADC | 154 Hz | `read_samples_adc1_batch(...)` | [examples/batched_adc.py](https://github.com/EdgePi-Cloud/edgepi-python-sdk/tree/main/examples/batched_adc.py) | Reads from ADC1 only |
122+
| Batched ADC/Diff | 5.467 ms per 4 ADC, 2 Diff | 183 Hz | `read_samples_adc1_batch(...)` | [examples/batched_adc_diff.py](https://github.com/EdgePi-Cloud/edgepi-python-sdk/tree/main/examples/batched_adc_diff.py) | Differential ADC inputs each use two pins. Reads from ADC1 only |
123+
| Thermocouple (TC) | 100.2ms | 9.98 hz | `read_temperatures()` | [examples/single_tc.py](https://github.com/EdgePi-Cloud/edgepi-python-sdk/tree/main/examples/single_tc.py) | Limited by [hardware](https://www.analog.com/media/en/technical-documentation/data-sheets/MAX31856.pdf) (see conversion mode). 100ms is needed for accurate (19 bit) readings |
124+
110125
# Bug Reports / Feature Requests
111126
Use [GitHub Issues Page](https://github.com/EdgePi-Cloud/edgepi-python-sdk/issues) to report any issues or feature requests.
112127

113128
# Get involved
114129
Follow [@edgepi_cloud on Twitter](https://twitter.com/edgepi_cloud/).
115-
Read and subscribe to the [EdgePi blog](https://www.edgepi.com/blog).
130+
See the [EdgePi wiki](https://wiki.edgepi.com/) for more information on how to get started with your EdgePi.
116131
If you have a specific question, please check out our [discussion forums](https://www.edgepi.com/forums).
117132

118133
# License

examples/batched_adc.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Example reading from ADC using the batched function"""
2+
3+
import time
4+
5+
from edgepi.adc.edgepi_adc import EdgePiADC
6+
from edgepi.adc.adc_constants import AnalogIn, ADC1DataRate
7+
8+
ITER = 50
9+
10+
def run_test():
11+
"""
12+
This test performs 400 Analog input reads, batched 8 reads at a time.
13+
"""
14+
15+
edgepi_adc = EdgePiADC(enable_cache=False)
16+
17+
start = time.time()
18+
result_list = []
19+
adc_choices = [
20+
AnalogIn.AIN1, AnalogIn.AIN2, AnalogIn.AIN3, AnalogIn.AIN4,
21+
AnalogIn.AIN5, AnalogIn.AIN6, AnalogIn.AIN7, AnalogIn.AIN8,
22+
]
23+
24+
for _ in range(ITER):
25+
tmp = edgepi_adc.read_samples_adc1_batch(
26+
data_rate=ADC1DataRate.SPS_38400,
27+
analog_in_list=adc_choices,
28+
)
29+
result_list += [tmp]
30+
31+
elapsed = time.time() - start
32+
33+
print(result_list[24])
34+
print(f"Time elapsed {elapsed/ITER:.6f} s")
35+
print(f"Frequency {ITER/elapsed:.4f} hz")
36+
37+
if __name__ == "__main__":
38+
run_test()

examples/batched_adc_diff.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""Example reading from from individual ADC pins"""
2+
3+
import time
4+
5+
from edgepi.adc.edgepi_adc import EdgePiADC
6+
from edgepi.adc.adc_constants import AnalogIn, ADC1DataRate, DiffMode
7+
8+
ITER = 50
9+
10+
def run_test():
11+
"""
12+
This test performs 300 analog input reads, with 50 for each of 4 analog pins, and
13+
50 for each of 2 differential analog pairs.
14+
"""
15+
16+
edgepi_adc = EdgePiADC(enable_cache=False)
17+
18+
start = time.time()
19+
result_list = []
20+
adc_choices = [
21+
AnalogIn.AIN1, AnalogIn.AIN2,
22+
AnalogIn.AIN5, AnalogIn.AIN6,
23+
]
24+
differential_pairs = [
25+
DiffMode.DIFF_2,
26+
DiffMode.DIFF_4,
27+
]
28+
29+
for _ in range(ITER):
30+
tmp = edgepi_adc.read_samples_adc1_batch(
31+
ADC1DataRate.SPS_38400,
32+
adc_choices,
33+
differential_pairs,
34+
)
35+
result_list += [tmp]
36+
37+
elapsed = time.time() - start
38+
39+
print(result_list[24])
40+
print(f"Time elapsed {elapsed/ITER:.6f} s")
41+
print(f"Frequency {ITER/elapsed:.4f} hz")
42+
43+
if __name__ == "__main__":
44+
run_test()

examples/batched_din.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Example reading from DIN using the batched function"""
2+
3+
import time
4+
5+
from edgepi.digital_input.digital_input_constants import DinPins
6+
from edgepi.digital_input.edgepi_digital_input import EdgePiDigitalInput
7+
8+
ITER = 250
9+
10+
def run_test():
11+
"""
12+
This test performs 2000 Digital input reads, batched 8 reads at a time.
13+
"""
14+
digital_input = EdgePiDigitalInput()
15+
16+
state_list = []
17+
choices = [
18+
DinPins.DIN1, DinPins.DIN2, DinPins.DIN3, DinPins.DIN4,
19+
DinPins.DIN5, DinPins.DIN6, DinPins.DIN7, DinPins.DIN8,
20+
]
21+
22+
start = time.time()
23+
for _ in range(ITER):
24+
pin_states = digital_input.digital_input_state_batch(choices)
25+
state_list += [pin_states]
26+
27+
elapsed = time.time() - start
28+
29+
print(f"DIN Pins: {state_list[217]}")
30+
print(f"Time elapsed {elapsed/ITER:.6f} s")
31+
print(f"Frequency {ITER/elapsed:.4f} hz")
32+
33+
if __name__ == "__main__":
34+
run_test()

examples/single_adc.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""Example reading from individual ADC pins"""
2+
3+
import time
4+
5+
from edgepi.adc.edgepi_adc import EdgePiADC
6+
from edgepi.adc.adc_constants import AnalogIn, ADC1DataRate, ConvMode
7+
8+
ITER = 50
9+
10+
def run_test():
11+
"""
12+
This test performs 400 analog input reads, with a total of 50 per ADC pin.
13+
"""
14+
edgepi_adc = EdgePiADC(enable_cache=False)
15+
16+
start = time.time()
17+
result_list = []
18+
adc_choices = [
19+
AnalogIn.AIN1, AnalogIn.AIN2, AnalogIn.AIN3, AnalogIn.AIN4,
20+
AnalogIn.AIN5, AnalogIn.AIN6, AnalogIn.AIN7, AnalogIn.AIN8,
21+
]
22+
23+
for _ in range(ITER):
24+
tmp_list = []
25+
for ain in adc_choices:
26+
edgepi_adc.set_config(
27+
adc_1_analog_in=ain,
28+
conversion_mode=ConvMode.PULSE,
29+
adc_1_data_rate=ADC1DataRate.SPS_38400
30+
)
31+
32+
voltage = edgepi_adc.single_sample()
33+
tmp_list += [voltage]
34+
35+
result_list += [tmp_list]
36+
37+
elapsed = time.time() - start
38+
39+
print(result_list[24])
40+
print(f"Time elapsed {elapsed/ITER:.6f} s")
41+
print(f"Frequency {ITER/elapsed:.4f} hz")
42+
43+
if __name__ == "__main__":
44+
run_test()

examples/single_din.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Example reading from individual DIN pins"""
2+
3+
import time
4+
5+
from edgepi.digital_input.digital_input_constants import DinPins
6+
from edgepi.digital_input.edgepi_digital_input import EdgePiDigitalInput
7+
8+
ITER = 250
9+
10+
def run_test():
11+
"""
12+
This test performs 2000 Digital input reads, with a total of 250 per DIN pin.
13+
"""
14+
digital_input = EdgePiDigitalInput()
15+
16+
state_list = []
17+
choices = [
18+
DinPins.DIN1, DinPins.DIN2, DinPins.DIN3, DinPins.DIN4,
19+
DinPins.DIN5, DinPins.DIN6, DinPins.DIN7, DinPins.DIN8,
20+
]
21+
22+
start = time.time()
23+
for _ in range(ITER):
24+
for din in choices:
25+
pin_state = digital_input.digital_input_state(din)
26+
state_list += [pin_state]
27+
28+
elapsed = time.time() - start
29+
30+
print(f"DIN Pins: {state_list[-9:-1]}")
31+
print(f"Time elapsed {elapsed/ITER:.6f} s")
32+
print(f"Frequency {ITER/elapsed:.4f} hz")
33+
34+
if __name__ == "__main__":
35+
run_test()

0 commit comments

Comments
 (0)