Skip to content

Commit

Permalink
再来修复一次
Browse files Browse the repository at this point in the history
  • Loading branch information
junhuanchen committed Jul 2, 2019
1 parent 5d46af0 commit 5ecf4bc
Show file tree
Hide file tree
Showing 207 changed files with 4,053 additions and 4,053 deletions.
4 changes: 2 additions & 2 deletions source/bpi-adu/tutorials/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
这里你将会体验和了解什么是 Arduino 编程,开始你的 C/C++ 嵌入式开发之旅吧。

.. toctree::
:maxdepth: 2
:maxdepth: 2

install
install
58 changes: 29 additions & 29 deletions source/bpi-mpy/advanced/leds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

.. code:: python
from machine import Pin
from machine import Pin
再次输入

.. code:: python
Pin(18, Pin.OUT).value(1)
Pin(18, Pin.OUT).value(1)
.. figure:: leds/light_up.png

Expand All @@ -35,7 +35,7 @@

.. code:: python
Pin(18, Pin.OUT).value(0)
Pin(18, Pin.OUT).value(0)
.. figure:: leds/light_down.png

Expand All @@ -50,34 +50,34 @@

.. code:: python
from machine import Pin
import time
led = Pin(18, Pin.OUT) # get a led on gpio 18.
print('turn on')
led.value(1) # turn on
print('sleep 1s')
time.sleep(1) # sleep 1s
print('turn off')
led.value(0) # turn off
from machine import Pin
import time
led = Pin(18, Pin.OUT) # get a led on gpio 18.
print('turn on')
led.value(1) # turn on
print('sleep 1s')
time.sleep(1) # sleep 1s
print('turn off')
led.value(0) # turn off
.. figure:: leds/mian_light.png

若是效果不明显,可以写成死循环来查看效果,注意使用\ ``Ctrl + C``\ 停下来,否则无法继续操作。

.. code:: python
from machine import Pin
import time
led = Pin(18, Pin.OUT) # get a led on gpio 18.
while True:
print('turn on')
led.value(1) # turn on
print('sleep 1s')
time.sleep(1) # sleep 1s
print('turn off')
led.value(0) # turn off
print('sleep 1s')
time.sleep(1) # sleep 1s
from machine import Pin
import time
led = Pin(18, Pin.OUT) # get a led on gpio 18.
while True:
print('turn on')
led.value(1) # turn on
print('sleep 1s')
time.sleep(1) # sleep 1s
print('turn off')
led.value(0) # turn off
print('sleep 1s')
time.sleep(1) # sleep 1s
.. figure:: leds/blink_led.png

Expand All @@ -88,10 +88,10 @@

.. code:: python
from pixel import Pixel
View = Pixel()
RGB = (10, 10, 10)
View.LoadXY(2, 2, RGB)
View.Show()
from pixel import Pixel
View = Pixel()
RGB = (10, 10, 10)
View.LoadXY(2, 2, RGB)
View.Show()
使用 ``runfile main.py`` 执行即可。
22 changes: 11 additions & 11 deletions source/bpi-mpy/advanced/mpfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ Tab 键可以查看模块中所有成员列表。这对于找出模块或对象

>>> import machine
>>> machine.
__class__ __name__ ADC DAC
DEEPSLEEP DEEPSLEEP_RESET EXT0_WAKE
EXT1_WAKE HARD_RESET I2C PIN_WAKE
PWM PWRON_RESET Pin RTC
SLEEP SOFT_RESET SPI Signal
TIMER_WAKE TOUCHPAD_WAKE Timer TouchPad
UART ULP_WAKE WDT WDT_RESET
deepsleep disable_irq enable_irq freq
idle mem16 mem32 mem8
reset reset_cause sleep time_pulse_us
unique_id wake_reason
__class__ __name__ ADC DAC
DEEPSLEEP DEEPSLEEP_RESET EXT0_WAKE
EXT1_WAKE HARD_RESET I2C PIN_WAKE
PWM PWRON_RESET Pin RTC
SLEEP SOFT_RESET SPI Signal
TIMER_WAKE TOUCHPAD_WAKE Timer TouchPad
UART ULP_WAKE WDT WDT_RESET
deepsleep disable_irq enable_irq freq
idle mem16 mem32 mem8
reset reset_cause sleep time_pulse_us
unique_id wake_reason
>>> machine.


