Skip to content

Commit f694d14

Browse files
committed
level up documentation comments
This fixes assorted Sphinx documentation stuff: 1. Add CSS workaround for horizontal stacking glitch in rtd theme 2. Convert plain comments for public constants to doc-comment style so they will get included in the html docs 3. Change Sphinx autodoc's default sort order from alphabetical to groupwise. Now the class methods come first, the properties come next, and the constants go at the end. It's much easier to read this way.
1 parent 71294d0 commit f694d14

File tree

3 files changed

+89
-38
lines changed

3 files changed

+89
-38
lines changed

adafruit_tlv320.py

Lines changed: 79 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
1616
**Hardware:**
1717
18+
* `Adafruit TLV320DAC3100 - I2S DAC <https://www.adafruit.com/product/6309>`_
19+
20+
* `Adafruit Fruit Jam <https://www.adafruit.com/product/6200>`_
21+
22+
1823
* The TLV320DAC chip has moderately complex onboard audio filtering, routing,
1924
and amplification capability. Each of the signal chains for speaker, headphone
2025
left, and headphone right start with the DAC, then they go through a mixer
@@ -122,56 +127,92 @@
122127
DATA_LEN_32 = const(0b11) # 32 bits
123128

124129
# GPIO1 pin mode options
125-
GPIO1_DISABLED = const(0b0000) # GPIO1 disabled (input and output buffers powered down)
126-
GPIO1_INPUT_MODE = const(0b0001) # Input mode (secondary BCLK/WCLK/DIN input or ClockGen)
127-
GPIO1_GPI = const(0b0010) # General-purpose input
128-
GPIO1_GPO = const(0b0011) # General-purpose output
129-
GPIO1_CLKOUT = const(0b0100) # CLKOUT output
130-
GPIO1_INT1 = const(0b0101) # INT1 output
131-
GPIO1_INT2 = const(0b0110) # INT2 output
132-
GPIO1_BCLK_OUT = const(0b1000) # Secondary BCLK output for codec interface
133-
GPIO1_WCLK_OUT = const(0b1001) # Secondary WCLK output for codec interface
130+
#: GPIO1 pin mode options: GPIO1 disabled (input and output buffers powered down)
131+
GPIO1_DISABLED = const(0b0000)
132+
#: GPIO1 pin mode options: Input mode (secondary BCLK/WCLK/DIN input or ClockGen)
133+
GPIO1_INPUT_MODE = const(0b0001)
134+
#: GPIO1 pin mode options: General-purpose input
135+
GPIO1_GPI = const(0b0010)
136+
#: GPIO1 pin mode options: General-purpose output
137+
GPIO1_GPO = const(0b0011)
138+
#: GPIO1 pin mode options: CLKOUT output
139+
GPIO1_CLKOUT = const(0b0100)
140+
#: GPIO1 pin mode options: INT1 output
141+
GPIO1_INT1 = const(0b0101)
142+
#: GPIO1 pin mode options: INT2 output
143+
GPIO1_INT2 = const(0b0110)
144+
#: GPIO1 pin mode options: Secondary BCLK output for codec interface
145+
GPIO1_BCLK_OUT = const(0b1000)
146+
#: GPIO1 pin mode options: Secondary WCLK output for codec interface
147+
GPIO1_WCLK_OUT = const(0b1001)
134148

135149
# DAC channel data path options
136-
DAC_PATH_OFF = const(0b00) # DAC data path off
137-
DAC_PATH_NORMAL = const(0b01) # Normal path (L->L or R->R)
138-
DAC_PATH_SWAPPED = const(0b10) # Swapped path (R->L or L->R)
139-
DAC_PATH_MIXED = const(0b11) # Mixed L+R path
150+
#: DAC channel data path option: DAC data path off
151+
DAC_PATH_OFF = const(0b00)
152+
#: DAC channel data path option: Normal path (L->L or R->R)
153+
DAC_PATH_NORMAL = const(0b01)
154+
#: DAC channel data path option: Swapped path (R->L or L->R)
155+
DAC_PATH_SWAPPED = const(0b10)
156+
#: DAC channel data path option: Mixed L+R path
157+
DAC_PATH_MIXED = const(0b11)
140158

141159
# DAC volume control soft stepping options
142-
VOLUME_STEP_1SAMPLE = const(0b00) # One step per sample
143-
VOLUME_STEP_2SAMPLE = const(0b01) # One step per two samples
144-
VOLUME_STEP_DISABLED = const(0b10) # Soft stepping disabled
160+
#: DAC volume control soft stepping option: One step per sample
161+
VOLUME_STEP_1SAMPLE = const(0b00)
162+
#: DAC volume control soft stepping option: One step per two samples
163+
VOLUME_STEP_2SAMPLE = const(0b01)
164+
#: DAC volume control soft stepping option: Soft stepping disabled
165+
VOLUME_STEP_DISABLED = const(0b10)
145166

146167
# DAC volume control configuration options
147-
VOL_INDEPENDENT = const(0b00) # Left and right channels independent
148-
VOL_LEFT_TO_RIGHT = const(0b01) # Left follows right volume
149-
VOL_RIGHT_TO_LEFT = const(0b10) # Right follows left volume
168+
#: DAC volume control configuration option: Left and right channels independent
169+
VOL_INDEPENDENT = const(0b00)
170+
#: DAC volume control configuration option: Left follows right volume
171+
VOL_LEFT_TO_RIGHT = const(0b01)
172+
#: DAC volume control configuration option: Right follows left volume
173+
VOL_RIGHT_TO_LEFT = const(0b10)
150174

