Skip to content

Commit

Permalink
update v1.90 docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tangliufeng committed Jul 22, 2019
1 parent 65d9dc3 commit 007b8fc
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 6 deletions.
8 changes: 8 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.

sys.path.append(os.path.abspath('../ports/esp32/modules'))

autodoc_mock_imports = ["time", "micropython", "machine",
"framebuf", "ubinascii", "neopixel", "mpython", "random",
"_thread","ustruct"
]

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
Expand Down
5 changes: 2 additions & 3 deletions docs/extboard/parrot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
Python库
+++++++++

- 掌控拓展板 ``parrot`` 模块: https://github.com/labplus-cn/mPython-lib
- :ref:`auido<audio>` 模块 : 用于音频播放功能

- :mod:`parrot` 模块 : 用于电机驱动功能
- :mod:`audio` 模块 : 用于音频播放功能

5 changes: 2 additions & 3 deletions docs/extboard/tutorials/parrot_kit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ RGB光环板
blue:bit模块
+++++++++++

有关blue:bit模块的基本的使用方法,可查阅wiki了解。掌控板使用blue:bit模块,首先要将 ``bluebit.py`` 驱动库上传至文件系统。bluebit for mPython library可在下文地址获取
有关blue:bit模块的基本的使用方法,可查阅wiki了解。有关 blue:bit 模块说明,请查阅 :mod:`bluebit` 模块 API说明

| *bluebit套装Wiki*:http://wiki.labplus.cn/index.php?title=Bluebit
| *bluebit for mPython library*: https://github.com/labplus-cn/mPython_bluebit
- *bluebit套装Wiki*:http://wiki.labplus.cn/index.php?title=Bluebit

按键模块
~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ mPython类库
- :mod:`audio` --------- 音频播放录音
- :mod:`radio` --------- 无线广播
- :mod:`sdcard` --------- 挂载SD卡
- :mod:`bluebit` --------- blue:bit驱动
- :mod:`parrot` --------- 掌控拓展板驱动



Expand Down
231 changes: 231 additions & 0 deletions docs/library/mPython/bluebit.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@

.. module:: bluebit
:synopsis: blue:bit驱动

:mod:`bluebit` --- blue:bit驱动
==================================================


`blue:bit` 模块提供bluebit套件的掌控板库。


.. contents::

.. image:: http://wiki.labplus.cn/images/0/07/Bluebit套件1.png


NTC模块
-------------

.. autoclass:: bluebit.NTC
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


LM35模块
-------------

.. autoclass:: bluebit.LM35
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


四按键模块
-------------

.. autoclass:: bluebit.joyButton
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource

温湿度模块
-------------

.. autoclass:: bluebit.SHT20
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


颜色模块
-------------

.. autoclass:: bluebit.Color
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource

数字光线模块
-------------

.. autoclass:: bluebit.AmbientLight
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


超声波模块
-------------

.. autoclass:: bluebit.Ultrasonic
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource

4段数码管模块
-------------

.. autoclass:: bluebit.SEGdisplay
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource

8x8点阵模块
-------------

.. py:class:: Matrix(i2c=i2c)
8x8点阵模块控制类

- ``i2c`` : I2C实例对象,默认i2c=i2c.

.. py:method:: Matrix.blink_rate(rate=None)
设置像素点闪烁率

- ``rate`` : 闪烁间隔时间,单位秒.默认None,常亮.


.. py:method:: Matrix.brightness(brightness)
设置像素点亮度

- ``brightness`` : 亮度级别,范围0~15.


.. py:method:: Matrix.fill(color)
填充所有

- ``color`` : 1亮;0灭

.. py:method:: Matrix.bitmap(bitmap)
显示位图

- ``bitmap`` : 8x8点阵数据


.. py:method:: Matrix.show()
显示生效


除上述函数方法外,还继承 ``FrameBuffer`` 类 ,有关其他方法,如显示字符,绘制函数。详情可查阅 micropython framebuf模块 `FrameBuffer <https://mpython.readthedocs.io/zh/master/library/micropython/framebuf.html>`_ 类.

LCD1602模块
-------------

.. autoclass:: bluebit.LCD1602
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource

MIDI模块
-------------

.. autoclass:: bluebit.MIDI
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource



MP3模块
-------------

.. autoclass:: bluebit.MP3
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


OLED模块
-------------

.. autoclass:: bluebit.OLEDBit
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


红外接收模块
-------------

.. autoclass:: bluebit.IRRecv
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource

红外发射模块
-------------

.. autoclass:: bluebit.IRTrans
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


实验探究类
-------------

适用的模块有电压、电流、磁场、电导率、PH、光电门、气压、力传感器。

.. autoclass:: bluebit.DelveBit
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource


编码电机模块
-------------

.. autoclass:: bluebit.EncoderMotor
:members:
:undoc-members: True
:exclude-members:
:special-members: '__init__'
:member-order: bysource

1 change: 1 addition & 0 deletions docs/library/mPython/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ mPython类库
radio.rst
sdcard.rst
bluebit.rst
parrot.rst


29 changes: 29 additions & 0 deletions docs/library/mPython/parrot.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

.. module:: parrot
:synopsis: 掌控拓展板驱动

:mod:`parrot` --- 掌控拓展板驱动
==================================================

掌控拓展板parrot是mPython掌控板衍生的一款体积小巧、易于携带。支持电机驱动、语音播放、语音合成等功能的IO引脚扩展板,可扩展12路IO接口和2路I2C接口。
该库为掌控拓展板提供电机驱动,LED驱动等功能。

电机控制I2C通讯协议数据格式:

======== ======== =========== ===========
Type Command motor_no speed(int)
控制电机 0x01 0x01/0x02 -100~100
======== ======== =========== ===========

*当 'speed' 为负值,反转;当为正值,正转。*

--------------------------------------------------

.. automodule:: parrot
:members:
:member-order: bysource


.. literalinclude:: /../examples/motor_simple.py
:caption: 电机驱动示例
:linenos:
24 changes: 24 additions & 0 deletions examples/motor_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import parrot
from mpython import sleep_ms,sleep

# 可设置速度范围为-100到100。
# 当值为正值时,电机正转;为负值时,电机反转;


while True:

# 设置正转速度100
parrot.set_speed(parrot.MOTOR_1,100)
parrot.set_speed(parrot.MOTOR_2,100)
print("current motor speend: %d,%d" %(parrot.get_speed(parrot.MOTOR_1),parrot.get_speed(parrot.MOTOR_2))) #获取电机速度
sleep(5)
# 设置反转速度100
parrot.set_speed(parrot.MOTOR_1,-100)
parrot.set_speed(parrot.MOTOR_2,-100)
print("current motor speend: %d,%d" %(parrot.get_speed(parrot.MOTOR_1),parrot.get_speed(parrot.MOTOR_2))) #获取电机速度
sleep(5)
# 停止
parrot.set_speed(parrot.MOTOR_1,0)
parrot.set_speed(parrot.MOTOR_2,0)
print("current motor speend: %d,%d" %(parrot.get_speed(parrot.MOTOR_1),parrot.get_speed(parrot.MOTOR_2))) #获取电机速度
sleep(2)
Binary file not shown.
Binary file not shown.

0 comments on commit 007b8fc

Please sign in to comment.