From 3c3ac33e36bc0cdf5ec792f734f3e49e2dd71b8d Mon Sep 17 00:00:00 2001 From: Matthias Blankertz Date: Sat, 1 Jun 2024 14:21:50 +0200 Subject: [PATCH] Add flake8 CI checks Signed-off-by: Matthias Blankertz --- .gitea/workflows/check-format.yaml | 15 +++++++++++++++ software/src/rp2_neopixel.py | 17 +++++++++-------- software/src/test.py | 16 +++++++--------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/.gitea/workflows/check-format.yaml b/.gitea/workflows/check-format.yaml index 4a3c4bc..e82f332 100644 --- a/.gitea/workflows/check-format.yaml +++ b/.gitea/workflows/check-format.yaml @@ -13,3 +13,18 @@ jobs: run: | cmake software -B build 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 {} + diff --git a/software/src/rp2_neopixel.py b/software/src/rp2_neopixel.py index 8aa4e1a..fc9a0c1 100644 --- a/software/src/rp2_neopixel.py +++ b/software/src/rp2_neopixel.py @@ -14,17 +14,18 @@ T1 = 2 T2 = 5 T3 = 3 + @asm_pio(sideset_init=(PIO.OUT_LOW), fifo_join=PIO.JOIN_TX, autopull=True, out_shiftdir=PIO.SHIFT_LEFT) def _ws2812_pio(T1=T1, T2=T2, T3=T3): - label("bitloop") - out(x, 1).side(0).delay(T3-1) - jmp(not_x, "do_zero").side(1) [T1-1] - label("do_one") - jmp("bitloop").side(1) [T2-1] - label("do_zero") - nop().side(0) [T2-1] - wrap() + label("bitloop") # noqa:F821 + out(x, 1).side(0).delay(T3-1) # noqa:F821 + jmp(not_x, "do_zero").side(1).delay(T1-1) # noqa:F821 + label("do_one") # noqa:F821 + jmp("bitloop").side(1).delay(T2-1) # noqa:F821 + label("do_zero") # noqa:F821 + nop().side(0).delay(T2-1) # noqa:F821 + wrap() # noqa:F821 class NeoPixel: diff --git a/software/src/test.py b/software/src/test.py index 28e46f0..535ed66 100644 --- a/software/src/test.py +++ b/software/src/test.py @@ -44,14 +44,13 @@ async def rainbow(np, period=10): samplerate = 44100 -hz = 441 # 344.53125 -count = 100 # 128 +hz = 441 +count = 100 amplitude = 0x1fff buf = array('I', range(count)) for i in range(len(buf)): - val = int(sin(i * hz / samplerate * 2 * pi)*amplitude) & 0xffff - buf[i] = (val << 16) | val - # print(hex(buf[i])) + val = int(sin(i * hz / samplerate * 2 * pi)*amplitude) & 0xffff + buf[i] = (val << 16) | val async def output_sound(audioctx): @@ -60,9 +59,7 @@ async def output_sound(audioctx): while True: pushed, avail, underruns = audioctx.put(buf[pos:]) pos = (pos + pushed) % len(buf) - # pushed, avail = audioctx.put(array('I', range(pos, pos+100))) - # pos += pushed - #print(f"pushed {pushed}, pos {pos}, avail {avail}") + # print(f"pushed {pushed}, pos {pos}, avail {avail}") if underruns > known_underruns: print(f"{underruns:x}") known_underruns = underruns @@ -94,7 +91,8 @@ def list_sd(): delay_sum = 0 delay_count = 0 max_delay = 0 - + + async def latency_test(): global delay_sum global delay_count