examples.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Examples
  2. ========
  3. This page contains a few examples.
  4. See more on `GitHub <https://github.com/ofabel/mp-flipper/tree/master/examples>`_.
  5. Speaker
  6. -------
  7. .. literalinclude:: ../../examples/flipperzero_speaker_test.py
  8. :language: python
  9. For details, see the :ref:`reference-speaker` section on the :doc:`reference` page.
  10. Input
  11. -----
  12. .. literalinclude:: ../../examples/flipperzero_draw_on_input_test.py
  13. :language: python
  14. For details, see the :ref:`reference-input` section on the :doc:`reference` page.
  15. Interrupts
  16. ----------
  17. .. literalinclude:: ../../examples/flipperzero_gpio_interrupt_test.py
  18. :language: python
  19. 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.
  20. The following schematic circuit diagram shows the hardware setup for this example:
  21. .. figure:: ./assets/gpio_interrupt_circuit.svg
  22. :width: 90%
  23. Hardware setup for the GPIO interrupt example.
  24. For details, see the :ref:`reference-gpio` section on the :doc:`reference` page.
  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. For details, see the :ref:`reference-adc` section on the :doc:`reference` page.
  34. PWM
  35. ---
  36. .. literalinclude:: ../../examples/flipperzero_pwm_test.py
  37. :language: python
  38. This example drives an LED connected to pin ``A7`` and ``GND`` using a PWM signal with two different frequency and duty cycle settings.
  39. .. figure:: ./assets/pwm_circuit.svg
  40. :width: 90%
  41. Hardware setup for the PWM example.
  42. For details, see the :ref:`reference-pwm` section on the :doc:`reference` page.
  43. Infrared
  44. --------
  45. .. literalinclude:: ../../examples/flipperzero_infrared_test.py
  46. :language: python
  47. For details, see the :ref:`reference-infrared` section on the :doc:`reference` page.