Skip to content

Commit 3573cc1

Browse files
committed
Add doc for dac2 and miniscale.
1 parent d81f265 commit 3573cc1

File tree

5 files changed

+232
-90
lines changed

5 files changed

+232
-90
lines changed

docs/en/refs/unit.dac2.ref

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. |DAC2Unit| image:: https://static-cdn.m5stack.com/resource/docs/products/unit/Unit-DAC2/img-d3d02dea-e7ad-4543-ae7c-84957de8329e.webp
2+
:target: https://docs.m5stack.com/en/unit/Unit-DAC2
3+
:height: 200px
4+
:width: 200 px
5+
6+
.. |DAC2Hat| image:: https://static-cdn.m5stack.com/resource/docs/products/hat/Hat-DAC2/img-26204d9b-195c-4c62-afbb-5b3232c09381.webp
7+
:target: https://docs.m5stack.com/en/hat/Hat-DAC2
8+
:height: 200px
9+
:width: 200 px
10+
11+
.. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/init.svg
12+
13+
.. |setDACOutputVoltageRange.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/setDACOutputVoltageRange.svg
14+
15+
.. |setVoltage.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/setVoltage.svg
16+
17+
.. |setVoltageBoth.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/setVoltageBoth.svg
18+
19+
.. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/example.svg

docs/en/refs/unit.miniscale.ref

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,31 @@
22
:target: https://docs.m5stack.com/en/unit/Unit-Mini%20Scales
33
:height: 200px
44
:width: 200 px
5+
6+
.. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/init.svg
7+
8+
.. |calibration.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/calibration.svg
9+
10+
.. |getAverageFilterLevel.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/getAverageFilterLevel.svg
11+
12+
.. |getEMAFilterAlpha.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/getEMAFilterAlpha.svg
13+
14+
.. |getLowPassFilter.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/getLowPassFilter.svg
15+
16+
.. |get_adc.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/get_adc.svg
17+
18+
.. |get_button.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/get_button.svg
19+
20+
.. |get_weight.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/get_weight.svg
21+
22+
.. |reset.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/reset.svg
23+
24+
.. |setAverageFilterLevel.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setAverageFilterLevel.svg
25+
26+
.. |setEMAFilterAlpha.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setEMAFilterAlpha.svg
27+
28+
.. |setLed.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setLed.svg
29+
30+
.. |setLowPassFilter.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setLowPassFilter.svg
31+
32+
.. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/example.svg

docs/en/units/dac2.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
DAC2 Unit
2+
=========
3+
4+
.. include:: ../refs/unit.dac2.ref
5+
6+
The `Dac2` class interfaces with a GP8413 15-bit Digital to Analog Converter (DAC), capable of converting digital signals into two channels of analog voltage output, ranging from 0-5V and 0-10V.
7+
8+
Support the following products:
9+
10+
11+
|DAC2Unit|
12+
13+
|DAC2Hat|
14+
15+
16+
17+
Micropython Example::
18+
19+
import os, sys, io
20+
import M5
21+
from M5 import *
22+
import time
23+
from unit import DAC2Unit
24+
25+
i2c = I2C(0, scl=Pin(1), sda=Pin(2), freq=400000)
26+
dac2_0 = DAC2Unit(i2c0, 0x59)
27+
dac2_0.setDACOutputVoltageRange(dac2_0.RANGE_10V)
28+
dac2_0.setVoltage(7.5, channel=dac2_0.CHANNEL_BOTH)
29+
30+
31+
UIFLOW2 Example:
32+
33+
|example.svg|
34+
35+
36+
.. only:: builder_html
37+
38+
39+
class DAC2Unit
40+
--------------
41+
42+
Constructors
43+
---------------------------
44+
45+
.. class:: DAC2Unit(i2c0, addr)
46+
47+
Create an DAC2Unit object.
48+
49+
- ``I2C0`` is I2C Port.
50+
- ``addr`` I2C address of the DAC (default is `0x59`)..
51+
52+
UIFLOW2:
53+
54+
|init.svg|
55+
56+
57+
Methods
58+
----------------------
59+
60+
.. method:: MiniScaleUnit.setDACOutputVoltageRange(_range)
61+
62+
63+
Sets the output voltage range of the DAC.
64+
65+
- ``_range`` The DAC output voltage range, either `DAC2Unit.RANGE_5V` or `DAC2Unit.RANGE_10V`..
66+
67+
UIFLOW2:
68+
69+
|setDACOutputVoltageRange.svg|
70+
71+
.. method:: MiniScaleUnit.setVoltage(voltage, channel=Dac2.CHANNEL_BOTH)
72+
73+
74+
Sets the output voltage of the DAC.
75+
76+
- ``voltage`` Desired output voltage from 0.0 to range maximum (5V or 10V).
77+
- ``channel`` The DAC channel to set. Options are `Dac2.CHANNEL_0`, `Dac2.CHANNEL_1`, or `Dac2.CHANNEL_BOTH`.
78+
79+
UIFLOW2:
80+
81+
|setVoltage.svg|
82+
83+
84+
.. method:: MiniScaleUnit.setVoltageBoth(voltage0, voltage1)
85+
86+
87+
Sets the output voltage for both channels.
88+
89+
- ``voltage0`` Desired output voltage from 0.0 to range maximum (5V or 10V).
90+
- ``voltage1`` Desired output voltage from 0.0 to range maximum (5V or 10V).
91+
92+
UIFLOW2:
93+
94+
|setVoltageBoth.svg|

docs/en/units/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Unit
2020
op90.rst
2121
op180.rst
2222
miniscale.rst
23+
dac2.rst

0 commit comments

Comments
 (0)