diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d4bb2cbb9eddb1bb1b4f366623044af8e4830919 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/badge/badge_link.rst b/docs/badge/badge_link.rst new file mode 100644 index 0000000000000000000000000000000000000000..f5a7c1e582f6ea2f4333a308eab5ba112501e769 --- /dev/null +++ b/docs/badge/badge_link.rst @@ -0,0 +1,19 @@ +.. _Badge Link: + +Badge Link +========== + +Badge Link is a protocol for digital communication over the 3.5mm ports. + +You can configure individual pins (tip, ring) of each of the two 3.5mm ports +(line in, line out) to be used as TX or RX for UART, at any baud rate up to +5mbit in theory. In practice lower baud rates are recommended to avoid data +corruption. + +MIDI can be used by configuring the baud rate to 31250. There is no galvanic +isolation, but there are current limiting resistors. + +The input protection can handle between +5v and -3v. + +For the micropython badge link API, see the :ref:`badge_link<py_badge_link>` API docs + diff --git a/docs/badge/hardware_specs.rst b/docs/badge/hardware_specs.rst new file mode 100644 index 0000000000000000000000000000000000000000..5bf6f4d6754fbbc7f89b89b7f694b003c87c3bc4 --- /dev/null +++ b/docs/badge/hardware_specs.rst @@ -0,0 +1,28 @@ +Hardware Specs +============== + +* ESP32-S3 SoC + * 240MHz + * 8MiB SPI RAM, 512KiB SRAM + * 16MiB flash + * WiFi (2.4GHz, b/g/n) + * Bluetooth LE (no bluetooth audio) +* Round display, 240x240px, compatible with GC9A01 +* Two speakers +* Two 3.5mm ports + * Headphone / line out and microphone / line in + * :ref:`Badge Link` + * Can be configured in each 3.5mm port (3.3v UART) + * MIDI compatible (31250 baud UART) +* USB-C + * Two modes: + * USB Serial/JTAG (implemented in hardware) + * TinyUSB (for serial, mass storage, USB MIDI) + * SBU1/SBU2 (sideband use) pins have UART RX/TX for early debug + * Passive analog audio out + * Not supported: USB host +* 40 RGB LEDs (WS2812C) +* MicroSD card slot +* Accelerometer? XXX +* Battery compatible with MCH2022 badge + diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..f2f3093b2b0d4138d53c28ff4739f7542cf15baa --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,29 @@ +import os + +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'flow3r' +copyright = '2023' +author = 'ccc' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinx_rtd_theme' +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..7c2063b85c02e71eb3cced4b6d63d93590b57ad8 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,29 @@ +.. flow3r documentation master file, created by + sphinx-quickstart on Sun Jun 11 19:43:11 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to flow3r's documentation! +================================== + +.. toctree:: + :maxdepth: 1 + :caption: The badge: + + badge/hardware_specs.rst + badge/badge_link.rst + +.. toctree:: + :maxdepth: 1 + :caption: Python API: + + python/overview.rst + python/audio.rst + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000000000000000000000000000000000000..32bb24529f92346af26219baed295b7488b77534 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/python/audio.rst b/docs/python/audio.rst new file mode 100644 index 0000000000000000000000000000000000000000..f9e650e40dc0438a817b76d1b7d3ea71c5ea266e --- /dev/null +++ b/docs/python/audio.rst @@ -0,0 +1,79 @@ +.. py:module:: audio + +``audio`` module +================ + +(XXX when it says bool in the python api that's often an int, should change +that) + +.. py:function:: headset_is_connected() -> bool +.. c:function:: uint8_t audio_headset_is_connected() + + Returns 1 if headphones with microphone were connected to the headphone + jack at the last call of audio_update_jacksense. + +.. py:function:: headphones_are_connected() -> bool +.. c:function:: uint8_t audio_headphones_are_connected() + + Returns 1 if headphones with or without microphone were connected to the + headphone jack at the last call of audio_update_jacksense. + +.. py:function:: headphones_detection_override(enable : bool) +.. c:function:: void audio_headphones_detection_override(uint8_t enable) + + If a sleeve contact mic doesn't pull the detection pin low enough the + codec's built in headphone detection might fail. Calling this function + with 'enable = 1' overrides the detection and assumes there's headphones + plugged in. Call with 'enable = 0' to revert to automatic detection. + +.. py:function:: headphones_set_volume_dB(vol_dB : float) -> float +.. c:function:: float audio_headphones_set_volume_dB(float vol_dB); +.. py:function:: speaker_set_volume_dB(vol_dB : float) -> float +.. c:function:: float audio_speaker_set_volume_dB(float vol_dB); +.. py:function:: set_volume_dB(vol_dB : float) -> float +.. c:function:: float audio_set_volume_dB(float vol_dB); + + Attempts to set target volume for the headphone output/onboard speakers + respectively, clamps/rounds if necessary and returns the actual volume. + Absolute reference arbitrary. + Does not unmute, use :code:`audio_{headphones_/speaker_/}set_mute` as + needed. + Enters fake mute if requested volume is below the value set by + :code:`audio_{headphones/speaker}_set_minimum_volume_user`. + + Note: This function uses a hardware PGA for the coarse value and software + for the fine value. These two methods are as of yet not synced so that + there may be a transient volume "hiccup". "p1" badges only use software + volume. The unspecified variant automatically chooses the adequate channel + (**). + + +.. py:function:: headphones_adjust_volume_dB +.. py:function:: speaker_adjust_volume_dB +.. py:function:: adjust_volume_dB + +.. py:function:: headphones_get_volume_dB +.. py:function:: speaker_get_volume_dB +.. py:function:: get_volume_dB + +.. py:function:: headphones_get_mute +.. py:function:: speaker_get_mute +.. py:function:: get_mute + +.. py:function:: headphones_set_mute +.. py:function:: speaker_set_mute +.. py:function:: set_mute + +.. py:function:: headphones_set_minimum_volume_dB +.. py:function:: speaker_set_minimum_volume_dB +.. py:function:: headphones_set_maximum_volume_dB +.. py:function:: speaker_set_maximum_volume_dB + +.. py:function:: headphones_get_minimum_volume_dB +.. py:function:: speaker_get_minimum_volume_dB +.. py:function:: headphones_get_maximum_volume_dB +.. py:function:: speaker_get_maximum_volume_dB + +.. py:function:: headphones_get_volume_relative +.. py:function:: speaker_get_volume_relative +.. py:function:: get_volume_relative diff --git a/docs/python/overview.rst b/docs/python/overview.rst new file mode 100644 index 0000000000000000000000000000000000000000..f943ce22cfaefaf25c953c1ffe21c0e0a0127d34 --- /dev/null +++ b/docs/python/overview.rst @@ -0,0 +1,2 @@ +Python API +==========