Oliver Fabel 1 год назад
Родитель
Сommit
0a4fc41220
7 измененных файлов с 79 добавлено и 43 удалено
  1. 1 0
      .gitignore
  2. 2 1
      Makefile
  3. 1 1
      docs/pages/conf.py
  4. 62 15
      docs/pages/reference.rst
  5. 0 6
      flipperzero/__init__.py
  6. 0 16
      flipperzero/_builtins.py
  7. 13 4
      flipperzero/_modal.py

+ 1 - 0
.gitignore

@@ -1,5 +1,6 @@
 /dist/
 /venv/
+/flipperzero/__init__.py
 .vscode
 .clang-format
 .clangd

+ 2 - 1
Makefile

@@ -16,7 +16,8 @@ clean:
 
 .PHONY: pages
 pages:
-	rm -rf ./dist/pages
+	rm -rf ./dist/pages ./flipperzero/__init__.py
+	cat ./flipperzero/_*.py > ./flipperzero/__init__.py
 	source venv/bin/activate && sphinx-build docs/pages dist/pages
 
 .PHONY: publish

+ 1 - 1
docs/pages/conf.py

@@ -57,4 +57,4 @@ autodoc_default_options = {
     'member-order': 'bysource',
 }
 
-add_module_names = False
+add_module_names = True

+ 62 - 15
docs/pages/reference.rst

@@ -1,55 +1,91 @@
 Reference
 =========
 
-This page contains the API documentation of the ``flipperzero`` module.
+This page contains the API documentation of the ``flipperzero`` module and some built-in functions.
 
 Vibration
 ---------
 
 Control the vibration motor of your Flipper.
 
-.. automodule:: flipperzero._vibro
-   :members:
+.. autofunction:: flipperzero.vibro_set
 
 Light
 -----
 
 Control the RGB LED and display backlight of your Flipper.
 
-.. automodule:: flipperzero._light
-   :members:
+.. autodata:: flipperzero.LIGHT_RED
+.. autodata:: flipperzero.LIGHT_GREEN
+.. autodata:: flipperzero.LIGHT_BLUE
+.. autodata:: flipperzero.LIGHT_BACKLIGHT
+.. autofunction:: flipperzero.light_set
+.. autofunction:: flipperzero.light_blink_start
+.. autofunction:: flipperzero.light_blink_set_color
+.. autofunction:: flipperzero.light_blink_stop
 
 Speaker
 -------
 
 Full control over the built-in speaker module.
 
-.. automodule:: flipperzero._speaker
-   :members:
+.. autofunction:: flipperzero.speaker_start
+.. autofunction:: flipperzero.speaker_set_volume
+.. autofunction:: flipperzero.speaker_stop
 
 Input
 -----
 
 Make your application interactive with full control over the Flipper's hardware buttons.
 
-.. automodule:: flipperzero._input
-   :members:
+.. autodata:: flipperzero.INPUT_BUTTON_UP
+.. autodata:: flipperzero.INPUT_BUTTON_DOWN
+.. autodata:: flipperzero.INPUT_BUTTON_RIGHT
+.. autodata:: flipperzero.INPUT_BUTTON_LEFT
+.. autodata:: flipperzero.INPUT_BUTTON_OK
+.. autodata:: flipperzero.INPUT_BUTTON_BACK
+.. autodata:: flipperzero.INPUT_TYPE_PRESS
+.. autodata:: flipperzero.INPUT_TYPE_RELEASE
+.. autodata:: flipperzero.INPUT_TYPE_SHORT
+.. autodata:: flipperzero.INPUT_TYPE_LONG
+.. autodata:: flipperzero.INPUT_TYPE_REPEAT
+.. autodecorator:: flipperzero.on_input
 
 Canvas
 ------
 
 Write text and draw dots and shapes on the the display.
 
