【CC2530 Intensive Training 04】Timer interval timing to achieve N-click button[Copy link]
【Question Requirements】 The difficulty of developing the perception layer in the 2018 National Vocational College Skills Competition "Internet of Things Technology Application" National Competition (Higher Vocational Group) has increased sharply. All three questions are completed under the Zigbee protocol stack. The first question "Intelligent Control System of Warehouse Temperature and Humidity" examines single-click, double-click and triple-click of buttons. In order to help everyone better master the complex processing ideas of buttons, here we use a specific practical training case to explain the basic idea of realizing N-click of buttons through interval timing. On the black Zigbee module of the New World National Competition equipment, or in the XMF09B and XMF09C made by Little Bee, single-clicking the button SW1 switches the on/off state of the D5 lamp; double-clicking the button SW1 switches the on/off state of the D6 lamp; triple-clicking the button SW1 switches the on/off state of the D3 lamp; quadruple-clicking the button SW1 switches the on/off state of the D4 lamp. Button SW1-----------P1_2 D5 lamp--------------P1_3 (high level lights up) D6 lamp--------------P1_4 (high level lights up) D3 lamp--------------P1_0 (high level lights up) D4 lamp--------------P1_1 (high level lights up)
【Implementation ideas】 Each button press defines a life cycle. If it is 0.5 seconds, the final state of the button is determined at the end of the life cycle. If a new button is pressed during the life cycle of the button, the life cycle will be recalculated, and this is a double click. If a new button is pressed during the life cycle of a double click, the life cycle will be recalculated, and this is a triple click. If no new key is pressed during the entire life cycle, the final key state is a triple click. And so on.