[Allwinner ClassA20 class library Analysis] 1. Delphi on ARM, allwinnerclassa20
Speaking of Delphi on the host computer, there may be many people familiar with it before. Although there were fewer and fewer people using Delphi with the collapse of Borland in the past few years, however, this does not cover the light of her advanced VCL framework and all-powerful player. On Windows, the once compiled exe file can be run without installing any Runtime Library, no matter from Win95 or Win8.1, it used to be a preferred language for virus writing. In the development of various management systems, Delphi is also a language with extremely high development efficiency and operational efficiency. Borland's policy of over-binding Windows has greatly reduced the chances of applying Windows to other platforms. Her sister, Kilix on x86 Linux, is also not popular nowadays, not to mention on ARM. Recently, Delphi, which was acquired by Yi bolong, started a Jedi counterattack under the guidance of a new company. The Delphi XE series not only can develop Windows 32-bit and 64-bit native programs, at the same time, you can directly compile the Android and iOS programs without changing the code, greatly expanding the application scenarios. It also maintains the advantages of rapid development and rich controls. Imagine visual development. Simply drag a few button input boxes in the form to run on your device. Such development is a pleasure.
After talking about this, it's time for the main character to show up. But don't worry, this time the main character is not Delphi, but a brother like Delphi but has no kinship: free pascal. It is based on the pascal language, but this brother is even more excited, whether it is x86 Windows, Linux, Android, MacOS, or ARM's WinCE, Linux, Android, iOS, etc, or MIPS-based operating systems can become active platforms. It has a similarity of more than 98% with Delphi, and adhering to the advantages of Delphi, it is said that it can be "compiled once, compiled everywhere ". The compiled program can be directly compiled into the corresponding system program using different compilers, greatly reducing the workload of porting between systems.
Free pascal is just like its name. It is free, and neither learning nor developing products are permitted. Free pascal is a language with its own IDE environment: Lazarus. After a long period of development and many bugs have been fixed, the current version is 1.2x, which is relatively stable and can be officially used. He looks very similar to Delphi 5, and can be quickly used by novice or veteran. I can't wait. Please show it to Lazarus.
The development environment, compilation environment, and running environment mentioned this time are all carried out on ARM Lubuntu on the banana family, and the environment is not difficult to build, there are no fancy skills. Everything is for simple, practical, and rapid development. This is also true for other Linux releases, and for other ARM devices. The executable files compiled on the banana school can be directly copied to other ARM boards for running (excluding the underlying drivers involved) without carrying a large number of so or other files.
To put it bluntly, start installing Lazarus. Only four commands are required:
1. sudo apt-get update
2. sudo apt-get upgrade
3. sudo apt-get install fpc
4. sudo apt-get install lazarus
In fact, only the last command is supported. When lazarus is installed, the fpc compiler can be automatically installed in some Linux versions. For the sake of insurance, it is better to install it separately. To ensure that the latest version is installed, run the first two commands.
The installation process is no longer detailed, and there is no manual change. The program is relatively large, which may look like 2 or M. The speed of the network speed and SD card greatly affects the installation speed, but I have satisfied it, at least it is much faster and easier than QT. After installation, you can find it in the programming sub-menu in the Start Menu, Lazarus, run it.
After running, it looks like this:
There are only a few common operations. However, Lazarus provides a Chinese language which is developed by Chinese fans. Thanks again. For the Chinese Language, choose "Tools"> "Options"> "Desktop"> "Language.
After saving the settings, You need to disable Lazarus. After running it again, it becomes Chinese.
After Lazarus runs, a project with a form is created by default. According to the number in the figure, the functions of each part are described as follows:
1. Visualized editing form: This form is the form displayed by the Compilation Program. What you see is what you get;
2. Run and breakpoint debugging: You can directly run the current program and execute each statement in one step. When a breakpoint is executed, the current running value is displayed when you place the cursor over a certain volume;
3. Component toolbar: select a required component and place it in a proper position on the editing form. After double-clicking the component, you can directly jump to the corresponding code line and add the function code by yourself;
4. Object Viewer: displays all the components that have been placed on the editing form. You can select components that cannot be clicked by clicking the mouse because of overwriting;
5. Edit attributes and events: After selecting a component, you can set some attribute values here, change its functions or styles, or add events for it (the form is also a component );
6. Code Editor: This is not much to say. It is the place where the code is written. Click the blank area in front of the row number to set the breakpoint and click Cancel again;
7. Message form: Some information during compilation is displayed here, including warnings and errors;
After introducing the general functions, let's take a look at what it looks like after running. If you directly click the green triangle in the running and debugging sections to run the program, it is too boring. Let's take a look at some practical functions: Click the close button to bring up a dialog box that allows users to choose whether to exit the program.
First, select "Button" in the component toolbar and place it in the form. Find "Caption" in properties and change the value to "Quit". Press enter, this is the text displayed on the button;
Double-click the Button in the form to automatically jump to the "Button_Click" Event code in the Code Editor and write the code in it.
Close;
Case Insensitive;
Finally, select the form, select the event tag in the event properties and event Editing Section, find "OnCloseQuery", double-click to jump to the Code, and write the code
CanClose: = Application. MessageBox ('Are you sure? ', 'Title', MB_OKCANCEL) = IDOK;
Do not forget to add a constant-defined unit LCLType to the Code uses at the top of the Code Editor. If this unit is not added, change MB_OKCANCEL and IDOK to 1, otherwise, the system prompts that the definition cannot be found during compilation.
Start running. Click the green triangle. the first running time is long, especially for programs with forms. It will be much faster since the second time. After running, click the Quit button to bring up the dialog box
Select "OK" to exit the program. Select "Cancel" to return to the form.
Running principle: When you click the "Quit" button, the code is closed. Normally, you should close the form and exit the program. However, the "OnCloseQuery" event is added, that is, the event triggered before the form is closed, and a dialog box is added to allow the user to choose whether to exit, determine the action to be performed next Based on the selected result. If the user cancels the operation, the form is no longer closed.
Now you have compiled ~ 8.1 program code running on Linux, MacOS, WinCE, ARM Linux, and Android can be compiled on the corresponding platform. So far, I have a perceptual knowledge of Lazarus. Is it easy to operate? If you are interested, refer to the next section to describe the structure of pascal code units and common debugging methods.
To download the ClassA20 encapsulation class library file, visit: https://github.com/tjcfeng/classa20.