-.. automodule:: flipperzero._canvas
-   :members:
+.. autofunction:: flipperzero.canvas_update
+.. autofunction:: flipperzero.canvas_clear
+.. autofunction:: flipperzero.canvas_width
+.. autofunction:: flipperzero.canvas_height
+.. autodata:: flipperzero.COLOR_BLACK
+.. autodata:: flipperzero.COLOR_WHITE
+.. autofunction:: flipperzero.canvas_set_color
+.. autodata:: flipperzero.ALIGN_BEGIN
+.. autodata:: flipperzero.ALIGN_END
+.. autodata:: flipperzero.ALIGN_CENTER
+.. autofunction:: flipperzero.canvas_set_text_align
+.. autodata:: flipperzero.FONT_PRIMARY
+.. autodata:: flipperzero.FONT_SECONDARY
+.. autofunction:: flipperzero.canvas_set_font
+.. autofunction:: flipperzero.canvas_set_text
+.. autofunction:: flipperzero.canvas_draw_dot
+.. autofunction:: flipperzero.canvas_draw_box
+.. autofunction:: flipperzero.canvas_draw_frame
+.. autofunction:: flipperzero.canvas_draw_line
+.. autofunction:: flipperzero.canvas_draw_circle
+.. autofunction:: flipperzero.canvas_draw_disc
 
 Dialog
 ------
 
 Display message dialogs on the display for user infos and confirm actions.
 
-.. automodule:: flipperzero._modal
-   :members:
+.. autofunction:: flipperzero.dialog_message_set_header
+.. autofunction:: flipperzero.dialog_message_set_text
+.. autofunction:: flipperzero.dialog_message_set_button
 
 Built-In
 --------
@@ -57,5 +93,16 @@ Built-In
 The functions in this section are `not` part of the ``flipperzero`` module.
 They're members of the global namespace instead.
 
-.. automodule:: flipperzero._builtins
-   :members:
+.. py:function:: print(*objects, sep=' ', end='\n', file=None, flush=False) -> None
+
+   The standard Python `print <https://docs.python.org/3/library/functions.html#print>`_ function.
+
+   :param objects: The objects to print (mostly a single string).
+   :param sep: The separator to use between the objects.
+   :param end: The line terminator character to use.
+
+   .. attention::
+      
+      This function prints to the internal log buffer.
+      Check out the `Flipper Zero docs <https://docs.flipper.net/development/cli#_yZ2E>`_ on how to reveal them in the CLI interface.
+

+ 0 - 6
flipperzero/__init__.py

@@ -1,6 +0,0 @@
-from ._canvas import *
-from ._input import *
-from ._light import *
-from ._speaker import *
-from ._vibro import *
-from ._builtins import *

+ 0 - 16
flipperzero/_builtins.py

@@ -1,16 +0,0 @@
-def print(*objects, sep=' ', end='\n', file=None, flush=False) -> None:
-    '''
-    The standard Python `print <https://docs.python.org/3/library/functions.html#print>`_ function.
-
-    :param objects: The objects to print (mostly a single string).
-    :param sep: The separator to use between the objects.
-    :param end: The line terminator character to use.
-
-    .. attention::
-
-        This function prints to the internal log buffer.
-        Check out the `Flipper Zero docs <https://docs.flipper.net/development/cli#_yZ2E>`_ on how to reveal them in the CLI interface.
-    
-
-    '''
-    pass

+ 13 - 4
flipperzero/_modal.py

@@ -1,6 +1,6 @@
-def dialog_message_set_text(text:str, x: int, y: int, h: int, v: int) -> None:
+def dialog_message_set_header(text: str, x: int, y: int, h: int, v: int) -> None:
     '''
-    Set a text on the dialog box.
+    Set a header text on the dialog box.
 
     :param text: The text to set.
     :param x: The x coordinates to use.
@@ -10,9 +10,9 @@ def dialog_message_set_text(text:str, x: int, y: int, h: int, v: int) -> None:
     '''
     pass
 
-def dialog_message_set_header(text:str, x: int, y: int, h: int, v: int) -> None:
+def dialog_message_set_text(text: str, x: int, y: int, h: int, v: int) -> None:
     '''
-    Set a header text on the dialog box.
+    Set a text on the dialog box.
 
     :param text: The text to set.
     :param x: The x coordinates to use.
@@ -21,3 +21,12 @@ def dialog_message_set_header(text:str, x: int, y: int, h: int, v: int) -> None:
     :param v: The vertical alignment.
     '''
     pass
+
+def dialog_message_set_button(text: str, button: int) -> None:
+    '''
+    Set the text of a dialog box button.
+
+    :param text: The text to set.
+    :param button: The button to use (e.g. :const:`flipperzero._input.INPUT_BUTTON_UP`).
+    '''
+    pass