Expand Down
68 changes: 34 additions & 34 deletions source/bpi-mpy/advanced/mqtt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,47 +48,47 @@ MQTT 服务器的传输模式可以认为是大家通过各自的内部约定后

.. code:: python
import wifi
wifi.start()
import wifi
wifi.start()
server_ip = "mq.tongxinmao.com" # 在线公共的 MQTT 服务器
client_id = "umqtt_client" # 客户端 ID ,随意定义,用来标识自己发出的数据。
server_ip = "mq.tongxinmao.com" # 在线公共的 MQTT 服务器
client_id = "umqtt_client" # 客户端 ID ,随意定义,用来标识自己发出的数据。
import time
import time
from umqtt.robust import MQTTClient
from umqtt.robust import MQTTClient
try:
# see https://github.com/micropython/micropython-lib/blob/master/umqtt.simple/umqtt/simple.py
c = MQTTClient(client_id, server_ip, 18830) # 配置连接,这个是连通信猫的服务器配置,端口是 18830,一般默认的是 1883
try:
# see https://github.com/micropython/micropython-lib/blob/master/umqtt.simple/umqtt/simple.py
c = MQTTClient(client_id, server_ip, 18830) # 配置连接,这个是连通信猫的服务器配置,端口是 18830,一般默认的是 1883
c.DEBUG = True # 输出 Debug 信息
c.DEBUG = True # 输出 Debug 信息
def sub_cb(topic, msg):
print((topic, msg))
c.publish(topic, msg) # 无论收到什么订阅的信息都以同样的主题和数据传回。
def sub_cb(topic, msg):
print((topic, msg))
c.publish(topic, msg) # 无论收到什么订阅的信息都以同样的主题和数据传回。
c.set_callback(sub_cb) # 把向远端订阅(subscribe)的数据接收回调处理。
c.set_callback(sub_cb) # 把向远端订阅(subscribe)的数据接收回调处理。
if not c.connect(clean_session=False):
c.subscribe(b"foo_topic") # 订阅一个 foo_topic 的主题(topic)
if not c.connect(clean_session=False):
c.subscribe(b"foo_topic") # 订阅一个 foo_topic 的主题(topic)
c.publish(b"foo_topic", b"hello") # 向 foo_topic 的主题(topic)发送 hello 字符串。
c.publish(b"foo_topic", b"hello") # 向 foo_topic 的主题(topic)发送 hello 字符串。
while 1:
# 让芯片运行慢一点,便于观察现象。
time.sleep(1)
while 1:
# 让芯片运行慢一点,便于观察现象。
time.sleep(1)
# 等待处理 MQTT 的数据
if c.check_msg() is not None:
c.wait_msg()
# 等待处理 MQTT 的数据
if c.check_msg() is not None:
c.wait_msg()
# 没数据可以处理的时候可以做点别的事情
else:
print('other operator')
# 没数据可以处理的时候可以做点别的事情
else:
print('other operator')
finally:
c.disconnect() # 调试程序事重开服务,要记得收尾,否则将重启板子才可以继续。
finally:
c.disconnect() # 调试程序事重开服务,要记得收尾,否则将重启板子才可以继续。
.. _通信猫 MQTT 服务器: http://www.tongxinmao.com/txm/webmqtt.php
.. _mosquitto Windows: https://github.com/BPI-STEAM/BPI-BIT-MicroPython/releases/tag/windows-mosquitto
Expand All @@ -99,16 +99,16 @@ MQTT 服务器的传输模式可以认为是大家通过各自的内部约定后
以上便是 MQTT 的具体实例,运行起来的应该有如下效果。

