esp32-sk6812/scripts/fasttrigon_gen_lut.py

18 lines
395 B
Python
Executable File

#!/usr/bin/env python3
import numpy as np
LUT_SIZE = 2048
PRECISION_BITS = 11
SCALE = (1 << (PRECISION_BITS-1)) - 1
x = np.array(range(LUT_SIZE)) * 2*np.pi / LUT_SIZE
y = SCALE * np.sin(x)
print(f"static const uint32_t LUT_SIZE = {LUT_SIZE};")
print(f"static const uint32_t PRECISION_BITS = {PRECISION_BITS};")
print(f"static const uint32_t SCALE = {SCALE};")
print(list(y.astype('int')))