fft_test.py 503 B

12345678910111213141516171819202122
  1. #python
  2. from k210 import FFT
  3. import math
  4. fft = FFT()
  5. FFT_N = 64
  6. input = []
  7. for i in range(0, FFT_N):
  8. v = 0.3 * math.cos(2 * math.pi * i / FFT_N + math.pi / 3) * 256
  9. v += 0.1 * math.cos(16 * 2 * math.pi * i / FFT_N - math.pi / 9) * 256
  10. v += 0.5 * math.cos((19 * 2 * math.pi * i / FFT_N) + math.pi / 6) * 256
  11. input.append(int(v) + 10)
  12. ret = fft.run(input = input, shift = 0, direction = fft.DIR_FORWARD) #DIR_BACKWARD
  13. print(ret)
  14. #将以上内容粘贴到MSH(注意不要删除FFT.run上的空行)