Skip to content

Commit

Permalink
Add doc for dac2 and miniscale.
Browse files Browse the repository at this point in the history
  • Loading branch information
icyqwq committed Jan 17, 2024
1 parent d81f265 commit 3573cc1
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 90 deletions.
19 changes: 19 additions & 0 deletions docs/en/refs/unit.dac2.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. |DAC2Unit| image:: https://static-cdn.m5stack.com/resource/docs/products/unit/Unit-DAC2/img-d3d02dea-e7ad-4543-ae7c-84957de8329e.webp
:target: https://docs.m5stack.com/en/unit/Unit-DAC2
:height: 200px
:width: 200 px

.. |DAC2Hat| image:: https://static-cdn.m5stack.com/resource/docs/products/hat/Hat-DAC2/img-26204d9b-195c-4c62-afbb-5b3232c09381.webp
:target: https://docs.m5stack.com/en/hat/Hat-DAC2
:height: 200px
:width: 200 px

.. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/init.svg

.. |setDACOutputVoltageRange.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/setDACOutputVoltageRange.svg

.. |setVoltage.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/setVoltage.svg

.. |setVoltageBoth.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/setVoltageBoth.svg

.. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/dac2/example.svg
28 changes: 28 additions & 0 deletions docs/en/refs/unit.miniscale.ref
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,31 @@
:target: https://docs.m5stack.com/en/unit/Unit-Mini%20Scales
:height: 200px
:width: 200 px

.. |init.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/init.svg

.. |calibration.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/calibration.svg

.. |getAverageFilterLevel.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/getAverageFilterLevel.svg

.. |getEMAFilterAlpha.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/getEMAFilterAlpha.svg

.. |getLowPassFilter.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/getLowPassFilter.svg

.. |get_adc.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/get_adc.svg

.. |get_button.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/get_button.svg

.. |get_weight.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/get_weight.svg

.. |reset.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/reset.svg

.. |setAverageFilterLevel.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setAverageFilterLevel.svg

.. |setEMAFilterAlpha.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setEMAFilterAlpha.svg

.. |setLed.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setLed.svg

.. |setLowPassFilter.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/setLowPassFilter.svg

.. |example.svg| image:: https://static-cdn.m5stack.com/mpy_docs/unit/miniscales/example.svg
94 changes: 94 additions & 0 deletions docs/en/units/dac2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
DAC2 Unit
=========

.. include:: ../refs/unit.dac2.ref

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.

Support the following products:


|DAC2Unit|

|DAC2Hat|



Micropython Example::

import os, sys, io
import M5
from M5 import *
import time
from unit import DAC2Unit

i2c = I2C(0, scl=Pin(1), sda=Pin(2), freq=400000)
dac2_0 = DAC2Unit(i2c0, 0x59)
dac2_0.setDACOutputVoltageRange(dac2_0.RANGE_10V)
dac2_0.setVoltage(7.5, channel=dac2_0.CHANNEL_BOTH)


UIFLOW2 Example:

|example.svg|


.. only:: builder_html


class DAC2Unit
--------------

Constructors
---------------------------

.. class:: DAC2Unit(i2c0, addr)

Create an DAC2Unit object.

- ``I2C0`` is I2C Port.
- ``addr`` I2C address of the DAC (default is `0x59`)..

UIFLOW2:

|init.svg|


Methods
----------------------

.. method:: MiniScaleUnit.setDACOutputVoltageRange(_range)


Sets the output voltage range of the DAC.

- ``_range`` The DAC output voltage range, either `DAC2Unit.RANGE_5V` or `DAC2Unit.RANGE_10V`..

UIFLOW2:

|setDACOutputVoltageRange.svg|

.. method:: MiniScaleUnit.setVoltage(voltage, channel=Dac2.CHANNEL_BOTH)


Sets the output voltage of the DAC.

- ``voltage`` Desired output voltage from 0.0 to range maximum (5V or 10V).
- ``channel`` The DAC channel to set. Options are `Dac2.CHANNEL_0`, `Dac2.CHANNEL_1`, or `Dac2.CHANNEL_BOTH`.

UIFLOW2:

|setVoltage.svg|


.. method:: MiniScaleUnit.setVoltageBoth(voltage0, voltage1)


Sets the output voltage for both channels.

- ``voltage0`` Desired output voltage from 0.0 to range maximum (5V or 10V).
- ``voltage1`` Desired output voltage from 0.0 to range maximum (5V or 10V).

UIFLOW2:

|setVoltageBoth.svg|
1 change: 1 addition & 0 deletions docs/en/units/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Unit
op90.rst
op180.rst
miniscale.rst
dac2.rst
Loading

0 comments on commit 3573cc1

Please sign in to comment.