In the design of a single-chip microcomputer, it is often necessary to display a multi-level operation menu on the display screen. Each level menu has some menu items and corresponding key operations, and subsequent processing programs executed in response to various operations. References use function pointers as structural elements to stretch the entire menu structure into an array of structures containing all the menu items. This method does not separate the menu item data from the function function, but writes the menu item data in the function function. When the menu item data needs to be changed, the function function must be modified, which greatly limits the versatility of the program. It is not conducive to the maintenance of the program. The reference literature is slightly improved on the basis of the former, and the menu item display text and the button multiplex mark are added to the original structure, which makes the structure larger, and the text content of the menu item is very fixed, and is saved in the EEPROM, which is not flexible. Change the display content and location. The reference introduces a window and message mechanism under Windows system to realize multi-level menu design. This method requires maintenance stack, message queue and window timer, etc., and the design is too complicated.
This paper aims to provide a lightweight single-chip multi-level menu implementation method, with less system resource consumption and simple and convenient way to complete the menu design. Considering that the menu program needs to have three basic elements: one is the content to be displayed in each menu window; the other is the button definition and response corresponding to each window; the third is the switching between menu items in the window and the switching mechanism between windows. . Therefore, the menu is divided into two parts: the menu window module and the keyboard processing module, and the design is performed independently.
1 menu window module designThe main function of the menu window module is to complete the display control of the window in real time according to the menu window switching mechanism.
1.1 Menu window switching mechanism
The menu window switching mechanism includes two points: one is the realization of the switching effect between different windows; the other is the realization of the scroll switching effect between the same level menu items in the window. To achieve the above functions, two structures, MenuState and MenuItEMS, are defined. MenuState is defined as follows:
MenuState is an array of structures related to window jumps and window displays for globally scheduling the transitions between windows. Among them, CurIndex is the index value of the window, which is used to identify the current window. UPINdex, DnIndex, and BackIndex are used to identify the window that the program should turn to when there are "upper page", "next page", and "return" button operations. When the value is 255, it means no steering window. When the value is 0~254, it indicates the index of the window to be turned. Therefore, this design can support 255 menu windows, which is sufficient for engineering applications. CurOperate is a function pointer that points to the window display control program that should be executed when the current window is displayed to implement window display.
MenuItems is a menu item structure that saves the display position and content of all menu items of the current window. The content of this structure is updated during the initialization of the new window as the window switches. This satisfies the need for window switching and reverse scrolling between menu items. Since only menu items related to the current window are saved, the system resource consumption of the structure is small.
Items contains all the menu items in the current window. Considering that some menu items have no steering window, this value is set to 255 for this menu item. When a window is displayed, Items will be filled in the menu item information of the current window, and the filling will be constructed in the order of the menu items. In this way, when there are "upward" and "down" button operations, the target line can be quickly found and the line is reversed.
1.2 Menu window display control
The window display part encapsulates each menu window in an independently named function. The function includes assigning items to the menu, displaying the menu items of the current window at the specified position on the display screen, and drawing, drawing, and drawing as needed. Drawing operations such as buttons. These functions are independent of each other and correspond to different menu windows. They are only given to CurOperate when the window is switched, so it is very suitable for multi-person development.
It should be noted that the display control of the menu window is based on the display screen. The TFT screen or the dot matrix liquid crystal screen is commonly used in engineering. When using, the driver of the display screen needs to be realized, and the screen is initialized, read, written, etc. Since this is not the focus of this article, this part is skipped.
2 keyboard processing module designThe menu operations of the MCU are mostly done in the form of buttons. Generally, there are multiple buttons, which correspond to different functions. In addition, the button multiplexing problem should also be considered. That is to say, the buttons in the same position may have different function definitions in different windows. Therefore, the keys are collected and parsed in the program to respond correctly. The flow of button processing is shown in Figure 1.
For example, when the "upper page" button is pressed, the program receives the button, parses the key definition according to the currently located window, and determines "upper page"; then obtains an index to the window in the window structure menu Index The value, according to the index value, obtains a pointer of the window display control program, and releases the menu item structure ItEMS, and executes the window display control program. code show as below:
In a certain equipment simulation project, the AT89C52 chip is used as the core device, and the display part adopts the graphic dot matrix liquid crystal display module HG3202405V2-B-LWH-LV, and the external composite function button 6 to realize the menu design. Some of the code is as follows:
The main menu window is shown in Figure 2.
The multi-level menu design of single-chip microcomputer is a common problem in project development. This paper gives the solution and is applied in the project. Its characteristics are manifested in two aspects: First, the system overhead is small, only the MenuState and MenuItEMS two structures and several variables can maintain the same level menu items in each window and window; Second, the functional independence of each part of the module is strong. The display control programs of each menu window are independent of each other and do not affect each other, and the keyboard processing program is also self-contained. Therefore, the scheme is highly modular, the development process is simple and convenient, the scalability is good, the portability is strong, and it is suitable for team development and maintenance.
The so-called mini projector is also called pico projector, TRT-Lcos Portable Projector. Mainly through the 3M LCOS RGB three-color projector and 720P film decoding technology, the traditional huge projector is refined, portable, miniaturized, entertaining and practical, making the projection technology closer to life and entertainment.
Usually the projector has certain regulations on 2 aspects:
a). Size: Usually the size is the size of a mobile phone.
b). Battery life: It is required to have at least 1-2 hours or more of battery life when it is not connected to power.
In addition, its general weight will not exceed 0.2Kg, and some do not even need fan cooling or ultra-small silent fan cooling. It can be carried with you (it can be put into your pocket), and the screen can be projected to 40-50 inches or more.
Advantage:
1. Completely replace the MP5 player, video, listening to songs, playing games, e-books, picture browsing, etc. MP5 video is affected by physical performance, the screen can not be bigger, and the screen of this thing is at least 20 inches.
2. Instead of the TV function, the machine can have a built-in CMMB function, or it can be directly connected to the set-top box to play the TV, and it can be used as a 21-inch TV during the day.
Look, it can be used as a 60-100-inch TV at night to achieve the effect of home theater; it is convenient to move and break through the traditional film and television space. Even if you are on the mountain, you can also share today's TV series, movies, and MTV with your lover.
3. Business office: instead of large projectors, it is used for company meetings; the price of large projectors is 4,000 to 14,000, and the lamp life is more than 1,000 hours, which is not convenient to carry. 30,000 hours, no need to change the bulb for 3 years, easy to carry, the salesman only needs to bring a micro projector to demonstrate the new product, which can achieve the demonstration effect.
4. Teaching: training meetings, classroom teaching; traditional projectors are not easy to carry. In school classrooms, due to the naughty students, projectors are not safe to place in the classroom and are easily damaged by students. The portability of micro projectors makes up for the teaching vacancies. In the future, teachers only need to store the materials in the projector and show them to students for teaching, saving the trouble of textbooks and handwriting with pens and chalks.
In addition, the micro-projection has no radiation, which can fully protect pregnant women and people with myopia. Its low power consumption function is 1/1,000,000 of the power consumption of color TVs. One day of electricity has completely impacted the indicators of safety, environmental protection, health, etc., and has made amazing contributions to future social development, standing at the peak of the green world as a leader.
best mini projectors under £100,mini projector pvo portable projector,mini projector portable,mini projector amazon,mini projectors for movies
Shenzhen Happybate Trading Co.,LTD , https://www.happybateprojectors.com