1. 板子将向订阅了 foo_topic 主题的发送一条 ``hello``
数据,此时在网页上订阅该主题的用户应该会得到该数据,并显示出来。
数据,此时在网页上订阅该主题的用户应该会得到该数据,并显示出来。

2. 板子订阅了 foo_topic 主题,所以会接收到 1 自己先前发送的 ``hello``
数据,然后根据代码可知,它会把这条接收的数据原封不动的发回去,所以这时候板子会在
foo_topic 主题上循环接收和发送数据。
数据,然后根据代码可知,它会把这条接收的数据原封不动的发回去,所以这时候板子会在
foo_topic 主题上循环接收和发送数据。

3. 如果我们在网页端部分向 foo_topic
主题发送了数据,则板子会接收到数据并对应显示数据,例如图中所看到的
``11 22 3311`` 数据,注意这时候,你发的新数据也会参与 2
中所提及的循环输出数据了。
主题发送了数据,则板子会接收到数据并对应显示数据,例如图中所看到的
``11 22 3311`` 数据,注意这时候,你发的新数据也会参与 2
中所提及的循环输出数据了。

.. image:: mqtt/online_test.png

Expand Down
10 changes: 5 additions & 5 deletions source/bpi-mpy/advanced/wifi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

.. code:: python
import wifi # booy.py default enable
wifi.try_connect()
import wifi # booy.py default enable
wifi.try_connect()
效果如下图,默认 boot.py 里会默认调用
``import wifi``\ ,所以你也可以直接在 REPL 中调用
Expand Down Expand Up @@ -104,9 +104,9 @@ SmartConfig 配网

.. code:: python
WIFI_SSID = '你的WIFI热点名称'
WIFI_PSWD = '你的WIFI热点密码'
HOST_NAME = '你板子的网络名称' # 可选
WIFI_SSID = '你的WIFI热点名称'
WIFI_PSWD = '你的WIFI热点密码'
HOST_NAME = '你板子的网络名称' # 可选
(现在已经可以先 ``get wifi_cfg.py`` 取回配置)与 ``mpfshell``
同一个目录中使用 ``put wifi_cfg.py``, 将其替换掉现在的 WIFI 连接配置。
Expand Down
32 changes: 16 additions & 16 deletions source/bpi-mpy/advanced/wireless.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mpfshell 适配了 webrepl 的,也就是说,基于 mpfshell 的 pycharm
1. webrepl 标准路径为 ``ws://192.168.30.116:8266``\

2. mpfshell 的路径则为
``ws:192.168.30.116,1234``\ ,区别在于后者允许顺带密码,从而免去了连接认证。
``ws:192.168.30.116,1234``\ ,区别在于后者允许顺带密码,从而免去了连接认证。

至此,你已经可以像过去有线一样使用它了,如果期间出现任何问题,只需要重启板子即可,它会自动上电连接网络并打开
Webrepl 的支持服务。
Expand All @@ -54,8 +54,8 @@ FTP 标准文件系统操作服务

.. code:: python
import ftptiny
ftptiny.FtpTiny().start()
import ftptiny
ftptiny.FtpTiny().start()
.. figure:: wireless/ftp.png

Expand All @@ -66,8 +66,8 @@ WebDAV HTTP 文件系统服务(在 20190312 后固件暂时移除了)

.. code:: python
import webdav
webdav.start()
import webdav
webdav.start()
.. figure:: wireless/webdav.png

Expand Down Expand Up @@ -117,17 +117,17 @@ MDns 反向域名解析服务

