/**************************************************************************
Function: key scan
Entry parameters: Double-click waiting time
Return value: button status 0: no action 1: single click 2: double click
key=0 means pressing
**************************************************************************/
u8 click_N_Double (u8 time)
{
static u8 flag_key,count_key,double_key;
static u16 count_single,Forever_count;
if(KEY2==0) Forever_count++; //Long press flag is not set to 1
else Forever_count=0;
if(0==KEY2&&0==flag_key) flag_key=1;
if(0==count_key)
{
if(flag_key==1)//Click once to enter once
{
double_key++;
count_key=1;
}
if(double_key==2) //Judge double click
{
double_key=0;
count_single=0;
return 2; //Double click to execute command
}
}
if(1==KEY2) flag_key=0,count_key=0;
if(1==double_key)
{
count_single++;
if(count_single>time&&Forever_count
Previous article:Detailed explanation of the magic of STM32 buttons
Next article:STM32 Getting Started Development--LED Module to Implement Marquee
Recommended ReadingLatest update time:2024-11-16 16:03
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- PA Design Principles and Practice - PA Design Based on MRF8P9040N - Personally Tested ADS2011
- There are 5 Bing Dwen Dwen waiting for you to win in the forum: DIY Bing Dwen Dwen together!
- [Mill Edge AI Computing Box FZ5 Review] Handwritten digit recognition - pytorch network builds Lenet network
- Does anyone have the Chinese operating instructions for the Agilent E4408B spectrum analyzer?
- 【IoT Graduation Project. Part 2】STM32+Gizwits AIoT+Laboratory Safety Monitoring System
- Is it necessary to pull up the data line and pull down the clock line in SWD mode for the burning port?
- MSP430 drives MCP4017 digital potentiometer driver debugging record
- [RVB2601-demo analysis and kernel analysis] YOC architecture + three-color indicator light
- dsp2812 ADC application experience
- The questions for this national competition were released at 7:30 this morning. What do you think?