Create Project
Overviewโ
This topic describes how to run the tos.py new project command to create a new project. The tos.py new project command is used to create a new project within the TuyaOpen development environment. This command quickly initializes the basic structure of a new project based on predefined templates.
Procedureโ
Run the command tos.py new project. The system will prompt you to enter the new project's name and select a platform.
โฏ tos.py new project
[INFO]: Running tos.py ...
[NOTE]: Input new project name.
input: new-project
After the command execution is completed, the system will create a folder named new-project in the current directory, containing the basic structure of the new project.
Directoryโ
new-project
โโโ app_default.config # Default configuration file
โโโ CMakeLists.txt # CMake build configuration
โโโ src
โโโ hello_world.c # Sample code file
Parametersโ
-f, --framework [base|arduino]: Specifies the framework type used by the project.
base(default): Creates a base framework project.arduino: Creates an Arduino framework project.
Next stepโ
Overview:
Build and verify.
Write code.
Modify configuration and verify functionality.
Save the default configuration file for use by other developers.
Build and verifyโ
First, use the command tos.py config choice to select the desired chip platform configuration.
Then, use the command tos.py build to perform compilation verification.
Write codeโ
-
Determine your code's directory structure and configure the source file and header file paths required for
add_library(${EXAMPLE_LIB})in theCMakeLists.txtfile.-
${EXAMPLE_LIB}: This is the library name variable, defined by the main framework, and does not need to be modified manually. -
Configure the
APP_SRCandAPP_INCvariables using standardCMakesyntax.
-
-
Proceed with code development.
Develop using the interfaces provided in
${tuyaopen_root}/srcand${tuyaopen_root}/platform/.../tuyaos_adapter.You can refer to the official sample codes in
appsandexamples. -
Change the configuration file.
Run the command
tos.py config menuto enter the configuration interface, then adjust TuyaOpen's configuration options.
Verify functionalitiesโ
Flash the firmware and verify the code's functionalities.
Save the default configuration fileโ
Run the command tos.py config save to save the current configuration as the default configuration file.