Skip to content

Commit

Permalink
bme280、灯带
Browse files Browse the repository at this point in the history
  • Loading branch information
LahmYing committed Jan 9, 2019
1 parent faec1a8 commit f1caabb
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 0 deletions.
93 changes: 93 additions & 0 deletions examples/NeoPixel/NeoPixel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="mpython_neopixel_init" id="MnLJd/Qo^x)0fw.[g+,4" x="-291" y="72">
<field name="neopixel_name">my_rgb</field>
<field name="analogP_IO">33</field>
<value name="n">
<shadow type="math_number" id="Y2Uk9MtW9++2Z@:kD#mV">
<field name="NUM">3</field>
</shadow>
</value>
<next>
<block type="controls_repeat_forever" id="gi~c12vNi3lOy-v(_MM=">
<statement name="DO">
<block type="mpython_neopixel_single_gui" id="t;/V23`K62{.VMu+{S*r">
<field name="neopixel_name">my_rgb</field>
<field name="COLOUR">#ff0000</field>
<value name="order">
<shadow type="math_number" id="L*UN.=F_9$WRDvkOE2}o">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="mpython_neopixel_show" id="x!b7CJ^i97)#q*B-rg|%">
<field name="neopixel_name">my_rgb</field>
<next>
<block type="mpython_sleep_ms" id="%46|4fESBj~iYRb`BG3t">
<value name="duration">
<shadow type="math_number" id="o;k+rRK%F|FjIE0_h:k4">
<field name="NUM">1000</field>
</shadow>
</value>
<next>
<block type="mpython_neopixel_all" id="2aah=C^^iq0Gl)x:AE:L">
<field name="neopixel_name">my_rgb</field>
<value name="r">
<shadow type="math_number" id="M=g)kR4A5#(PG-w.=0KG">
<field name="NUM">0</field>
</shadow>
</value>
<value name="g">
<shadow type="math_number" id="wR2*Reqp8blu0Miy::IZ">
<field name="NUM">50</field>
</shadow>
</value>
<value name="b">
<shadow type="math_number" id="Rc#[rcORkl8s@TBRByO6">
<field name="NUM">100</field>
</shadow>
</value>
<next>
<block type="mpython_neopixel_show" id="cR4eu#O(8,U@-?mqpl@H">
<field name="neopixel_name">my_rgb</field>
<next>
<block type="mpython_sleep_ms" id="U76ZFOof2!,][6/kiq$z">
<value name="duration">
<shadow type="math_number" id="5qg8.m+NerY-d1-TxcGI">
<field name="NUM">1000</field>
</shadow>
</value>
<next>
<block type="mpython_neopixel_off" id="olfT~3aw3.t#y,6W3eYF">
<field name="neopixel_name">my_rgb</field>
<next>
<block type="mpython_neopixel_show" id="N`}JE0m;7[d)s.K%^l|7">
<field name="neopixel_name">my_rgb</field>
<next>
<block type="mpython_sleep_ms" id="!SwpaoiAmY;[^ooEehC;">
<value name="duration">
<shadow type="math_number" id="9,G^yq-RLUOhJ-JN2X[%">
<field name="NUM">3000</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</xml>
95 changes: 95 additions & 0 deletions examples/bme280/bme280.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="controls_repeat_forever" id="wu[i7$#thRLZ{*kidgyM" x="-458" y="54">
<statement name="DO">
<block type="mpython_display_fill" id="@KOj@.uBW=N^`X*T-/H]">
<field name="display_fill">fill(0)</field>
<next>
<block type="mpython_display_DispChar" id="TZQb,DsD{MgP?^C8-thZ">
<value name="x">
<shadow type="math_number" id="=OlQPP?j4a*L)|{YPV~0">
<field name="NUM">0</field>
</shadow>
</value>
<value name="y">
<shadow type="math_number" id="BSc]@iZg]tUhAEDe/~#D">
<field name="NUM">0</field>
</shadow>
</value>
<value name="message">
<shadow type="text" id="}*WsII+Z42.VDZo=fMm~">
<field name="TEXT">气压:</field>
</shadow>
</value>
<next>
<block type="mpython_display_DispChar" id="osBKaLASJ(EMz]`Hin`[">
<value name="x">
<shadow type="math_number" id="lU5CpH;n~dlWxL|T]ABj">
<field name="NUM">40</field>
</shadow>
</value>
<value name="y">
<shadow type="math_number" id="N6*3ZZ,4#fc)DoxZ]l1*">
<field name="NUM">0</field>
</shadow>
</value>
<value name="message">
<shadow type="text" id="3LcS,JnIlyrL_4$FaYDV">
<field name="TEXT">Hello, World!</field>
</shadow>
<block type="text_join" id="ejKWCWHm6-Lwi-_8J@oB">
<mutation items="1"></mutation>
<value name="ADD0">
<block type="math_round" id="l`Q1.W;{bX?Y2ZJf1y8|">
<field name="OP">ROUND</field>
<value name="NUM">
<shadow type="math_number" id="dr4UT6m1$=[RUz%bZmdJ">
<field name="NUM">3.1</field>
</shadow>
<block type="mpython_bme280_hum_tem_pre" id="{wrr?u[r.l3tQ}pUcSIz">
<field name="hum_tem_pre">pressure</field>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="mpython_display_DispChar" id="%ZPsg$[|d4NZ#w[q_#el">
<value name="x">
<shadow type="math_number" id="@7L@5Z6(os]@~-H_G6xl">
<field name="NUM">80</field>
</shadow>
</value>
<value name="y">
<shadow type="math_number" id=";T3j_*j8+PcVfrAD.AaJ">
<field name="NUM">0</field>
</shadow>
</value>
<value name="message">
<shadow type="text" id="3LcS,JnIlyrL_4$FaYDV">
<field name="TEXT">Pa</field>
</shadow>
</value>
<next>
<block type="mpython_display_Show" id="NVn_=w{3_}G]f.O9hhix">
<next>
<block type="mpython_sleep_ms" id="]J0eryhM%+?oN?vutKdW">
<value name="duration">
<shadow type="math_number" id="}d0^;T^h/CJQ|U4YHfl?">
<field name="NUM">2000</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</xml>
40 changes: 40 additions & 0 deletions source/blocks/NeoPixel.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
NeoPixel
======

