فهرست منبع

add light and vibro api docs

Oliver Fabel 1 سال پیش
والد
کامیت
de474cd47b
6فایلهای تغییر یافته به همراه113 افزوده شده و 2 حذف شده
  1. 1 0
      .gitignore
  2. 1 0
      LICENSE.txt
  3. 23 2
      docs/pages/conf.py
  4. 1 0
      docs/pages/quickstart.md
  5. 7 0
      docs/pages/reference.rst
  6. 80 0
      flipperzero/__init__.py

+ 1 - 0
.gitignore

@@ -6,3 +6,4 @@
 .editorconfig
 .editorconfig
 .env
 .env
 .ufbt
 .ufbt
+__pycache__

+ 1 - 0
LICENSE.txt

@@ -1,4 +1,5 @@
 MIT License
 MIT License
+===========
 
 
 Copyright (c) 2024 Oliver Fabel
 Copyright (c) 2024 Oliver Fabel
 
 

+ 23 - 2
docs/pages/conf.py

@@ -1,7 +1,20 @@
+import datetime
+import pathlib
+import sys
+
+base = pathlib.Path(__file__).parent.parent.parent
+root = base.__str__()
+flipperzero = base.joinpath('flipperzero').__str__()
+now = datetime.datetime.now()
+
+sys.path.append(root)
+sys.path.append(flipperzero)
+
 project = 'uPython'
 project = 'uPython'
-copyright = '2024, Oliver Fabel'
+copyright = str(now.year) + ', Oliver Fabel'
 author = 'Oliver Fabel'
 author = 'Oliver Fabel'
 release = '1.0.0'
 release = '1.0.0'
+version = '1.0'
 language = 'en'
 language = 'en'
 
 
 extensions = [
 extensions = [
@@ -23,6 +36,7 @@ include_patterns = [
 
 
 html_theme = 'alabaster'
 html_theme = 'alabaster'
 html_theme_options = {
 html_theme_options = {
+    'show_powered_by': False,
     'extra_nav_links': {
     'extra_nav_links': {
         'Source Code': 'https://www.github.com/ofabel/mp-flipper',
         'Source Code': 'https://www.github.com/ofabel/mp-flipper',
         'Bugtracker': 'https://www.github.com/ofabel/mp-flipper/issues',
         'Bugtracker': 'https://www.github.com/ofabel/mp-flipper/issues',
@@ -30,8 +44,15 @@ html_theme_options = {
 
 
     }
     }
 }
 }
+html_copy_source = False
+html_show_copyright = False
+html_show_sphinx = False
 html_static_path = [
 html_static_path = [
     'static'
     'static'
 ]
 ]
 html_logo = 'assets/logo.png'
 html_logo = 'assets/logo.png'
-html_favicon = 'assets/favicon.png'
+html_favicon = 'assets/favicon.png'
+
+autodoc_default_options = {
+    'member-order': 'bysource',
+}

+ 1 - 0
docs/pages/quickstart.md

@@ -0,0 +1 @@
+# Quickstart

+ 7 - 0
docs/pages/reference.rst

@@ -0,0 +1,7 @@
+Reference
+=========
+
+This page contains the API documentation of the ``flipperzero`` module.
+
+.. automodule:: flipperzero
+   :members:

+ 80 - 0
flipperzero/__init__.py

@@ -0,0 +1,80 @@
+LIGHT_RED: int
+'''
+Constant value for the red LED light.
+'''
+
+LIGHT_GREEN: int
+'''
+Constant value for the green LED light.
+'''
+
+LIGHT_BLUE: int
+'''
+Constant value for the blue LED light.
+'''
+
+LIGHT_BACKLIGHT: int
+'''
+Constant value for the display backlight.
+'''
+
+def light_set(light: int, brightness: int) -> None:
+    '''
+    Control the RGB LED on your Flipper. You can also set the brightness of multiple channels at once using bitwise operations.
+    The ``brightness`` parameter accepts values from 0 (light off) to 255 (very bright).
+
+    :param light: The RGB channels to set.
+    :param brightness: The brightness to use.
+
+    :Example:
+
+    >>> import flipperzero as f0
+    >>> f0.light_set(f0.LIGHT_RED | f0.LIGHT_GREEN, 250)
+
+    .. tip::
+
+        You can use  up to seven colors using `additive mixing <https://en.wikipedia.org/wiki/Additive_color>`_.
+    '''
+    pass
+
+def light_blink_start(light: int, brightness: int, on_time: int, period: int) -> None:
+    '''
+    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.
+    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`.
+
+    :param light: The RGB channels to set.
+    :param brightness: The brightness to use.
+    :param on_time: The LED's active duration in milliseconds.
+    :param period: Total duration of a blink period in milliseconds.
+
+    :Example:
+
+    >>> import flipperzero as f0
+    >>> f0.light_blink_start(f0.LIGHT_RED, 150, 100, 200)
+    '''
+    pass
+
+def light_blink_set_color(light: int) -> None:
+    '''
+    Change the RGB LED's color while blinking. This is a non-blocking operation.
+    Be aware, that you must start the blinking procedure first by using the :func:`light_blink_start` function.
+    Call the :func:`light_blink_stop` function to stop the blinking LED.
+
+    :param light: The RGB channels to set.
+    '''
+    pass
+
+def light_blink_stop() -> None:
+    '''
+    Stop the blinking LED.
+    '''
+    pass
+
+def vibro_set(state: bool) -> bool:
+    '''
+    Turn vibration on or off. This is a non-blocking operation. The vibration motor will continue to run until you stop it.
+
+    :param state: ``True`` to turn on vibration.
+    :returns: ``True`` if vibration is on.
+    '''
+    pass