Add flake8 CI checks

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
2024-06-01 14:21:50 +02:00
parent 12149986c4
commit b7c980b6eb
3 changed files with 31 additions and 17 deletions

View File

@@ -12,3 +12,18 @@ jobs:
run: | run: |
cmake software -B build cmake software -B build
cmake --build build -- check-format cmake --build build -- check-format
Check-Python-Flake8:
runs-on: ubuntu-22.04-full
steps:
- name: Get Flake8
run: |
python -m venv flake-venv
flake-venv/bin/pip install flake8==7.0
- name: Check out repository code
uses: actions/checkout@v4
with:
path: git
- name: Check python
run: |
cd git/software/src &&
find . -iname '*.py' -exec ../../../flake-venv/bin/flake8 {} +

View File

@@ -14,17 +14,18 @@ T1 = 2
T2 = 5 T2 = 5
T3 = 3 T3 = 3
@asm_pio(sideset_init=(PIO.OUT_LOW), fifo_join=PIO.JOIN_TX, autopull=True, @asm_pio(sideset_init=(PIO.OUT_LOW), fifo_join=PIO.JOIN_TX, autopull=True,
out_shiftdir=PIO.SHIFT_LEFT) out_shiftdir=PIO.SHIFT_LEFT)
def _ws2812_pio(T1=T1, T2=T2, T3=T3): def _ws2812_pio(T1=T1, T2=T2, T3=T3):
label("bitloop") label("bitloop") # noqa:F821
out(x, 1).side(0).delay(T3-1) out(x, 1).side(0).delay(T3-1) # noqa:F821
jmp(not_x, "do_zero").side(1) [T1-1] jmp(not_x, "do_zero").side(1).delay(T1-1) # noqa:F821
label("do_one") label("do_one") # noqa:F821
jmp("bitloop").side(1) [T2-1] jmp("bitloop").side(1).delay(T2-1) # noqa:F821
label("do_zero") label("do_zero") # noqa:F821
nop().side(0) [T2-1] nop().side(0).delay(T2-1) # noqa:F821
wrap() wrap() # noqa:F821
class NeoPixel: class NeoPixel:

View File

@@ -44,14 +44,13 @@ async def rainbow(np, period=10):
samplerate = 44100 samplerate = 44100
hz = 441 # 344.53125 hz = 441
count = 100 # 128 count = 100
amplitude = 0x1fff amplitude = 0x1fff
buf = array('I', range(count)) buf = array('I', range(count))
for i in range(len(buf)): for i in range(len(buf)):
val = int(sin(i * hz / samplerate * 2 * pi)*amplitude) & 0xffff val = int(sin(i * hz / samplerate * 2 * pi)*amplitude) & 0xffff
buf[i] = (val << 16) | val buf[i] = (val << 16) | val
# print(hex(buf[i]))
async def output_sound(audioctx): async def output_sound(audioctx):
@@ -60,9 +59,7 @@ async def output_sound(audioctx):
while True: while True:
pushed, avail, underruns = audioctx.put(buf[pos:]) pushed, avail, underruns = audioctx.put(buf[pos:])
pos = (pos + pushed) % len(buf) pos = (pos + pushed) % len(buf)
# pushed, avail = audioctx.put(array('I', range(pos, pos+100))) # print(f"pushed {pushed}, pos {pos}, avail {avail}")
# pos += pushed
#print(f"pushed {pushed}, pos {pos}, avail {avail}")
if underruns > known_underruns: if underruns > known_underruns:
print(f"{underruns:x}") print(f"{underruns:x}")
known_underruns = underruns known_underruns = underruns
@@ -94,7 +91,8 @@ def list_sd():
delay_sum = 0 delay_sum = 0
delay_count = 0 delay_count = 0
max_delay = 0 max_delay = 0
async def latency_test(): async def latency_test():
global delay_sum global delay_sum
global delay_count global delay_count