__init__.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. LIGHT_RED: int
  2. '''
  3. Constant value for the red LED light.
  4. '''
  5. LIGHT_GREEN: int
  6. '''
  7. Constant value for the green LED light.
  8. '''
  9. LIGHT_BLUE: int
  10. '''
  11. Constant value for the blue LED light.
  12. '''
  13. LIGHT_BACKLIGHT: int
  14. '''
  15. Constant value for the display backlight.
  16. '''
  17. def light_set(light: int, brightness: int) -> None:
  18. '''
  19. Control the RGB LED on your Flipper. You can also set the brightness of multiple channels at once using bitwise operations.
  20. The ``brightness`` parameter accepts values from 0 (light off) to 255 (very bright).
  21. :param light: The RGB channels to set.
  22. :param brightness: The brightness to use.
  23. :Example:
  24. .. code-block::
  25. import flipperzero as f0
  26. f0.light_set(f0.LIGHT_RED | f0.LIGHT_GREEN, 250)
  27. .. tip::
  28. You can use up to seven colors using `additive mixing <https://en.wikipedia.org/wiki/Additive_color>`_.
  29. '''
  30. pass
  31. def light_blink_start(light: int, brightness: int, on_time: int, period: int) -> None:
  32. '''
  33. Let the RGB LED blink. You can define the total duration of a blink period and the duration, the LED is active during a blink period.
  34. Hence, ``on_time`` must be smaller than ``period``. This is a non-blocking operation. The LED will continue to blink until you call :func:`light_blink_stop`.
  35. :param light: The RGB channels to set.
  36. :param brightness: The brightness to use.
  37. :param on_time: The LED's active duration in milliseconds.
  38. :param period: Total duration of a blink period in milliseconds.
  39. :Example:
  40. :Example:
  41. .. code-block::
  42. import flipperzero as f0
  43. f0.light_blink_start(f0.LIGHT_RED, 150, 100, 200)
  44. '''
  45. pass
  46. def light_blink_set_color(light: int) -> None:
  47. '''
  48. Change the RGB LED's color while blinking. This is a non-blocking operation.
  49. Be aware, that you must start the blinking procedure first by using the :func:`light_blink_start` function.
  50. Call the :func:`light_blink_stop` function to stop the blinking LED.
  51. :param light: The RGB channels to set.
  52. '''
  53. pass
  54. def light_blink_stop() -> None:
  55. '''
  56. Stop the blinking LED.
  57. '''
  58. pass
  59. def vibro_set(state: bool) -> bool:
  60. '''
  61. Turn vibration on or off. This is a non-blocking operation. The vibration motor will continue to run until you stop it.
  62. :param state: :const:`True` to turn on vibration.
  63. :returns: :const:`True` if vibration is on.
  64. '''
  65. pass
  66. def speaker_start(frequency: float, volume: float) -> bool:
  67. '''
  68. Output a steady tone of a defined frequency and volume on the Flipper's speaker.
  69. This is a non-blocking operation. The tone will continue until you call :func:`speaker_stop`.
  70. The ``volume`` parameter accepts values from 0.0 (silent) up to 1.0 (very loud).
  71. :param frequency: The frequency to play in `hertz <https://en.wikipedia.org/wiki/Hertz>`_.
  72. :param volume: The volume to use.
  73. :returns: :const:`True` if the speaker was acquired.
  74. :Example:
  75. .. code-block::
  76. import flipperzero as f0
  77. f0.speaker_start(50.0, 0.8)
  78. '''
  79. pass
  80. def speaker_set_volume(volume: float) -> bool:
  81. '''
  82. Set the speaker's volume while playing a tone. This is a non-blocking operation.
  83. The tone will continue until you call :func:`speaker_stop`.
  84. The ``volume`` parameter accepts values from 0.0 (silent) up to 1.0 (very loud).
  85. :param volume: The volume to use.
  86. :returns: :const:`True` if the speaker was acquired.
  87. :Example:
  88. This function can be used to play `nice` sounds:
  89. .. code-block::
  90. import time
  91. import flipperzero as f0
  92. volume = 0.8
  93. f0.speaker_start(100.0, volume)
  94. for _ in range(0, 150):
  95. volume *= 0.9945679
  96. f0.speaker_set_volume(volume)
  97. time.sleep_ms(1)
  98. f0.speaker_stop()
  99. '''
  100. pass
  101. def speaker_stop() -> bool:
  102. '''
  103. Stop the speaker output.
  104. :returns: :const:`True` if the speaker was successfully released.
  105. '''
  106. pass