CN105302331A - Key acquisition method based on bus - Google Patents
Key acquisition method based on bus Download PDFInfo
- Publication number
- CN105302331A CN105302331A CN201410303214.6A CN201410303214A CN105302331A CN 105302331 A CN105302331 A CN 105302331A CN 201410303214 A CN201410303214 A CN 201410303214A CN 105302331 A CN105302331 A CN 105302331A
- Authority
- CN
- China
- Prior art keywords
- button
- timer
- press
- state
- double hit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Abstract
The present invention discloses a key acquisition method based on a bus, comprising the following steps of: S1, detecting whether a key is pressed and when detecting the key is pressed, simultaneously starting a combo timer and a long-press timer; S2, detecting whether a key is released, simultaneously detecting whether the combo timer is timed out, determining a short-press event when the combo timer is timed out, and when the combo timer is not timed out, re-detecting whether a press is pressed, and if yes, determining a combo event; S3, during the process of performing the above steps S1 and S2, simultaneously detecting the long-press timer, and when detecting the long-press timer is timed out at any time, determining a long-press event. According to the method provided by the present invention, a key event state machine is introduced; and when the press is in an idle state, data sending is stopped; when the pressed key is detected, key events ( short-press, long-press, combo) are judged according to the logic of the state machine, data is sent, cycle detection is performed, and when timeout is detected, sending is performed again.
Description
Technical field
The present invention relates to a kind of button acquisition method, particularly a kind of button acquisition method based on bus.
Background technology
In onboard navigation system, transmitting key-press event by bus protocol (CAN, LIN etc.) has been design very common in onboard system, and the acquisition mode of button ensures the key point of this transmission mode reliability and validity exactly.Traditional method generally has two kinds: (1) cycle sends key-press status; (2) event sends key-press status.
In (1) above-mentioned kind mode, in order to ensure the promptness that button gathers, the cycle frequently sends a large amount of bus bandwidth of press key message consumption, and system effectiveness is low; (2) plants mode, and only have key-press status to change just updating message, if bus communication is made mistakes likely occur that key-press event is lost, system reliability is low.
Summary of the invention
Based on this, technical matters to be solved by this invention is, provides a kind of button acquisition method based on bus.
Technical scheme of the present invention is:
Based on a button acquisition method for bus, comprise the steps:
S1: detect and whether have button to press, then starts double hit timer with long by timer sometimes when detecting simultaneously;
Whether overtime whether S2: detect and whether have button to discharge, detect double hit timer simultaneously, when double hit timer expired is then short in event, when double hit timer does not have time-out, again detect and have button to press, if had, is double hit event;
S3: in the process performing above-mentioned steps S1 and S2, detects length simultaneously and presses timer, detects long by timer expired when at any time, be then long by event.
As further technical scheme, described button acquisition method step comprises five states, is respectively original state 0x0, shortly detects double hit state 0X2, double hit state 0X3 and long by state 0X4 by state 0X1, release.
As further technical scheme, in step S1, forward state 0X1 to when having detected that button is pressed.
As further technical scheme, in step S2 when button release having been detected and double hit timer does not have a time-out, then get the hang of 0X2, then enters then return state 0X0, and be judged as once short in event when button time-out being detected.
As further technical scheme, in step S2 when detect have button to press again time, get the hang of 0X3, when detecting that button discharges, return state 0X0.
As further technical scheme, in step S3 when finding length by timer expired at any time, get the hang of 0X4.
Beneficial effect:
The inventive method introduces key-press event state machine, when button is idle condition, stops sending data, when detecting that button is pressed, (short to press according to the Logic judgment of state machine, longly to press, double hit) key-press event, send data, and cycle detection wait timeout resends.The data volume of such transmission is relatively little, and can not take a large amount of bus bandwidth, validity is high; And have overtime testing mechanism, avoid detection event to lose and make mistakes, reliability is high.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of a kind of button acquisition method based on bus of the present invention.
Embodiment
Understand technology contents of the present invention for convenience of those skilled in the art, below in conjunction with drawings and Examples, the present invention is described in further detail.
Based on a button acquisition method for bus, comprising the steps: S1: detect and whether have button to press, sometimes then starting double hit timer with long by timer when detecting simultaneously; Whether overtime whether S2: detect and whether have button to discharge, detect double hit timer simultaneously, when double hit timer expired is then short in event, when double hit timer does not have time-out, again detect and have button to press, if had, is double hit event; S3: in the process performing above-mentioned steps S1 and S2, detects length simultaneously and presses timer, detects long by timer expired when at any time, be then long by event.
In a preferred embodiment, described button acquisition method step comprises five states, is respectively original state 0x0, shortly detects double hit state 0X2, double hit state 0X3 and long by state 0X4 by state 0X1, release.Further referring to this embodiment, in step S1, forward state 0X1 to when having detected that button is pressed.Further, in step S2 when button release having been detected and double hit timer does not have a time-out, then get the hang of 0X2, then enters then return state 0X0, and be judged as once short in event when button time-out being detected.In addition, in step S2 when detect have button to press again time, get the hang of 0X3, when detecting that button discharges, return state 0X0., in step S3 when finding length by timer expired at any time, get the hang of 0X4.
As shown in Figure 1, the inventive method introduces key-press event state machine, when button is idle condition, stops sending data, when detecting that button is pressed, (short to press according to the Logic judgment of state machine, longly to press, double hit) key-press event, send data, and cycle detection wait timeout resends.Its operating process is: state 0x0 is original state, jumps to state 0x1 when detecting that button is pressed, and starts double hit timer with long by timer; State 0x1 is short in state, and when detecting that button discharges and double hit timer does not have time-out, get the hang of 0x2; When button release being detected and double hit timer expired, return state 0x0; Long by timer expired when detecting, get the hang of 0x4; State 0x2 is release detection double hit state, when double hit timer expired being detected, and return state 0x0; When another detects that button is pressed, get the hang of 0x3(double hit); State 0x3 is double hit state, when detecting that button discharges, and return state 0x0; Long by timer expired when detecting, get the hang of 0x4; State 0x4 presses state for long, when detecting that button discharges, and return state 0x0; Long by timer expired when detecting, reenter state 4.The data volume of such transmission is relatively little, and can not take a large amount of bus bandwidth, validity is high; And have overtime testing mechanism, avoid detection event to lose and make mistakes, reliability is high.
Above-described embodiment is only wherein specific implementation of the present invention, and it describes comparatively concrete and detailed, but therefore can not be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these apparent replacement forms all belong to protection scope of the present invention.
Claims (6)
1., based on a button acquisition method for bus, it is characterized in that comprising the steps:
S1: detect and whether have button to press, then starts double hit timer with long by timer sometimes when detecting simultaneously;
Whether overtime whether S2: detect and whether have button to discharge, detect double hit timer simultaneously, when double hit timer expired is then short in event, when double hit timer does not have time-out, again detect and have button to press, if had, is double hit event;
S3: in the process performing above-mentioned steps S1 and S2, detects length simultaneously and presses timer, detects long by timer expired when at any time, be then long by event.
2. a kind of button acquisition method based on bus according to claim 1, it is characterized in that, described button acquisition method step comprises five states, is respectively original state 0x0, shortly detects double hit state 0X2, double hit state 0X3 and long by state 0X4 by state 0X1, release.
3. a kind of button acquisition method based on bus according to claim 2, is characterized in that, forwarding state 0X1 in step S1 when having detected that button is pressed.
4. a kind of button acquisition method based on bus according to claim 3, it is characterized in that, in step S2 when button release having been detected and double hit timer does not have a time-out, then get the hang of 0X2, then enter then return state 0X0 when button time-out being detected, and be judged as once short in event.
5. a kind of button acquisition method based on bus according to claim 4, is characterized in that, in step S2 when detect have button to press again time, get the hang of 0X3, when detecting that button discharges, return state 0X0.
6. a kind of button acquisition method based on bus according to claim 5, is characterized in that, in step S3 when finding length by timer expired at any time, get the hang of 0X4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410303214.6A CN105302331A (en) | 2014-06-30 | 2014-06-30 | Key acquisition method based on bus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410303214.6A CN105302331A (en) | 2014-06-30 | 2014-06-30 | Key acquisition method based on bus |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105302331A true CN105302331A (en) | 2016-02-03 |
Family
ID=55199683
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410303214.6A Pending CN105302331A (en) | 2014-06-30 | 2014-06-30 | Key acquisition method based on bus |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105302331A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109189242A (en) * | 2018-09-30 | 2019-01-11 | 天津市英贝特航天科技有限公司 | A kind of key board unit and working method based on PS2 agreement |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1896933A (en) * | 2005-07-13 | 2007-01-17 | 英华达(上海)电子有限公司 | Method for operating mouse on touched-panel cell phone |
CN101272139A (en) * | 2008-04-02 | 2008-09-24 | 嘉兴淳祥电子科技有限公司 | Multifunctional touch press key triggered by double-click |
CN101408823A (en) * | 2008-11-18 | 2009-04-15 | 广东威创视讯科技股份有限公司 | Method for judging double clicks of touch screen |
CN101645198A (en) * | 2009-03-27 | 2010-02-10 | 青岛海信电器股份有限公司 | Method and remote controller for identifying keying |
CN101800557A (en) * | 2009-02-10 | 2010-08-11 | 阿尔派株式会社 | Key input device and key input identification method thereof |
CN103092518A (en) * | 2013-01-24 | 2013-05-08 | 福建升腾资讯有限公司 | Moving cloud desktop accurate touch method based on remote desktop protocol (RDP) |
CN103546165A (en) * | 2013-10-15 | 2014-01-29 | 深圳市凌启电子有限公司 | Key sampling method and system and related equipment |
-
2014
- 2014-06-30 CN CN201410303214.6A patent/CN105302331A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1896933A (en) * | 2005-07-13 | 2007-01-17 | 英华达(上海)电子有限公司 | Method for operating mouse on touched-panel cell phone |
CN101272139A (en) * | 2008-04-02 | 2008-09-24 | 嘉兴淳祥电子科技有限公司 | Multifunctional touch press key triggered by double-click |
CN101408823A (en) * | 2008-11-18 | 2009-04-15 | 广东威创视讯科技股份有限公司 | Method for judging double clicks of touch screen |
CN101800557A (en) * | 2009-02-10 | 2010-08-11 | 阿尔派株式会社 | Key input device and key input identification method thereof |
CN101645198A (en) * | 2009-03-27 | 2010-02-10 | 青岛海信电器股份有限公司 | Method and remote controller for identifying keying |
CN103092518A (en) * | 2013-01-24 | 2013-05-08 | 福建升腾资讯有限公司 | Moving cloud desktop accurate touch method based on remote desktop protocol (RDP) |
CN103546165A (en) * | 2013-10-15 | 2014-01-29 | 深圳市凌启电子有限公司 | Key sampling method and system and related equipment |
Non-Patent Citations (1)
Title |
---|
唐飞等: "基于有线状态机的STM32系统按键识别方法", 《长春工业大学学报》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109189242A (en) * | 2018-09-30 | 2019-01-11 | 天津市英贝特航天科技有限公司 | A kind of key board unit and working method based on PS2 agreement |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP2010022015A5 (en) | ||
CN104540091A (en) | Automatic pairing system and automatic pairing method based on bluetooth equipment | |
CN105429814A (en) | Method and device for BFD protection by utilizing multiple board cards | |
CN105392187A (en) | Instant messaging application program management method, device and mobile terminal | |
CN101980171A (en) | Failure self-recovery method for software system and software watchdog system used by same | |
WO2018032869A1 (en) | Method and device for controlling multicast transmission | |
CN102457402A (en) | Method for detecting multiple active equipment conflict and apparatus thereof | |
CN105634502A (en) | Realization method of key scanning based on state machine | |
CN105451077B (en) | A kind of button processing method and system based on module TV | |
CN105302331A (en) | Key acquisition method based on bus | |
CN103607360A (en) | Message processing method, line card and switching equipment | |
CN102880416A (en) | Remote control unlocking method for mobile equipment in remote control protocol (RCP) communication process | |
CN104618152A (en) | Session table aging method and system | |
CN102215145A (en) | Method and device for reporting detection result of link connected state | |
CN101320968B (en) | Self-adapting circuit and its processing method | |
CN104506358A (en) | SNMP (simple network management protocol) based network management system and network management method | |
CN104038355A (en) | Communication device and main/standby switchover method thereof | |
WO2014127690A1 (en) | Method for waking pos machine up using bluetooth | |
CN101692183B (en) | Method and system for warning about losing of handwriting pen of mobile terminal, and mobile terminal | |
US20180063781A1 (en) | Data Packet Processing Method and Related Device | |
CN105472459A (en) | Automatic optimization system and method of intelligent television system | |
CN112612670B (en) | Session information statistical method, device, exchange equipment and storage medium | |
CN103162356A (en) | Indoor air automatic purifying system | |
CN103701837A (en) | PPP (Point-to-point Protocol) on-demand dialing method and home gateway | |
CN203177341U (en) | Indoor air automatic purification system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20160203 |
|
RJ01 | Rejection of invention patent application after publication |