flipperzero_speaker_note_test.py 562 B

123456789101112131415161718192021222324252627
  1. import time
  2. import flipperzero as f0
  3. def play_frequency(frequency: float):
  4. volume = 0.8
  5. f0.speaker_start(frequency, volume)
  6. for _ in range(0, 150):
  7. volume *= 0.9945679
  8. f0.speaker_set_volume(volume)
  9. time.sleep_ms(1)
  10. f0.speaker_stop()
  11. play_frequency(f0.SPEAKER_NOTE_C5)
  12. play_frequency(f0.SPEAKER_NOTE_D5)
  13. play_frequency(f0.SPEAKER_NOTE_E5)
  14. play_frequency(f0.SPEAKER_NOTE_F5)
  15. play_frequency(f0.SPEAKER_NOTE_G5)
  16. play_frequency(f0.SPEAKER_NOTE_A5)
  17. play_frequency(f0.SPEAKER_NOTE_B5)
  18. play_frequency(f0.SPEAKER_NOTE_C6)