This commit is contained in:
Eeason Shen 2025-03-22 17:47:50 +08:00
parent 69546533b1
commit f6c911c02f
20 changed files with 888 additions and 351 deletions

View File

@ -58,3 +58,5 @@ urllib3==1.26.9
# via requests
myst_parser==4.0.0
sphinxcontrib-googleanalytics==0.4

View File

@ -0,0 +1,53 @@
{%- if meta is defined and meta is not none %}
{%- set check_meta = True %}
{%- else %}
{%- set check_meta = False %}
{%- endif %}
{%- if check_meta and 'github_url' in meta %}
{%- set display_github = True %}
{%- endif %}
{%- if check_meta and 'bitbucket_url' in meta %}
{%- set display_bitbucket = True %}
{%- endif %}
{%- if check_meta and 'gitlab_url' in meta %}
{%- set display_gitlab = True %}
{%- endif %}
{%- set display_vcs_links = display_vcs_links if display_vcs_links is defined else True %}
{#- Translators: This is an ARIA section label for page links, including previous/next page link and links to GitHub/GitLab/etc. -#}
<div role="navigation" aria-label="{{ _('Page navigation') }}">
<ul class="wy-breadcrumbs">
{%- block breadcrumbs %}
<li><a href="{{ pathto(master_doc) }}" class="icon icon-home" aria-label="Home"></a></li>
{%- for doc in parents %}
<li class="breadcrumb-item"><a href="{{ doc.link|e }}">{{ doc.title }}</a></li>
{%- endfor %}
<li class="breadcrumb-item active">{{ title }}</li>
{%- endblock %}
{%- block breadcrumbs_aside %}
<li class="wy-breadcrumbs-aside">
<div id="pageHeaderContent">
</div>
</li>
{%- endblock %}
</ul>
{%- if (theme_prev_next_buttons_location == 'top' or theme_prev_next_buttons_location == 'both') and (next or prev) %}
{#- Translators: This is an ARIA section label for sequential page links, such as previous and next page links. -#}
<div class="rst-breadcrumbs-buttons" role="navigation" aria-label="{{ _('Sequential page navigation') }}">
{%- if prev %}
<a href="{{ prev.link|e }}" class="btn btn-neutral float-left" title="{{ prev.title|striptags|e }}" accesskey="p"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> {{ _('Previous') }}</a>
{%- endif %}
{%- if next %}
<a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}" accesskey="n">{{ _('Next') }} <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
{%- endif %}
</div>
{%- endif %}
<hr/>
</div>

View File

@ -1,6 +1,17 @@
{%- extends "!layout.html" %}
{%- block extrabody %}
<script>
// window.onload = function () {
// let contactUsHtml = `
// <div> Need help? Contact <a href="mailto:support@freenove.com">support@freenove.com</a> </div>
// `;
// viewPageSourcesElements = document.getElementsByClassName("wy-breadcrumbs-aside")
// console.log(document.getElementsByClassName("wy-breadcrumbs-aside"))
// viewPageSourcesElements[0].innerHTML = contactUsHtml;
// }
</script>
<div class="extrabody-content">
<div id="navContent">

View File

@ -15,86 +15,65 @@ sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())
os.system("rm -r freenove_Kit")
os.system("git clone --depth 1 https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_ESP32 freenove_Kit")
# # 删除文件夹
# os.system("rm -r _static")
# os.system("rm -r _templates")
# os.system("rm freenove-logo.png")
# # 克隆所需资料到freenove_css文件夹中
# os.system("git clone --branch nav https://github.com/Freenove/freenove-docs freenove_css")
# # 复制网页样式到对应位置
# os.system("cp -r freenove_css/_static .")
# os.system("cp -r freenove_css/_templates .")
# # 复制网页样式到对应位置
# os.system("cp freenove_css/freenove-logo.png .")
# # 删除文件夹
# os.system("rm -r freenove_css")
def prepend_to_file(file_path, content):
with open(file_path, "r+") as file:
original = file.read()
file.seek(0) # 将文件光标移动到开头
file.write(content)
file.write(original)
def apend_to_file(file_path, content):
with open(file_path, "a") as file:
file.write(content)
# extlinks = {
# "fnk0020_github_url": (
# "https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi%s",
# "fnk0020_github_url%s",
# )
# }
print("hello")
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "fnk0047-docs"
copyright = "2016 - " + str(datetime.now().year) + ", support@freenove.com"
author = "freenove"
release = "v1.0"
version = "v1.0"
copyright = '2016-2025, Freenove'
author = 'Freenove'
release = 'v1.0.0'
version = 'v1.0.0'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
# extensions = []
# extensions = ['recommonmark','sphinx_markdown_tables']
extensions = [
"sphinx_rtd_theme",
# "sphinx.ext.extlinks",
# "sphinx.ext.intersphinx",
"sphinx.ext.duration",
"sphinx.ext.doctest",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
"sphinx.ext.autosectionlabel",
"sphinxcontrib.googleanalytics",
# "sphinx_favicon"
]
templates_path = ["_templates"]
autosectionlabel_prefix_document = True
googleanalytics_id="G-THC0SQQTDX"
source_suffix = {
'.rst': 'restructuredtext',
}
templates_path = ['_templates']
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
# html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"
# html_theme = 'pydata_sphinx_theme'
html_static_path = ["_static"]
html_static_path = ['_static']
html_favicon = "_static/images/freenove_logo_tag_icon.png"
html_logo = "_static/images/freenove_logo_home_button.png"
# html_favicon = "https://cdn.jsdelivr.net/gh/Freenove/freenove-docs/docs/source/_static/images/freenove_logo_tag_icon.png"
# html_logo = "https://cdn.jsdelivr.net/gh/Freenove/freenove-docs/docs/source/_static/images/freenove_logo_home_button.png"
html_theme = 'sphinx_rtd_theme'
html_theme_options = {
"collapse_navigation": False,
"logo_only": True,
"navigation_depth": -1,
"version_selector": True,
"includehidden": True,
# "flyout_display": "attached",
# 'style_nav_header_background': '#005500',
'collapse_navigation': False,
'logo_only': True,
'navigation_depth': -1,
'includehidden': True,
'flyout_display': 'hidden',
'version_selector': True,
'prev_next_buttons_location': 'both',
'style_external_links': True,
'language_selector': True,
# 'titles_only': True,
# 'style_nav_header_background': '#E3E3E3',
}
# html_copy_source = False
# html_show_sourcelink = False
# multi-language docs
language = 'en'
@ -105,7 +84,7 @@ gettext_uuid = True # optional.
rst_prolog = """
.. include:: <s5defs.txt>
.. include:: ../../../_static/style/custom-style.txt
"""
"""
variables_to_export = [
"project",
@ -126,19 +105,29 @@ html_css_files = [
'https://cdn.jsdelivr.net/gh/Freenove/freenove-docs/docs/source/_static/css/custom.css',
'https://cdn.jsdelivr.net/gh/Freenove/freenove-docs/docs/source/_static/css/navigationStyle.css',
]
html_js_files = [
'https://cdn.jsdelivr.net/gh/Freenove/freenove-docs/docs/source/_static/js/custom.js',
# 'js/custom.js'
]
extlinks = {
"Freenove": (
"https://docs.freenove.com/projects/%s/en/latest/", None
)
}
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/")
intersphinx_mapping = {
# "rpi-starter-kit": ("https://freenove-docs2.readthedocs.io/projects/fnk0066/en/latest/", None),
# "fnk0017": ("https://docs.freenove.com/projects/fnk0017/en/latest/", None),
}
intersphinx_disabled_reftypes = ["*"]
def setup(app):
pass
# app.add_css_file("css/custom.css")
# app.add_css_file("css/custom.css")
# app.add_css_file('https://cdn.jsdelivr.net/gh/Freenove/freenove-docs/docs/source/_static/css/custom.css')
suppress_warnings = ['autosectionlabel.*']

View File

@ -135,7 +135,7 @@ According to the circuit, when the GPIO2 of ESP32-WROVER output level is high, t
Upload the following Sketch:
**Freenove_Ultimate_Starter_Kit_for_ESP32\Sketches\Sketch_01.1_Blink.**
**Freenove_Ultimate_Starter_Kit_for_ESP32\Sketches\\Sketch_01.1_Blink.**
Before uploading the code, click "**Tools**", "**Board**" and select "**ESP32 Wrover Module**".

View File

@ -313,173 +313,4 @@ The design for creating the BLE server is:
:lines: 44-57
:dedent:
Project Bluetooth Control LED
*********************************************
In this section, we will control the LED with Bluetooth.
Component List
======================================
+------------------------------------+-------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1 |
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+-------------------------+
| Micro USB Wire x1 |
| |
| |Chapter08_00| |
+--------------------------------------------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+-----------------+------------------+-------------------------+
| LED x1 | Resistor 220Ω x1 | Jumper M/M x2 |
| | | |
| |Chapter01_03| | |Chapter01_04| | |Chapter01_05| |
+-----------------+------------------+-------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter01_03| image:: ../_static/imgs/1_LED/Chapter01_03.png
.. |Chapter01_04| image:: ../_static/imgs/1_LED/Chapter01_04.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter08_00| image:: ../_static/imgs/8_Serial_Communication/Chapter08_00.png
Circuit
==========================================
Connect Freenove ESP32 to the computer using a USB cable.
.. list-table::
:width: 80%
:header-rows: 1
:align: center
* - Schematic diagram
* - |Chapter27_27|
* - Hardware connection.
If you need any support, please feel free to contact us via: support@freenove.com
|Chapter27_28|
.. |Chapter27_27| image:: ../_static/imgs/27_Bluetooth/Chapter27_27.png
.. |Chapter27_28| image:: ../_static/imgs/27_Bluetooth/Chapter27_28.png
Sketch
======================================
Sketch_Bluetooth_Control_LED
--------------------------------------------
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_29.png
:align: center
Compile and upload code to ESP32. The operation of the APP is the same as 27.1, you only need to change the sending content to "led_on" and "led_off" to operate LEDs on the ESP32-WROVER.
Data sent from mobile APP:
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_30.png
:align: center
Display on the serial port of the computer:
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_31.png
:align: center
The phenomenon of LED
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_32.png
:align: center
Attention: If the sending content isn't "led-on' or "led-off", then the state of LED will not change. If the LED is on, when receiving irrelevant content, it keeps on; Correspondingly, if the LED is off, when receiving irrelevant content, it keeps off.
The following is the program code:
.. literalinclude:: ../../../freenove_Kit/C/Sketches/Sketch_27.3_BluetoothToLed/Sketch_27.3_BluetoothToLed.ino
:linenos:
:language: c
:dedent:
Use character string to handle function header file.
.. literalinclude:: ../../../freenove_Kit/C/Sketches/Sketch_27.3_BluetoothToLed/Sketch_27.3_BluetoothToLed.ino
:linenos:
:language: c
:lines: 10-10
:dedent:
Define a buffer to receive data from Bluetooth, and use "count" to record the bytes of data received.
.. literalinclude:: ../../../freenove_Kit/C/Sketches/Sketch_27.3_BluetoothToLed/Sketch_27.3_BluetoothToLed.ino
:linenos:
:language: c
:lines: 13-14
:dedent:
Initialize the classic Bluetooth and name it as "ESP32test"
.. literalinclude:: ../../../freenove_Kit/C/Sketches/Sketch_27.3_BluetoothToLed/Sketch_27.3_BluetoothToLed.ino
:linenos:
:language: c
:lines: 17-17
:dedent:
When receive data, read the Bluetooth data and store it into buffer array.
.. literalinclude:: ../../../freenove_Kit/C/Sketches/Sketch_27.3_BluetoothToLed/Sketch_27.3_BluetoothToLed.ino
:linenos:
:language: c
:lines: 23-27
:dedent:
Compare the content in buffer array with "led_on" and "led_off" to see whether they are the same. If yes, execute the corresponding operation.
.. literalinclude:: ../../../freenove_Kit/C/Sketches/Sketch_27.3_BluetoothToLed/Sketch_27.3_BluetoothToLed.ino
:linenos:
:language: c
:lines: 30-35
:dedent:
After comparing the content of array, to ensure successful transmission next time, please empty the array and set the count to zero.
.. literalinclude:: ../../../freenove_Kit/C/Sketches/Sketch_27.3_BluetoothToLed/Sketch_27.3_BluetoothToLed.ino
:linenos:
:language: c
:lines: 36-37
:dedent:
Reference
-------------------------------
strncmp() functions are often used for string comparisons, which are accurate and stable.
.. py:function:: int strncmp(const char *str1, const char *str2, size_t n)
str1: the first string to be compared
str2: the second string to be compared
n: the biggest string to be compared
Return value: if stir1>str2, then return value>0.
If return value is 0, then the contents of str1 and str2 are the same.
If str1< str2, then return value<0.
|
Function memset is mainly used to clean and initialize the memory of array
.. py:function:: void *memset(void *s, int c, unsigned long n)
Function memset() is to set the content of a certain internal storage as specified value.
*s: the initial address of the content to clear out.
c:to be replaced as specified value
n: the number of byte to be replaced
.. include:: 27_2_Bluetooth.rst

View File

@ -0,0 +1,36 @@
######################################################
Processing language
######################################################
.. toctree::
:maxdepth: 1
:caption: Important_Information
:glob:
Processing/Welcome.rst
.. toctree::
:maxdepth: 1
:caption: Prepare
:glob:
Processing/Preface.rst
.. toctree::
:maxdepth: 1
:numbered:
:glob:
Processing/1_Oscilloscope
Processing/2_Control_2D_and_3D_Figures
Processing/3_Snake_Game
Processing/4_Pick_Apples
Processing/5_Pong_Game
Processing/6_Tetris
.. toctree::
:maxdepth: 1
:caption: What's next?
:glob:
Processing/What_s_next

View File

@ -0,0 +1,84 @@
##############################################################################
Chapter Oscilloscope
##############################################################################
In this chapter, we will make a complex virtual instrument, oscilloscope. Oscilloscope is a widely used electronic measuring instrument. It can get the electrical signals not directly observed into visible image to facilitate the analysis and study of various electrical signals change process.
Project 1.1 Oscilloscope
**********************************
Now, let's use Processing and ESP32 board to create an oscilloscope.
Component List
====================================
+------------------------------------+------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1|
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+------------------------------------+------------------------+
| Rotary potentiometer x1 | Jumper M/M x3 |
| | |
| |Chapter09_00| | |Chapter01_05| |
+------------------------------------+------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter13_00| image:: ../_static/imgs/1_LED/Chapter13_00.png
.. |Chapter07_04| image:: ../_static/imgs/7_Buzzer/Chapter07_04.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter09_00| image:: ../_static/imgs/9_AD_DA_Converter/Chapter09_00.png
Circuit
===============================================
Use Pin4 (A10) port to detect the voltage of rotary potentiometer.
.. list-table::
:width: 100%
:align: center
* - Schematic diagram
- Hardware connection
* - |Chapter01_00|
- |Chapter01_01|
.. |Chapter01_00| image:: ../_static/imgs/1_Oscilloscope/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_Oscilloscope/Chapter01_01.png
Sketch
==============================
Sketch Oscilloscope
------------------------------
Use Processing to open **Freenove Ultimate Starter Kit for ESP32\C\Processing\Processing\Oscilloscope\Oscilloscope.pde** and click Run. If the connection succeeds, the follow will be shown:
.. image:: ../_static/imgs/1_Oscilloscope/Chapter01_02.png
:align: center
The green line is the waveform acquisited. Rotate the potentiometer, then you can see changes of the waveform:
.. image:: ../_static/imgs/1_Oscilloscope/Chapter01_03.png
:align: center
Disconnect the A10 port from the potentiometer and connect it to the Pin 2 port. Pin 2 port output is 0.5Hz square wave. As is shown below:
.. image:: ../_static/imgs/1_Oscilloscope/Chapter01_04.png
:align: center
The left side of the software interface is a voltage scale, which is used to indicate the voltage of the waveform.
The "1000ms" on top left corner is the time of a square, and you can press “↑” and “↓” key on keyboard to adjust it.
The "0.00V" on top right corner is the voltage value of current signal.
You can press the space bar on keyboard to pause the display waveform, which is easy to view and analysis.
We believe that with the help of this oscilloscope, you can obtain more intuitive understanding of the actual work of some electronic circuits. It will help you complete the project and eliminate the trouble. You can export this sketch to an application used as a tool.

View File

@ -0,0 +1,101 @@
##############################################################################
Chapter Control 2D and 3D Figures
##############################################################################
In this chapter, we will use ESP32 board to make Processing program control figure changes. And we will control 2D and 3D figures, respectively.
Project 2.1 Ellipse
*************************************
First, control a 2D figure.
Component List
====================================
+------------------------------------+------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1|
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+------------------------------------+------------------------+
| Joystick x1 | Jumper M/M x3 |
| | |
| |Chapter14_00| | |Chapter01_05| |
+------------------------------------+------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter13_00| image:: ../_static/imgs/1_LED/Chapter13_00.png
.. |Chapter07_04| image:: ../_static/imgs/7_Buzzer/Chapter07_04.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter14_00| image:: ../_static/imgs/14_Joystick/Chapter14_00.png
Circuit
=======================================
Use Pin36 and Pin39 (A0 and A3) ports to detect the voltage value of two rotary potentiometers inside joystick.
.. list-table::
:width: 100%
:align: center
* - Schematic diagram
* - |Chapter02_00|
* - Hardware connection.
* - |Chapter02_01|
.. |Chapter02_00| image:: ../_static/imgs/2_Control_2D_and_3D_Figures/Chapter02_00.png
.. |Chapter02_01| image:: ../_static/imgs/2_Control_2D_and_3D_Figures/Chapter02_01.png
Sketch
==================================
Sketch Ellipse
-----------------------------
Use Processing to open **Freenove Ultimate Starter Kit for ESP32\C\Processing\Processing\Ellipse\Ellipse.pde** , then click Run. If the connection succeeds, the following will be shown:
.. image:: ../_static/imgs/2_Control_2D_and_3D_Figures/Chapter02_02.png
:align: center
Then you can change the ellipse shape by shifting the joystick:
.. image:: ../_static/imgs/2_Control_2D_and_3D_Figures/Chapter02_03.png
:align: center
Project 2.2 Box 3D
***********************************
Now control a 3D figure.
Component list
=================================
The same as last section.
Circuit
=================================
The same as last section.
Sketch
===================================
Sketch Box_3D
--------------------------------
Use Processing to open **Freenove Ultimate Starter Kit for ESP32\C\Processing\Processing\Box_3D\Box_3D.pde** , and click Run. If the connection succeeds, the following will be shown. The left is a 3D box presented by line and the right is a 3D box entity.
.. image:: ../_static/imgs/2_Control_2D_and_3D_Figures/Chapter02_04.png
:align: center
Then you can change the space angle of two 3D box by shifting the joystick:
.. image:: ../_static/imgs/2_Control_2D_and_3D_Figures/Chapter02_05.png
:align: center

View File

@ -0,0 +1,118 @@
##############################################################################
Chapter Snake Game
##############################################################################
We have learned how control 2D and 3D figures. Now, we will use ESP32 board to play the classic snake game. There are both 2D and 3D version.
Project 3.1 Snake Game
************************************
First, let's play a 2D snake game.
Component List
====================================
+------------------------------------+------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1|
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+------------------------------------+------------------------+
| Joystick x1 | Jumper M/M x3 |
| | |
| |Chapter14_00| | |Chapter01_05| |
+------------------------------------+------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter13_00| image:: ../_static/imgs/1_LED/Chapter13_00.png
.. |Chapter07_04| image:: ../_static/imgs/7_Buzzer/Chapter07_04.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter14_00| image:: ../_static/imgs/14_Joystick/Chapter14_00.png
Circuit
==============================
Use Pin36 and Pin39 (A0 and A3) ports to detect the voltage value of two rotary potentiometers inside joystick.
.. list-table::
:width: 100%
:align: center
* - Schematic diagram
* - |Chapter03_00|
* - Hardware connection.
* - |Chapter03_01|
.. |Chapter03_00| image:: ../_static/imgs/3_Snake_Game/Chapter03_00.png
.. |Chapter03_01| image:: ../_static/imgs/3_Snake_Game/Chapter03_01.png
Sketch
===========================
Sketch Snake_Game
--------------------------
Use Processing to open **Freenove Ultimate Starter Kit for ESP32\C\Processing\Processing\Box_3D\Box_3D.pde** , and click Run.Snake_Game.pde and click Run. If the connection succeeds, the follow will be shown:
.. image:: ../_static/imgs/3_Snake_Game/Chapter03_02.png
:align: center
Press the space bar on keyboard to start the game:
.. image:: ../_static/imgs/3_Snake_Game/Chapter03_03.png
:align: center
Shift the joystick to control the snake action. The game rules are the same as the classic snake game:
.. image:: ../_static/imgs/3_Snake_Game/Chapter03_04.png
:align: center
When the game fails, press space bar to restart the game:
.. image:: ../_static/imgs/3_Snake_Game/Chapter03_05.png
:align: center
Additionally, you can restart the game by pressing the space bar at any time.
Project 3.2 Snake Game 3D
*******************************************
Now, let's experience the 3D version game.
Component list
================================
The same as last section.
Circuit
=================================
The same as last section.
Sketch
=================================
Sketch Snake_Game_3D
----------------------------------
Use Processing to open **Freenove Ultimate Starter Kit for ESP32\C\Processing\Processing\ Snake_Game_3D\Snake_Game_3D.pde Snake_Game_3D.pde** and click Run. If the connection succeeds, the follow will be shown:
.. image:: ../_static/imgs/3_Snake_Game/Chapter03_06.png
:align: center
Press the space bar on keyboard to start the game:
.. image:: ../_static/imgs/3_Snake_Game/Chapter03_07.png
:align: center
Shift the joystick to control the snake action. The game rules are the same as the classic snake game:
.. image:: ../_static/imgs/3_Snake_Game/Chapter03_08.png
:align: center
The rest operation is the same as the 2D version.

View File

@ -0,0 +1,81 @@
##############################################################################
Chapter Pick Apples
##############################################################################
In this chapter, we prepare pick apples game. You can use the joystick to pick apples.
Project 4.1 Pick Apples
**************************************
Now, let's use Processing and ESP32 board to achieve the game.
Component List
====================================
+------------------------------------+------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1|
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+------------------------------------+------------------------+
| Joystick x1 | Jumper M/M x3 |
| | |
| |Chapter14_00| | |Chapter01_05| |
+------------------------------------+------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter13_00| image:: ../_static/imgs/1_LED/Chapter13_00.png
.. |Chapter07_04| image:: ../_static/imgs/7_Buzzer/Chapter07_04.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter14_00| image:: ../_static/imgs/14_Joystick/Chapter14_00.png
Circuit
==============================
Use Pin36 and Pin39 (A0 and A3) ports to detect the voltage value of two rotary potentiometers inside joystick.
.. list-table::
:width: 100%
:align: center
* - Schematic diagram
* - |Chapter04_00|
* - Hardware connection.
* - |Chapter04_01|
.. |Chapter04_00| image:: ../_static/imgs/4_Pick_Apples/Chapter04_00.png
.. |Chapter04_01| image:: ../_static/imgs/4_Pick_Apples/Chapter04_01.png
Sketch
================================
Sketch Pick Apples
----------------------------------
Use Processing to open Pick_Apples.pde and click Run. If the connection succeeds, the follow will be shown:
.. image:: ../_static/imgs/4_Pick_Apples/Chapter04_02.png
:align: center
You can use the joystick to control the game. When the palm picked the apple, score +20.
.. image:: ../_static/imgs/4_Pick_Apples/Chapter04_03.png
:align: center
If the palm touches the bomb, the score is -20.
.. image:: ../_static/imgs/4_Pick_Apples/Chapter04_04.png
:align: center
At the same time, you need to pick as many apples as possible before the countdown is over.
When the game fails, press space bar to restart the game:
.. image:: ../_static/imgs/4_Pick_Apples/Chapter04_05.png
:align: center

View File

@ -0,0 +1,118 @@
##############################################################################
Chapter Pong Game
##############################################################################
We have experienced single-player game snake before. Now, let's use ESP32 board to play classic two-player pong game. You will experience both 2D and 3D version.
Project 5.1 Pong Game
********************************
First, let's experience the 2D version game.
Component List
====================================
+------------------------------------+------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1|
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+------------------------------------+------------------------+
| Rotary potentiometer x2 | Jumper M/M x6 |
| | |
| |Chapter09_00| | |Chapter01_05| |
+------------------------------------+------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter13_00| image:: ../_static/imgs/1_LED/Chapter13_00.png
.. |Chapter07_04| image:: ../_static/imgs/7_Buzzer/Chapter07_04.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter09_00| image:: ../_static/imgs/9_AD_DA_Converter/Chapter09_00.png
Circuit
=====================================
Use A0, A3 ports on ESP32 board to detect the voltage of rotary potentiometers.
.. list-table::
:width: 100%
:align: center
* - Schematic diagram
* - |Chapter05_00|
* - Hardware connection.
* - |Chapter05_01|
.. |Chapter05_00| image:: ../_static/imgs/5_Pong_Game/Chapter05_00.png
.. |Chapter05_01| image:: ../_static/imgs/5_Pong_Game/Chapter05_01.png
Sketch
====================================
Sketch Pong_Game
-------------------------------
Use Processing to open Pong_Game and click Run. If the connection succeeds, the follow will be shown:
.. image:: ../_static/imgs/5_Pong_Game/Chapter05_02.png
:align: center
Now you can try to turn the potentiometer to control the movement of paddle without ball. Press space bar to start the game:
.. image:: ../_static/imgs/5_Pong_Game/Chapter05_03.png
:align: center
Use potentiometer to control the movement of paddle to block the ball back. The game rules are the same as classic pong game:
.. image:: ../_static/imgs/5_Pong_Game/Chapter05_04.png
:align: center
The game will be over when one side reachs three points. Pressing the space bar can restart the game:
.. image:: ../_static/imgs/5_Pong_Game/Chapter05_05.png
:align: center
Additionally, you can restart the game by pressing the space bar at any time.
Project 5.2 Pong Game 3D
********************************
Now, let's experience the 3D version game.
Component list
===========================
The same as last section.
Circuit
==========================
The same as last section.
Sketch
============================
Sketch Pong_Game_3D
-----------------------------
Use Processing to open Pong_Game_3D.pde and click Run. If the connection succeeds, the follow will be shown:
.. image:: ../_static/imgs/5_Pong_Game/Chapter05_06.png
:align: center
Now you can try to turn the potentiometer to control the movement of paddle without ball. Press space bar to start the game:
.. image:: ../_static/imgs/5_Pong_Game/Chapter05_07.png
:align: center
Use potentiometer to control the movement of paddle to block the ball back. The game rules are the same as classic pong game:
.. image:: ../_static/imgs/5_Pong_Game/Chapter05_08.png
:align: center
The rest operation is the same as the 2D version.

View File

@ -0,0 +1,72 @@
##############################################################################
Chapter Tetris
##############################################################################
In this chapter, we prepare a tetris game for you. You can play the game by pressing the buttons.
Project 6.1 Tetris
************************************
Now, let's use Processing and ESP32 board to achieve the tetris game.
Component list
===============================
+------------------------------------+-------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1 |
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+-------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+-----------------+------------------+-------------------------+
| Jumper M/M x4 | Resistor 10kΩ x4 | Push button x4 |
| | | |
| |Chapter01_05| | |Chapter02_01| | |Chapter02_02| |
+-----------------+------------+-----+-------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter02_01| image:: ../_static/imgs/2_Button_&_LED/Chapter02_01.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter02_02| image:: ../_static/imgs/2_Button_&_LED/Chapter02_02.png
Circuit
==================================
Use Pin4, Pin5, Pin18, Pin19 port on ESP32 board to control the movement of the block.
.. list-table::
:width: 100%
:align: center
* - Schematic diagram
* - |Chapter06_00|
* - Hardware connection.
* - |Chapter06_01|
.. |Chapter06_00| image:: ../_static/imgs/6_Tetris/Chapter06_00.png
.. |Chapter06_01| image:: ../_static/imgs/6_Tetris/Chapter06_01.png
Sketch
============================
Sketch Tetris
---------------------------
Use Processing to open Tetris.pde and click Run. If the connection succeeds, the follow will be shown:
.. image:: ../_static/imgs/6_Tetris/Chapter06_02.png
:align: center
Now you can try using the buttons to control the falling block. Press the space bar to pause the game.
.. image:: ../_static/imgs/6_Tetris/Chapter06_03.png
:align: center
When the game is over, you can press the space bar to play the game again. Press ESC to exit the game.
.. image:: ../_static/imgs/6_Tetris/Chapter06_04.png
:align: center

View File

@ -0,0 +1,136 @@
##############################################################################
Preface
##############################################################################
Processing is an easy-to-use, free and open source software for writing graphical programs to run on a computer.
This document will show you how to use Processing to write programs to communicate with the control board. By doing this, we can make virtual instruments, game consoles and other projects.
Processing Software
*************************************
Processing software / Processing Development Environment (PDE) makes it easy to write programs.
Processing software uses Java programming language by default. Do not worry if you don't know Java, because we provide complete code. You can learn Java later if you are interested in it.
First, install Processing software. Visit https://processing.org/, click "Download" to enter the download page.
.. image:: ../_static/imgs/Preface/Preface51.png
:align: center
Select the Mac, Windows, or Linux version, depending on what machine you have.
.. image:: ../_static/imgs/Preface/Preface52.png
:align: center
Installation on each machine is straightforward:
- On Windows, you'll have a .zip file. Double-click it, and drag the folder inside to a location on your hard disk. It could be Program Files or simply the desktop, but the important thing is for the processing folder to be pulled out of that .zip file. Then double-click processing.exe to start.
- The Mac OS X version is also a .zip file. Double-click it and drag the Processing icon to the Applications folder. If you're using someone else's machine and can't modify the Applications folder, just drag the application to the desktop. Then double-click the Processing icon to start.
- The Linux version is a .tar.gz file, which should be familiar to most Linux users. Download the file to your home directory, then open a terminal window, and type:
**tar xvfz processing-xxxx.tgz**
(Replace xxxx with the rest of the file's name, which is the version number.) This will create a folder named processing-2.0 or something similar. Then change to that directory:
**cd processing-xxxx**
and run it:
**./processing**
With any luck, the main Processing window will now be visible. Everyone's setup is different, so if the program didn't start, or you're otherwise stuck, visit the troubleshooting page for possible solutions.
.. image:: ../_static/imgs/Preface/Preface53.png
:align: center
You're now running the Processing Development Environment (or PDE). There's not much to it; the large area is the Text Editor, and there's a row of buttons across the top; this is the toolbar. Below the editor is the Message Area, and below that is the Console. The Message Area is used for one line messages, and the Console is used for more technical details.
Install ControlP5
***************************
Open Processing.
.. image:: ../_static/imgs/Preface/Preface54.png
:align: center
Click Add Tool under Tools.
.. image:: ../_static/imgs/Preface/Preface55.png
:align: center
Select Libraries in the pop-up window.
.. image:: ../_static/imgs/Preface/Preface56.png
:align: center
Input “ControlP5” in the searching box, and then select the option as below. Click “Install” and wait for the installation to finish.
.. image:: ../_static/imgs/Preface/Preface57.png
:align: center
First Use
******************************
In the editor, type the following:
.. code-block:: c
ellipse(50, 50, 80, 80);
This line of code means "draw an ellipse, with the center 50 pixels over from the left and 50 pixels down from the top, with a width and height of 80 pixels." Click the Run button (the triangle button in the Toolbar).
.. image:: ../_static/imgs/Preface/Preface58.png
:align: center
If you've typed everything correctly, you'll see a circle on your screen.
.. image:: ../_static/imgs/Preface/Preface59.png
:align: center
If you didn't type it correctly, the Message Area will turn red and complain about an error. If this happens, make sure that you've copied the example code exactly: the numbers should be contained within parentheses and have commas between each of them, and the line should end with a semicolon.
.. image:: ../_static/imgs/Preface/Preface60.png
:align: center
You can export this sketch to an application to run it directly without opening the Processing.
To export the sketch to the application, you must first save it.
.. image:: ../_static/imgs/Preface/Preface61.png
:align: center
So far, we have completed the first use. I believe you have felt the joy of it.
Communication protocol
***********************************
We need to write code for control board and Processing to complete the interaction project of them, respectively.
In order to simplify and facilitate the operation, we prepared a SerialDevice class for Processing to communicate with the control board. To use this class, we need to upload the following sketch to the control board:
:red:`Freenove Ultimate Starter Kit for ESP32\C\Processing\SerialDevice\SerialDevice.ino.`
This sketch only need to be uploaded once, so the latter projects of this tutorial does not need to upload again.
SerialDevice class and SerialDevice.ino defined the communication protocol between them. The futures include:
- Recognize the control board uploaded SerialDevice.ino and establish connection with it, automatically. No need to view and set the serial number of the control board connected to the computer, even if there are a number of control board, it can be connected automatically.
- If control board uploaded SerialDevice.ino is not connected to computer, the Processing code will not be executed until the connection is done. The Processing sketch does not need to be run again after the connection is done.
- Send data to control board and receive data from it.
Here, Processing sketch code will not be introduced in detail. Interested readers can learn it by yourself.
And as for syntax and standard functions of Processing, you can visit https://processing.org/ and click Reference to view.
.. image:: ../_static/imgs/Preface/Preface62.png
:align: center
Or in the Processing software menu bar, click Help-Reference to view offline documents.
.. image:: ../_static/imgs/Preface/Preface63.png
:align: center

View File

@ -0,0 +1,4 @@
##############################################################################
Chapter
##############################################################################

View File

@ -0,0 +1,13 @@
##############################################################################
What's next?
##############################################################################
Thanks for your reading! This document is all over here.
If you find any mistakes, please feel free to contact us at support@freenove.com. We would love to hear from you.
If you want to learn more about electronics and programming, interesting robots and projects, please continue to follow our website. We will continue to launch cost-effective, innovative and exciting products.
www.freenove.com
Thank you again for choosing Freenove products.

View File

@ -27,12 +27,11 @@ Python language
Python/29_TCP_IP.rst
Python/30_Camera_Web_Server.rst
.. toctree::
.. toctree::
:maxdepth: 1
:caption: What's next?
:glob:
Python/What_s_next(47).rst
Python/What_s_next(others).rst
.. toctree::

View File

@ -128,103 +128,4 @@ When the mobile phone send data to ESP32 via BLE Bluetooth, it will print them o
:lines: 80-96
:dedent:
Project Bluetooth Control LED
*********************************************
In this section, we will control the LED with Bluetooth.
Component List
======================================
+------------------------------------+-------------------------+
| ESP32-WROVER x1 | GPIO Extension Board x1 |
| | |
| |Chapter01_00| | |Chapter01_01| |
+------------------------------------+-------------------------+
| Micro USB Wire x1 |
| |
| |Chapter08_00| |
+--------------------------------------------------------------+
| Breadboard x1 |
| |
| |Chapter01_02| |
+-----------------+------------------+-------------------------+
| LED x1 | Resistor 220Ω x1 | Jumper M/M x2 |
| | | |
| |Chapter01_03| | |Chapter01_04| | |Chapter01_05| |
+-----------------+------------------+-------------------------+
.. |Chapter01_00| image:: ../_static/imgs/1_LED/Chapter01_00.png
.. |Chapter01_01| image:: ../_static/imgs/1_LED/Chapter01_01.png
.. |Chapter01_02| image:: ../_static/imgs/1_LED/Chapter01_02.png
.. |Chapter01_03| image:: ../_static/imgs/1_LED/Chapter01_03.png
.. |Chapter01_04| image:: ../_static/imgs/1_LED/Chapter01_04.png
.. |Chapter01_05| image:: ../_static/imgs/1_LED/Chapter01_05.png
.. |Chapter08_00| image:: ../_static/imgs/8_Serial_Communication/Chapter08_00.png
Circuit
==========================================
Connect Freenove ESP32 to the computer using a USB cable.
.. list-table::
:width: 80%
:header-rows: 1
:align: center
* - Schematic diagram
* - |Chapter27_27|
* - Hardware connection.
If you need any support, please feel free to contact us via: support@freenove.com
|Chapter27_28|
.. |Chapter27_27| image:: ../_static/imgs/27_Bluetooth/Chapter27_27.png
.. |Chapter27_28| image:: ../_static/imgs/27_Bluetooth/Chapter27_28.png
Code
====================================
Move the program folder "Freenove_Ultimate_Starter_Kit_for_ESP32/Python/Python_Codes" to disk(D) in advance with the path of "D:/Micropython_Codes".
Open "Thonny", click "This computer" -> "D:" -> "Micropython_Codes" -> "27.2_ BLE_LED". Select "ble_advertising.py", right click your mouse to select "Upload to /", wait for "ble_advertising.py" to be uploaded to ESP32-WROVER and then double click "BLE_LED.py".
BLE_LED
-----------------------------------
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_44.png
:align: center
Compile and upload code to ESP32. The operation of the APP is the same as 27.1, you only need to change the sending content to "led_on" and "led_off" to operate LEDs on the ESP32-WROVER.
Data sent from mobile APP:
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_45.png
:align: center
You can check the message sent by Bluetooth in "Shell".
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_46.png
:align: center
The phenomenon of LED
.. image:: ../_static/imgs/27_Bluetooth/Chapter27_47.png
:align: center
Attention: If the sending content isn't "led_on' or "led_off", then the state of LED will not change. If the LED is on, when receiving irrelevant content, it keeps on; Correspondingly, if the LED is off, when receiving irrelevant content, it keeps off.
The following is the program code:
.. literalinclude:: ../../../freenove_Kit/Python/Python_Codes/27.2_BLE_LED/BLE_LED.py
:language: python
:dedent:
Compare received message with "led_on" and "led_off" and take action accordingly.
.. literalinclude:: ../../../freenove_Kit/Python/Python_Codes/27.2_BLE_LED/BLE_LED.py
:language: python
:lines: 88-91
:dedent:
.. include:: 27_2_Bluetooth.rst

View File

@ -1,13 +0,0 @@
##############################################################################
What's next?(47)
##############################################################################
Thanks for your reading. This tutorial is all over here. If you find any mistakes, omissions or you have other ideas and questions about contents of this tutorial or the kit and etc., please feel free to contact us:
support@freenove.com
We will check and correct it as soon as possible.
If you want to learn more about Arduino, Raspberry Pi, smart cars, robots and other interesting products in science and technology, please continue to focus on our website. We will continue to launch cost-effective, innovative and exciting products.
http://www.freenove.com/

View File

@ -31,6 +31,7 @@ This product provides the following online documents.
.. toctree::
:maxdepth: 1
:caption: FNK0060
fnk0060/codes/C.rst
fnk0060/codes/Python.rst