ledstick/python/parse_fft.py
Patrick Moessler fc4005cc49 v2
2025-02-24 00:29:15 +01:00

25 lines
675 B
Python

# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
from pathlib import Path
import re
from math import log10
# [0] fffffffe [16] fffffffe [32] ffffffff [48] ffffffff [64] 0000 [80] ffffffff [96] ffffffff [112] ffffffff [128] 0000 [144] ffffffff [160] ffffffff [176] ffffffff [192] 0000 [208] ffffffff [224] ffffffff [240] 0000
line_re = re.compile(r"\[([0-9]+)\] ([0-9a-f]+)")
def main() -> None:
for line in Path("fft_1.txt").open().readlines():
bins = [
int.from_bytes(bytes.fromhex(m[2]), "little", signed=True)
for m in line_re.finditer(line)
]
print(bins)
if __name__ == "__main__":
main()