Skip to content

Commit 3306e1a

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop-pandian
2 parents c6c1c38 + 3573cc1 commit 3306e1a

File tree

16 files changed

+1008
-494
lines changed

16 files changed

+1008
-494
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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. |MINISCALE| image:: https://static-cdn.m5stack.com/resource/docs/products/unit/Unit-Mini%20Scales/img-b9cc6e44-bd3c-4256-bd72-5fb45423483c.webp
2+
:target: https://docs.m5stack.com/en/unit/Unit-Mini%20Scales
3+
:height: 200px
4+
: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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ Unit
1919
relay.rst
2020
op90.rst
2121
op180.rst
22+
miniscale.rst
23+
dac2.rst

docs/en/units/miniscale.rst

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
Miniscale Unit
2+
==============
3+
4+
.. include:: ../refs/unit.miniscale.ref
5+
6+
The ``Miniscale`` class is designed for interfacing with a mini scale weight sensor, which includes a HX711 22-bit ADC. This sensor is capable of measuring weight and also includes additional functionalities like LED control and various filters.
7+
8+
Support the following products:
9+
10+
11+
|MINISCALE|
12+
13+
14+
15+
Micropython Example::
16+
17+
import os, sys, io
18+
import M5
19+
from M5 import *
20+
import time
21+
from unit import MiniScaleUnit
22+
23+
i2c = I2C(0, scl=Pin(1), sda=Pin(2), freq=400000)
24+
scale = MiniScaleUnit(i2c)
25+
scale.setLed(255, 0, 0)
26+
print(miniscale.weight)
27+
28+
29+
UIFLOW2 Example:
30+
31+
|example.svg|
32+
33+
34+
.. only:: builder_html
35+
36+
37+
class MiniScaleUnit
38+
-------------------
39+
40+
Constructors
41+
---------------------------
42+
43+
.. class:: MiniScaleUnit(i2c0)
44+
45+
Create an MiniScaleUnit object.
46+
47+
- ``I2C0`` is I2C Port.
48+
49+
50+
UIFLOW2:
51+
52+
|init.svg|
53+
54+
55+
Methods
56+
----------------------
57+
58+
.. method:: MiniScaleUnit.adc
59+
60+
61+
Gets the raw adc readout.
62+
63+
UIFLOW2:
64+
65+
|get_adc.svg|
66+
67+
.. method:: MiniScaleUnit.weight
68+
69+
70+
Gets the weight readout in grams.
71+
72+
UIFLOW2:
73+
74+
|get_weight.svg|
75+
76+
77+
.. method:: MiniScaleUnit.button
78+
79+
80+
Gets the button state.
81+
82+
UIFLOW2:
83+
84+
|get_button.svg|
85+
86+
.. method:: MiniScaleUnit.setLed(r, g, b)
87+
88+
Sets the RGB LED color.
89+
90+
- ``r``: Red value (0 - 255).
91+
- ``g``: Green value (0 - 255).
92+
- ``b``: Blue value (0 - 255).
93+
94+
UIFLOW2:
95+
96+
|setLed.svg|
97+
98+
.. method:: MiniScaleUnit.reset
99+
100+
Resets sensor.
101+
102+
103+
UIFLOW2:
104+
105+
|reset.svg|
106+
107+
.. method:: MiniScaleUnit.calibration(weight1_g, weight1_adc, weight2_g, weight2_adc)
108+
109+
110+
Calibrates the MiniScale sensor.
111+
112+
- ``weight1_g``: Weight1 in grams.
113+
- ``weight1_adc``: Weight1 in ADC value.
114+
- ``weight2_g``: Weight2 in grams.
115+
- ``weight2_adc``: Weight2 in ADC value.
116+
117+
calibration steps:
118+
119+
1. Reset sensor;
120+
2. Get adc, this is weight1_adc (should be zero). And weight1_g is also 0.
121+
3. Put some weight on it, then get adc, this is weight2_adc. And weight2_g is weight in gram you put on it.
122+
123+
124+
UIFLOW2:
125+
126+
|calibration.svg|
127+
128+
.. method:: MiniScaleUnit.setLowPassFilter(enable)
129+
130+
Enables or disables the low pass filter.
131+
132+
133+
UIFLOW2:
134+
135+
|setLowPassFilter.svg|
136+
137+
138+
.. method:: MiniScaleUnit.getLowPassFilter
139+
140+
Returns the status of the low pass filter (enabled or not).
141+
142+
143+
UIFLOW2:
144+
145+
|getLowPassFilter.svg|
146+
147+
.. method:: MiniScaleUnit.setAverageFilterLevel(level)
148+
149+
Sets the level of the average filter.
150+
151+
- ``level``: Level of the average filter (0 - 50). Larger value for smoother result but more latency
152+
153+
UIFLOW2:
154+
155+
|setAverageFilterLevel.svg|
156+
157+
.. method:: MiniScaleUnit.getAverageFilterLevel
158+
159+
Returns the level of the average filter.
160+
161+
UIFLOW2:
162+
163+
|getAverageFilterLevel.svg|
164+
165+
.. method:: MiniScaleUnit.setEMAFilterAlpha(alpha)
166+
167+
Sets the alpha value for the EMA filter.
168+
169+
The EMA (Exponential Moving Average) filter is more sensitive to changes in data compared to the average filter.
170+
171+
- ``alpha``: Alpha value for the EMA filter (0 - 99). Smaller value for smoother result but more latency
172+
173+
UIFLOW2:
174+
175+
|setEMAFilterAlpha.svg|
176+
177+
.. method:: MiniScaleUnit.getEMAFilterAlpha
178+
179+
Returns the alpha value for the EMA filter.
180+
181+
UIFLOW2:
182+
183+
|getEMAFilterAlpha.svg|
184+

0 commit comments

Comments
 (0)