examples.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Examples
  2. ========
  3. This page contains a few examples.
  4. Speaker
  5. -------
  6. .. literalinclude:: ../../examples/flipperzero_speaker_test.py
  7. :language: python
  8. Input
  9. -----
  10. .. literalinclude:: ../../examples/flipperzero_draw_on_input_test.py
  11. :language: python
  12. Tic-Tac-Toe
  13. -----------
  14. .. literalinclude:: ../../examples/tic_tac_toe.py
  15. :language: python
  16. Interrupts
  17. ----------
  18. .. literalinclude:: ../../examples/flipperzero_gpio_interrupt_test.py
  19. :language: python
  20. This example drives an external LED upon interrupts: A rising edge on ``C0`` sets the pin ``A7`` to high, a rising edge on ``C1`` sets the pin ``A7`` to low.
  21. The following schematic circuit diagram shows the hardware setup for this example:
  22. .. figure:: ./assets/gpio_interrupt_circuit.svg
  23. :width: 90%
  24. Hardware setup for the GPIO interrupt example.
  25. ADC
  26. ---
  27. .. literalinclude:: ../../examples/flipperzero_adc_test.py
  28. :language: python
  29. This example uses a voltage divider with the 3.3 V source from pin 9. The switch ``S1`` changes the input voltage on ``C1`` between 0 and about 0.8 V.
  30. .. figure:: ./assets/adc_circuit.svg
  31. :width: 90%
  32. Hardware setup for the ADC example.
  33. PWM
  34. ---
  35. .. literalinclude:: ../../examples/flipperzero_pwm_test.py
  36. :language: python
  37. This example drives an LED connected to pin ``A7`` and ``GND`` using a PWM signal with two different frequency and duty cycle settings.
  38. .. figure:: ./assets/pwm_circuit.svg
  39. :width: 90%
  40. Hardware setup for the PWM example.
  41. Infrared
  42. --------
  43. .. literalinclude:: ../../examples/flipperzero_infrared_test.py
  44. :language: python