This macro definition refers to the macro definition under the project's Options window--"C/C++"--"Preprocerssor Symbols".
Here the macro definition allows the compiler to selectively compile certain codes. For example:
#if defined(LCD_MODEL_AT043)
#define C_GLCD_H_PULSE 41
#define C_GLCD_H_FRONT_PORCH 10
#define C_GLCD_H_BACK_PORCH 10
#define C_GLCD_V_PULSE 10
#define C_GLCD_V_FRONT_PORCH 2
#define C_GLCD_V_BACK_PORCH 2
#elif defined(LCD_MODEL_AT070)
#define C_GLCD_H_PULSE 20
#define C_GLCD_H_FRONT_PORCH 210
#define C_GLCD_H_BACK_PORCH 46
#define C_GLCD_V_PULSE 10
#define C_GLCD_V_FRONT_PORCH 22
#define C_GLCD_V_BACK_PORCH 23
#else
#define C_GLCD_H_PULSE 20
#define C_GLCD_H_FRONT_PORCH 250
#define C_GLCD_H_BACK_PORCH 50
#define C_GLCD_V_PULSE 5
#define C_GLCD_V_FRONT_PORCH 5
#define C_GLCD_V_BACK_PORCH 5
#endif
In the above code, because LCD_MODEL_AT043 is defined in the project's macro definition, only the following macro definitions will be compiled:
#define C_GLCD_H_PULSE 41
#define C_GLCD_H_FRONT_PORCH 10
#define C_GLCD_H_BACK_PORCH 10
#define C_GLCD_V_PULSE 10
#define C_GLCD_V_FRONT_PORCH 2
#define C_GLCD_V_BACK_PORCH 2
The application scenarios of this macro definition are as follows:
If your program may be used for two LCD screens: 4.3 inches and 7 inches, you can do this:
Create two project objects in the "Project Targets" under the "Manage Project Items" window (if you only created one before, you can just add another one).
At this time, when you go back to MDK, you can see two options in the drop-down box next to the download button.
This is the project object you just created.
Select the first 4.3-inch project object and add LCD_MODEL_AT043 in the project macro definition.
Select the second 7-inch project object and add LCD_MODEL_AT070 in the project macro definition.
This is done.
When you want to use the 4.3-inch screen program, select the 4.3-inch screen project object in the drop-down box, and the macro definition LCD_MODEL_AT043 will take effect, only compiling your program
#if defined(LCD_MODEL_AT043)
#define C_GLCD_H_PULSE 41
#define C_GLCD_H_FRONT_PORCH 10
#define C_GLCD_H_BACK_PORCH 10
#define C_GLCD_V_PULSE 10
#define C_GLCD_V_FRONT_PORCH 2
#define C_GLCD_V_BACK_PORCH 2
part.
You can also use this method to separate the debugging program from the official version of the program. When you need some debugging information during debugging, you can include it with a macro definition, such as:
#if defined(debug)
shellSnd("It`s debuging status now!");
#endif
Previous article:J-Link V8 Firmware Fix
Next article:Understanding AREA and ENTRY in assembly
Recommended ReadingLatest update time:2024-11-16 23:54
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Reduction Operator Introduction
- WiFi 7 specs, features and release date
- 【LuatOS-ESP32】Create a new hello world project
- C2000 Power-on Boot Mode Analysis
- Espressif ESP32-S2-Kaluga-1 Review Summary
- Please recommend a DC-DC chip with 12V-3.3V wide voltage input and 3.3V2A output
- Several key performance characteristics of the MSP432P401R MCU 14-bit ADC
- Zigbee3.0 ZCL_ALARMS usage
- 【BearPi-HM Micro】Development of smart street light module based on E53 interface
- Using Ultra-Wideband Technology to Display the Bible