外部RGB灯带控制类指令

class NeoPixel(pin, n, bpp=3, timing=0)
-------------

**描述:** 构建对象

.. image:: /images/blocks/NeoPixel/class.png
:scale: 80 %

参数:

- ``pin`` - 输出引脚
- ``n`` - LED灯的个数
- ``bpp`` - bpp=3,默认为3元组RGB;bpp=4,对于具有3种以上颜色的LED,例如RGBW像素或RGBY像素,采用4元组RGBY或RGBY像素
- ``timing`` - 默认等于0,为400KHz速率;等于1,为800KHz速率


NeoPixel.write()
-------------

**描述:** 把数据写入RGB灯珠中


NeoPixel.fill( (r, g, b) )
-------------

**描述:** 填充所有灯珠颜色及亮度, r、g、b 为颜色亮度值,范围值为0~255


示例
^^^^^

.. image:: /images/blocks/NeoPixel/example/NeoPixel.png
:scale: 80 %

:download:`点击下载图形化示例</../examples/NeoPixel/NeoPixel.xml>`
47 changes: 47 additions & 0 deletions source/blocks/bme280.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
bme280
======

bme280环境传感器指令。

bme280是一款集成温度、湿度、气压,三位一体的环境传感器。具有高精度,多功能,小尺寸等特点。

* 温度检测范围:-40℃~+85℃,分辨率0.1℃,误差±0.5℃
* 湿度检测范围:0~100%RH,分辨率0.1%RH,误差±2%RH
* 压力检测范围:300~1100hPa
* 湿度测量响应时间:1s

.. Attention::

掌控板预留bme280芯片位置未贴片,默认配置的掌控板是不带bme280环境传感器,需留意!


bme280.temperature()
-------------

**描述:** 返回温度值,单位摄氏度

.. image:: /images/blocks/bme280/bme280.png
:scale: 80 %


bme280.pressure()
-------------

**描述:** 返回大气压值,单位Pa


bme280.humidity()
-------------

**描述:** 返回环境湿度,单位%


示例
^^^^^

预置bme280环境传感器的掌控板获取气压值

.. image:: /images/blocks/bme280/example/bme280.png
:scale: 80 %

:download:`点击下载图形化示例</../examples/bme280/bme280.xml>`
2 changes: 2 additions & 0 deletions source/blocks/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
light.rst
accelerometer.rst
rgb.rst
NeoPixel.rst
bme280.rst
wifi.rst
pin.rst
music.rst
Expand Down
Binary file added source/images/blocks/NeoPixel/class.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/images/blocks/bme280/bme280.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/images/blocks/bme280/example/bme280.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f1caabb

Please sign in to comment.