Skip to content

Add filesystem example guide and update filesystem API #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions source/amebapro2/API_Documents/FileSystem/Class File.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ A class for data manipulation of files in a file system.
+---------------------------+------------------------------------------+
| File::name | Get currently open file name. |
+---------------------------+------------------------------------------+
| File::convertMp3ToArray | Convert MP3 file to MP3data and MP3size. |
+---------------------------+------------------------------------------+

**File::File**
--------------
Expand Down Expand Up @@ -487,3 +489,35 @@ This function returns a pointer to a character array containing the filename of
NA

.. note :: "AmebaFatFSFile.h" must be included to use the class function.

**File::convertMp3ToArray**
---------------------------

**Description**
~~~~~~~~~~~~~~~

Convert MP3 file to MP3data and MP3size.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

void convertMp3ToArray(void);

**Parameters**
~~~~~~~~~~~~~~

NA

**Returns**
~~~~~~~~~~~

This function convert MP3 file into character array containing the MP3data without the ID3 header. If no file is open for conversion, it will print out error message.

**Example Code**
~~~~~~~~~~~~~~~~

NA

.. note :: "AmebaFatFSFile.h" must be included to use the class function.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Play MP3 with SD card
=====================

.. contents::
:local:
:depth: 2

Materials
---------

- `AMB82-mini <https://www.amebaiot.com/en/where-to-buy-link/#buy_amb82_mini>`_ x 1

- MicroSD card

- 3.5mm TRS/TRRS breakout x 1 (e.g., Adafruit 2791 / Sparkfun 11570)

Example
-------

In this example, we will use the Ameba Pro2 board to play MP3 audio from SD card.

Procedure
~~~~~~~~~

Using a card reader, connect the SD card to a computer and copy the MP3 file into the SD card. Take note to place the MP3 file in the root directory
and not in any folder. The MP3 sample file can be downloaded at https://github.com/ambiot/ambpro2_arduino/tree/dev/Ameba_misc/Example_Samples/Audio_test.mp3.

|image01|

Connect the audio jack to the Ameba board as shown in the diagram.

|image02|

Insert the MicroSD card into the SD card slot of the AMB82 MINI board.

Open the example in “File” -> “Examples” -> “AmebaMultimedia” -> “SDCardPlayMP3”.

|image03|

In the highlighted code snippet, fill in the MP3 file name which was store on the MicroSD card.

|image04|

Plug in a pair of wired earbuds or a wired speaker into the audio jack. Upload the code and press the reset button on the board, now you can hear the MP3 audio through the earbuds.

.. |image01| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/Play_MP3_with_SD_card/image01.png
:width: 900 px
:height: 550 px

.. |image02| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/Play_MP3_with_SD_card/image02.png
:width: 586 px
:height: 610 px

.. |image03| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/Play_MP3_with_SD_card/image03.png
:width: 1000 px
:height: 550 px

.. |image04| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/Play_MP3_with_SD_card/image04.png
:width: 1000 px
:height: 550 px

2 changes: 2 additions & 0 deletions source/amebapro2/Example_Guides/Multimedia/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Multimedia
Motion Detection Masking with MP4 Recording
Motion Detection with On-Screen Display
MP4 Recording
Play MP3 with SD card
RTP Audio Stream
RTSP Audio Stream
RTSP Streaming V7RC
RTSP Streaming

Loading