151175
# DAC output routing options
152-
DAC_ROUTE_NONE = const(0b00) # DAC not routed
153-
DAC_ROUTE_MIXER = const(0b01) # DAC routed to mixer amplifier
154-
DAC_ROUTE_HP = const(0b10) # DAC routed directly to HP driver
155-
156-
# Headphone common mode voltage settings
157-
HP_COMMON_1_35V = const(0b00) # Common-mode voltage 1.35V
158-
HP_COMMON_1_50V = const(0b01) # Common-mode voltage 1.50V
159-
HP_COMMON_1_65V = const(0b10) # Common-mode voltage 1.65V
160-
HP_COMMON_1_80V = const(0b11) # Common-mode voltage 1.80V
176+
#: DAC output routing option: DAC not routed
177+
DAC_ROUTE_NONE = const(0b00)
178+
#: DAC output routing option: DAC routed to mixer amplifier
179+
DAC_ROUTE_MIXER = const(0b01)
180+
#: DAC output routing option: DAC routed directly to HP driver
181+
DAC_ROUTE_HP = const(0b10)
182+
183+
# Headphone common mode voltage options
184+
#: Headphone common mode voltage option: Common-mode voltage 1.35V
185+
HP_COMMON_1_35V = const(0b00)
186+
#: Headphone common mode voltage option: Common-mode voltage 1.50V
187+
HP_COMMON_1_50V = const(0b01)
188+
#: Headphone common mode voltage option: Common-mode voltage 1.65V
189+
HP_COMMON_1_65V = const(0b10)
190+
#: Headphone common mode voltage option: Common-mode voltage 1.80V
191+
HP_COMMON_1_80V = const(0b11)
161192

162193
# Headset detection debounce time options
163-
DEBOUNCE_16MS = const(0b000) # 16ms debounce (2ms clock)
164-
DEBOUNCE_32MS = const(0b001) # 32ms debounce (4ms clock)
165-
DEBOUNCE_64MS = const(0b010) # 64ms debounce (8ms clock)
166-
DEBOUNCE_128MS = const(0b011) # 128ms debounce (16ms clock)
167-
DEBOUNCE_256MS = const(0b100) # 256ms debounce (32ms clock)
168-
DEBOUNCE_512MS = const(0b101) # 512ms debounce (64ms clock)
194+
#: Headset detection debounce time option: 16ms debounce (2ms clock)
195+
DEBOUNCE_16MS = const(0b000)
196+
#: Headset detection debounce time option: 32ms debounce (4ms clock)
197+
DEBOUNCE_32MS = const(0b001)
198+
#: Headset detection debounce time option: 64ms debounce (8ms clock)
199+
DEBOUNCE_64MS = const(0b010)
200+
#: Headset detection debounce time option: 128ms debounce (16ms clock)
201+
DEBOUNCE_128MS = const(0b011)
202+
#: Headset detection debounce time option: 256ms debounce (32ms clock)
203+
DEBOUNCE_256MS = const(0b100)
204+
#: Headset detection debounce time option: 512ms debounce (64ms clock)
205+
DEBOUNCE_512MS = const(0b101)
169206

170207
# Button press debounce time options
171-
BTN_DEBOUNCE_0MS = const(0b00) # No debounce
172-
BTN_DEBOUNCE_8MS = const(0b01) # 8ms debounce (1ms clock)
173-
BTN_DEBOUNCE_16MS = const(0b10) # 16ms debounce (2ms clock)
174-
BTN_DEBOUNCE_32MS = const(0b11) # 32ms debounce (4ms clock)
208+
#: Button press debounce time option: No debounce
209+
BTN_DEBOUNCE_0MS = const(0b00)
210+
#: Button press debounce time option: 8ms debounce (1ms clock)
211+
BTN_DEBOUNCE_8MS = const(0b01)
212+
#: Button press debounce time option: 16ms debounce (2ms clock)
213+
BTN_DEBOUNCE_16MS = const(0b10)
214+
#: Button press debounce time option: 32ms debounce (4ms clock)
215+
BTN_DEBOUNCE_32MS = const(0b11)
175216

176217
# Lookup table for speaker_volume and headphone_volume.
177218
# These are from TLV320DAC3100 datasheet Table 6-24.

docs/_static/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Monkey patch the rtd theme to prevent horizontal stacking of short items
2+
* see https://github.com/readthedocs/sphinx_rtd_theme/issues/1301
3+
*/
4+
.py.property{display: block !important;}

docs/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
autodoc_preserve_defaults = True
3131

32+
# Override the default config in which autodoc sorts things alphabetically
33+
autodoc_member_order = 'groupwise'
34+
3235
intersphinx_mapping = {
3336
"python": ("https://docs.python.org/3", None),
3437
"BusDevice": ("https://docs.circuitpython.org/projects/busdevice/en/latest/", None),
@@ -117,6 +120,9 @@
117120
# so a file named "default.css" will overwrite the builtin "default.css".
118121
html_static_path = ["_static"]
119122

123+
# Include extra css to work around rtd theme glitches
124+
html_css_files = ['custom.css']
125+
120126
# The name of an image file (relative to this directory) to use as a favicon of
121127
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
122128
# pixels large.

0 commit comments

Comments
 (0)