.. code:: python
try:
import network
mdns = network.mDNS()
mdns.start("bpibit", "MicroPython with mDNS")
_ = mdns.addService('_ftp', '_tcp', 21, "MicroPython",
{"board": "ESP32", "service": "bpibit FTP File transfer", "passive": "True"})
_ = mdns.addService('_telnet', '_tcp', 23, "MicroPython", {"board": "ESP32", "service": "bpibit Telnet REPL"})
_ = mdns.addService('_http', '_tcp', 80, "MicroPython", {"board": "ESP32", "service": "bpibit Web server"})
print("mDNS started")
except Exception as e:
print("mDNS not started")
try:
import network
mdns = network.mDNS()
mdns.start("bpibit", "MicroPython with mDNS")
_ = mdns.addService('_ftp', '_tcp', 21, "MicroPython",
{"board": "ESP32", "service": "bpibit FTP File transfer", "passive": "True"})
_ = mdns.addService('_telnet', '_tcp', 23, "MicroPython", {"board": "ESP32", "service": "bpibit Telnet REPL"})
_ = mdns.addService('_http', '_tcp', 80, "MicroPython", {"board": "ESP32", "service": "bpibit Web server"})
print("mDNS started")
except Exception as e:
print("mDNS not started")
在电脑中可以使用 ``bpibit.local`` 替代 IP
地址访问它,如下图,你也可以取自己想要的名字,改掉代码里的
Expand Down
18 changes: 9 additions & 9 deletions source/bpi-mpy/modules/display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ display 模块
- ``val`` 要显示的字符比如'hello world!'或数字如 12345。

- ``color`` 内部预置的颜色有:
* ``black`` - [0, 0, 0]
* ``Red`` - [2, 0, 0]
* ``Orange`` - [2, 1, 0]
* ``Yellow`` - [2, 2, 0]
* ``Green`` - [0, 2, 0]
* ``Blue`` - [0, 0, 2]
* ``Indigo`` - [0, 2, 2]
* ``Purple`` - [2, 0, 2]

* ``black`` - [0, 0, 0]
* ``Red`` - [2, 0, 0]
* ``Orange`` - [2, 1, 0]
* ``Yellow`` - [2, 2, 0]
* ``Green`` - [0, 2, 0]
* ``Blue`` - [0, 0, 2]
* ``Indigo`` - [0, 2, 2]
* ``Purple`` - [2, 0, 2]
用户也可以使用自定义的颜色比如color=[7,8,9],列表中的值分别对应红色,绿色,蓝色的颜色值,取值范围都是0-255。
同时color也可以包含多个颜色比如[[0,1,5],[2,2,8],[3,2,1],[4,5,6]],每个字符的颜色就会按照color的颜色显示。
- ``delay`` 字符滚动的速度。
Expand Down
4 changes: 2 additions & 2 deletions source/bpi-mpy/modules/music.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ page about scientific pitch notation`_. 例如,middle "C"是 ``c4`` 和concer
- ``wait`` 阻塞:如果 ``wait`` 设置为 ``True``, 为阻塞,否则未不。

- ``loop`` :如果 ``loop`` 设置为 ``True`` ,则重复调整直到stop被调用(见下文)或阻塞调用被中断。


.. function:: pitch(frequency, duration=-1, pin=Pin.P6, wait=True)

Expand All @@ -91,7 +91,7 @@ page about scientific pitch notation`_. 例如,middle "C"是 ``c4`` 和concer

.. function:: stop()

停止给定引脚上的所有音乐播放。
停止给定引脚上的所有音乐播放。


.. function:: reset()
Expand Down
2 changes: 1 addition & 1 deletion source/bpi-mpy/samples/weather.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ help(“modules”)
### 二、准备天气api

- 1.这里我用到了国家气象局的API
`http://www.weather.com.cn/data/cityinfo/101200801.html # 101200801为荆州市`
`http://www.weather.com.cn/data/cityinfo/101200801.html # 101200801为荆州市`
各城市ID详见:http://mobile.weather.com.cn/js/citylist.xml
- 2.请求返回Json数据样列
```python
Expand Down

0 comments on commit 5ecf4bc

Please sign in to comment.