Is micropython suitable for development?
MicroPython has become popular in the domestic programming community recently. What is the reason why it is so popular? Is it because it has powerful functions and is open source under the Mit license?
The origin of Micropython is due to Damien George, a great computer engineer. Damien George uses Python for work every day. One day he came up with a bold idea: Can Python be used to control a microcontroller? What about operating robots?
So is micropython suitable for development?
The Python language itself is an easy-to-use scripting language. Some non-computer major enthusiasts choose Python language as their introductory language. , but it has a fly in the ointment (why China and the United States do not participate in the World Cup), it cannot implement some low-level operations, and is inconspicuous in the hardware field. Therefore, Damien George spent 6 months to build MicroPython. This is the origin of MicroPyhton.
MicroPython is based on ANSIC, and its syntax is basically the same as Python3. It has an independent parser, compiler, virtual machine and class library. Currently it supports 32-bit based ARM processors, such as STM32F401, STM32F405, and STM32F407.
The following comparisons were made using the three languages of assembly, C, and MicroPython to illustrate whether micropython is suitable for development?
1. Compilation environment
Before writing programs in C language and assembly language, you need to download the compilation environment. However, Micropython does not require any compilation environment. You only need to insert the U port of the development board into the computer. A drive letter can appear on the computer, just like inserting a U disk. Then open the U disk and edit main.py directly with Notepad. The comfort of it is that MicroPython does not require any tools and environments. Any text tool can be used with just one development board. It can be developed and compiled, and you can give it a nickname - pocket programming computer. . . The best one in China is the TPYBoard v102 development board. If you are interested, you can learn more about it. It has complete information and video learning materials, which is quite good. That’s how I got into it.
2. Operation difficulty
The basic operation of assembly language is simple, but it is relatively difficult to achieve complex project goals. The code is lengthy and debugging is difficult; C language has statements and a large number of libraries Functions are simpler than assembly; MicroPython has more library functions than C, and the code format is not only simpler. With the support of the library, many functions and methods do not need to be written by yourself. You can just import xx directly. The class library import is ok. In the past, it took five or six lines of code to light a lamp, but now it only takes one line of code to light up the LED, so easy.
3. Program structure
Assembly language generally uses a jump structure. Whether it is a subroutine call, a loop or a random jump, in theory, the jump method is used to interrupt the operation or force an exit. The operation of the program segment requires precise control of the stack push, and the requirements are very strict; the C language generally uses a loop structure or a sequential structure, and there is no need to jump around to execute the program. The interrupt operation will automatically push the stack without human intervention. When timing requirements are high, assembly can be embedded to improve efficiency; MciroPython can use the C program structure or the thread structure. The thread structure requires strict and reasonable allocation of thread working time without conflicts, and good control of resources. , resources cannot be wasted by idle threads. In theory, multi-threads can run more efficiently. Although a single core can only run a single thread at the same time, it is synchronized from a macro perspective. It can effectively reduce the program when time requirements are not strict. difficulty of writing.
4. Writing method
When assembly does not use macros, the instructions usually directly operate the unit, which requires memorizing a large number of data unit uses, and due to the large number of program lines (possibly (will reach one or two thousand lines), you need to look back and forth through the program code, and the entire writing process is relatively cumbersome. And because they are all 8-bit units, complex data operations need to be completed by nesting C language; any variables used in C language need to be defined first. Compared with not having to memorize variable names, the overall structure is clear and most programming software has jumps. The subroutine function makes it very convenient to find program blocks. There are a large number of finished header files containing various commonly used functions, which reduces the writing of complex program codes; MicroPython inherits the writing advantages of C and does not require pre-definition or any end symbols. You only need to change the line to continue writing. But pay attention to the use of the Tab key in some special circumstances.
5. Readability
The assembly itself is difficult to read because there are few marks and the units are directly manipulated. The visual structure is not only two columns of code but also requires constant jumps, so it is difficult to read. It’s very difficult; the simple operation codes in C language are relatively clear, but for complex ones, you have to find methods within methods. Many complex codes have to be found by yourself, which makes people feel very headache; MicroPython has better readability than C , and because many special symbols have been cancelled, the overall feeling is relatively clear. Many methods are written separately in separate libraries and can be called directly. Each function has a separate class library, which seems extremely convenient and clear at a glance.
The above is the detailed content of Is micropython suitable for development?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

In VS Code, you can run the program in the terminal through the following steps: Prepare the code and open the integrated terminal to ensure that the code directory is consistent with the terminal working directory. Select the run command according to the programming language (such as Python's python your_file_name.py) to check whether it runs successfully and resolve errors. Use the debugger to improve debugging efficiency.

Python excels in automation, scripting, and task management. 1) Automation: File backup is realized through standard libraries such as os and shutil. 2) Script writing: Use the psutil library to monitor system resources. 3) Task management: Use the schedule library to schedule tasks. Python's ease of use and rich library support makes it the preferred tool in these areas.

VS Code extensions pose malicious risks, such as hiding malicious code, exploiting vulnerabilities, and masturbating as legitimate extensions. Methods to identify malicious extensions include: checking publishers, reading comments, checking code, and installing with caution. Security measures also include: security awareness, good habits, regular updates and antivirus software.

CentOS Installing Nginx requires following the following steps: Installing dependencies such as development tools, pcre-devel, and openssl-devel. Download the Nginx source code package, unzip it and compile and install it, and specify the installation path as /usr/local/nginx. Create Nginx users and user groups and set permissions. Modify the configuration file nginx.conf, and configure the listening port and domain name/IP address. Start the Nginx service. Common errors need to be paid attention to, such as dependency issues, port conflicts, and configuration file errors. Performance optimization needs to be adjusted according to the specific situation, such as turning on cache and adjusting the number of worker processes.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.
