Skip to content

Commit a077ff9

Browse files
committed
update
1 parent f91148c commit a077ff9

170 files changed

Lines changed: 4458 additions & 240 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode/*

DESCRIPTION.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PiSloth
2+
=======================
3+
Library for PiSloth

MANIFEST.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include DESCRIPTION.rst
2+
3+
# Include the test suite (FIXME: does not work yet)
4+
# recursive-include tests *
5+
6+
# If using Python 3.5 or less, then have to include package data, even though
7+
# it's already declared in setup.py

docs/source/dance.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Dance
22
=========
33

4-
在这个项目中,我们会播放一段音乐,并让Pisloth跟着音乐的节奏来跳一段舞。
4+
In this project, we will play a piece of music and let Pisloth dance to the rhythm of the music.
55

6-
You can open ``dancing.py`` in the folder of the ``example`` or directly copy the following code to the Python IDE to run.
6+
You can open ``dancing.py`` in the folder of the ``example`` with command ``sudo pyrhon3 dancing.py`` or directly copy the following code to the Python IDE to run.
77

88
**Code**
99

@@ -69,23 +69,22 @@ You can open ``dancing.py`` in the folder of the ``example`` or directly copy th
6969
7070
**How it works?**
7171

72-
你可以通过导入下面的这个库来让pisloth播放音乐。
72+
You can make Pisloth play music by importing the following library.
7373

7474
.. code:: python
7575
7676
from robot_hat import TTS, Music
7777
78-
播放musics目录下的背景音乐并设置音量为20。
78+
Play the background music in the music directory and set the volume to 20.
7979

8080
.. code:: python
8181
8282
music.background_music('./musics/india-Arulo.mp3')
8383
music.music_set_volume(20)
8484
85-
执行函数 ``sloth.do_action(motion_name,step=1,speed=None,bpm=None)`` 让pisloth执行设定好的动作。
86-
这里的bpm参数会影响pisloth做动作的间隔时间,数值越大,间隔时间越短。
87-
当我们通过一些方法了解到一首音乐的bpm后,你可以根据这首音乐的bpm自由搭配pisloth的动作,来让它伴随不同风格的音乐跳
88-
不同风格的舞蹈。
85+
Execute the function ``sloth.do_action(motion_name,step=1,speed=None,bpm=None)`` to let Pisloth perform the actions we set.
86+
The bpm parameter here will affect the interval time between Pisloth's actions, the larger the value, the shorter the interval time.
87+
When we learn about the bpm of a piece of music through some methods, you can freely match the movement of the Pisloth according to the bpm of this music to make it dance with different styles of music.
8988

90-
对于音乐的bmp,如果你想了解更多,可以参考:
89+
For music bmp, if you want to know more, you can refer to:
9190
https://en.wikipedia.org/wiki/Tempo

docs/source/diy_action.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
DIY Action
22
===============
33

4-
通过之前课程的学习,你是不是对pisloth有了更深的了解呢?那么接下来让我们尝试自己设计pisloth的动作吧。
4+
Through the previous courses, do you have a deeper understanding of Pisloth? And next let’s try to design the movement of Pisloth by ourselves.
55

66
**Code**
77

@@ -26,9 +26,9 @@ DIY Action
2626
2727
**How it works?**
2828

29-
你可以通过 ``add_action`` 函数来自定义pisloth的动作,第一个参数是动作的名称,
30-
第二个参数是个二维数组,数组里的四个参数用于控制pisloth腿部的四个舵机。我们会在
31-
下一课进行详细介绍。
29+
You can customize the action of Pisloth through the ``add_action`` function, the first parameter is the name of the action,
30+
The second parameter is a two-dimensional array. The four parameters in the array are used to control the four servos of the Pisloth leg.
31+
For how to choose the value we will introduce it in detail in the next lesson.
3232

3333
.. code:: python
3434
@@ -38,4 +38,4 @@ DIY Action
3838
[0, 0, 0, 0]
3939
])
4040
41-
然后用 ``do_action`` 函数让pisloth做动作查看实际效果。
41+
Then use the ``do_action'' function to make pisloth do the action to see the actual effect.

docs/source/diy_action2.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
DIY Action2
22
===============
33

4-
通过上一课,我们了解了如何用 ``add_action`` 函数自定义pisloth的动作。这节课我们会通过键盘直接控制pisloth腿部的四个舵机,可以让你
5-
对pisloth的腿部舵机有更直观的理解从而帮助你自定义一些更有趣的动作。
4+
Through the last lesson, we learned how to customize the action of Pisloth with the ``add_action`` function. In this lesson, we will directly control the four servos of the Pisloth leg through the keyboard, which allows you to
5+
have a more intuitive understanding of Pisloth's leg servos to help you customize some more interesting actions.
66

77
**Code**
88

@@ -100,12 +100,9 @@ DIY Action2
100100
101101
**How it works?**
102102

103-
本程序分为两个部分,第一个部分读取按下的键盘的字符,第二部分是通过按下的键盘字符来控制四个舵机。
103+
This program is divided into two parts. The first part reads the characters of the pressed keyboard, and the second part controls the four servos by pressing the characters of the keyboard.
104104

105-
``left_up_angle`` , ``left_down_angle`` , ``right_up_angle`` ,
106-
``right_down_angle`` 分别对应着函数 ``add_action`` 二维数组参数
107-
里面的四个值。我们通过按下预先设定好的键盘字符,来增加或减少这四个值从而控制
108-
pisloth腿部四个舵机的转动方向和幅度。
105+
``left_up_angle``, ``left_down_angle``, ``right_up_angle``, ``right_down_angle`` corresponds to the four values ​​in the parameters of the function ``add_action``. We increase or decrease these four values ​​by pressing the preset keyboard characters to control the rotation direction and amplitude of the four servos on the pisloth leg.
109106

110107
.. code:: python
111108

docs/source/dont_touch_me.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Don\'t Touch Me
22
==================
33

4-
在这个项目中,我们会让Pisloth表达自己的小情绪,当你试着触摸Pisloth时,它会生气的说不要碰我,然后退后离开你。
4+
In this project, we will let Pisloth express his little emotions. When you try to touch Pisloth, He will be on his guard and get back from you.
55

66
**Code**
77

@@ -43,7 +43,7 @@ Don\'t Touch Me
4343
4444
**How it works?**
4545

46-
实例化各种要用到的音乐类、pisloth以及红外感应模块的类
46+
Instantiate various classes of music, pislot and infrared sensor modules to be used.
4747

4848
.. code:: python
4949
@@ -53,7 +53,7 @@ Don\'t Touch Me
5353
sloth.set_offset([0,0,0,0])
5454
sonar = Ultrasonic(Pin("D0") ,Pin("D1"))
5555
56-
红外感应模块读取你的手与pisloth的距离,设置判断条件,当这个距离小于或等于alert_distance时,pisloth会播放音频文件并做出backward和stand动作。
56+
The ultrasonic module reads the distance between your hand and the Pisloth and sets the judgment condition. When the distance is less than or equal to alert_distance, Pisloth will play the audio file and do ``backward`` and ``stand`` actions.
5757

5858
.. code:: python
5959

docs/source/emotional_pisloth.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Emotional PiSloth
22
=======================
33

4-
在这个项目,我们会让pisloth变得更加生动,我们会让它表现出更多人类的感情动作,
5-
当然学完这课后,你也可以自己设计更多的感情动作出来。
4+
In this project, we will make the Pisloth more vivid, and we will make it show more human emotions,
5+
of course, after learning this lesson, you can also design more emotional actions yourself.
66

77
**Code**
88

@@ -133,7 +133,7 @@ Emotional PiSloth
133133
134134
**How it works?**
135135

136-
Pisloth播放sign.wav并执行 ``hook`` 动作表示confuse.
136+
Pisloth plays ``sign.wav`` and executes the ``hook'' action to indicate confuse.
137137
138138
.. code:: python
139139
@@ -144,7 +144,7 @@ Pisloth播放sign.wav并执行 ``hook`` 动作表示confuse.
144144
print(e)
145145
sloth.do_action('hook', 1, 100)
146146
147-
Pisloth播放happy2.wav并循环3次执行 ``hook`` ``stand`` 动作表示happy.
147+
Pisloth plays ``happy2.wav`` and executes the ``hook`` and ``stand'' actions 3 times to indicate happy.
148148
149149
.. code:: python
150150
@@ -157,7 +157,7 @@ Pisloth播放happy2.wav并循环3次执行 ``hook`` 和 ``stand`` 动作表示h
157157
sloth.do_action('hook', 1, 100)
158158
sloth.do_action('stand', 1, 100)
159159
160-
Pisloth播放warning.wav并执行 ``hook`` , ``stand`` , ``walk backward boldly`` 动作表示fear.
160+
Pisloth plays warning.wav and executes ``hook``, ``stand``, ``walk backward boldly`` actions to indicate fear.
161161

162162
.. code:: python
163163
@@ -175,7 +175,7 @@ Pisloth播放warning.wav并执行 ``hook`` , ``stand`` , ``walk backward boldly`
175175
sloth.do_action('walk backward boldly', 1, 100)
176176
sloth.do_action('stand', 1, 100)
177177
178-
Pisloth播放depress.wav并执行 ``big swing`` 动作表示sad.
178+
Pisloth plays ``depress.wav`` and performs the ``big swing'' action to indicate sad.
179179
180180
.. code:: python
181181
@@ -186,7 +186,7 @@ Pisloth播放depress.wav并执行 ``big swing`` 动作表示sad.
186186
print(e)
187187
sloth.do_action('big swing', 1, 100)
188188
189-
Pisloth播放error.wav并执行 ``walk backward boldly`` ``stand`` 动作表示angry.
189+
Pisloth plays ``error.wav`` and performs the ``walk backward boldly`` and ``stand`` actions to indicate angry.
190190

191191
.. code:: python
192192
@@ -198,7 +198,7 @@ Pisloth播放error.wav并执行 ``walk backward boldly`` 和 ``stand`` 动作表
198198
sloth.do_action('walk backward boldly', 1, 100)
199199
sloth.do_action('stand', 1, 100)
200200
201-
Pisloth播放depress2.wav并执行 ``fall left`` 动作表示fail.
201+
Pisloth plays ``depress2.wav`` and executes the ``fall left`` action to indicate a fall.
202202

203203
.. code:: python
204204
@@ -210,9 +210,10 @@ Pisloth播放depress2.wav并执行 ``fall left`` 动作表示fail.
210210
sloth.do_action('fall left', 1, 100)
211211
212212
.. note::
213-
这个动作会让pisloth摔倒,注意别让它从桌子上落下摔坏。
213+
This action will make the Pisloth fall, be careful not to let it fall off the table and break it.
214214

215-
Pisloth播放talk3.wav,talk2.wav并执行 ``close`` , ``stand`` 动作表示shy.
215+
216+
Pisloth plays ``talk3.wav``, ``talk2.wav`` and executes ``close``, ``stand'' action means shy.
216217
217218
.. code:: python
218219

docs/source/ezblock/conf.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
import sphinx_rtd_theme
17+
18+
html_theme = 'sphinx_rtd_theme'
19+
# -- Project information -----------------------------------------------------
20+
21+
project = 'pisloth'
22+
copyright = '2021, sunfounder'
23+
author = 'sunfounder'
24+
25+
26+
# -- General configuration ---------------------------------------------------
27+
28+
# Add any Sphinx extension module names here, as strings. They can be
29+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30+
# ones.
31+
extensions = [
32+
]
33+
34+
# Add any paths that contain templates here, relative to this directory.
35+
templates_path = ['_templates']
36+
37+
# List of patterns, relative to source directory, that match files and
38+
# directories to ignore when looking for source files.
39+
# This pattern also affects html_static_path and html_extra_path.
40+
exclude_patterns = []
41+
42+
43+
# -- Options for HTML output -------------------------------------------------
44+
45+
# The theme to use for HTML and HTML Help pages. See the documentation for
46+
# a list of builtin themes.
47+
#
48+
html_theme = 'sphinx_rtd_theme'
49+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
50+
51+
52+
# Add any paths that contain custom static files (such as style sheets) here,
53+
# relative to this directory. They are copied after the builtin static files,
54+
# so a file named "default.css" will overwrite the builtin "default.css".
55+
html_static_path = ['_static']
56+
57+
html_js_files = [
58+
'https://ezblock.cc/readDocFile/topHead.js',
59+
]
60+
html_css_files = [
61+
'https://ezblock.cc/readDocFile/topHead.css',
62+
]

docs/source/ezblock/dance_ez.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Dance
2+
=========
3+
4+
In this project, we would play a piece of music and make Pisloth dance to the rhythm of the music.
5+
6+
Cute Pisloth and good music can put you in a good mood.
7+
8+
**TIPS**
9+
10+
.. image:: img/dance.png
11+
:width: 400
12+
13+
This block can play some music that we have preset.
14+
15+
.. image:: img/dance2.png
16+
:width: 400
17+
18+
And then you can adjust the volume with this block.
19+
20+
.. image:: img/dance4.png
21+
:width: 250
22+
23+
You may want to use repeat which can help you repeatedly execute the same statement and reduce code size.
24+
25+
26+
**EXAMPLE**
27+
28+
.. image:: img/dance6.png
29+
30+
.. image:: img/dance7.png
31+
32+
.. image:: img/dance8.png

0 commit comments

Comments
 (0)