Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo
Fork of 17robo_Practice1 by
varEvent.h
- Committer:
- echo_piyo
- Date:
- 2017-09-13
- Revision:
- 51:70d45b959d6b
- Parent:
- 50:e4e1f38d1bd5
- Child:
- 52:f5ae47e683fa
File content as of revision 51:70d45b959d6b:
/****************************************************** -Class [varEvent] The [varEvent] interface is used to trigger an event when input data state changes. 目的: 入力された状態の[立ち上がり],[立ち下がり]を検知する [Rise(0->1)],[Fall(1->0)] Sbdbt用として作成,流用可 使い方: Public Member Functions: varEvent <useName> //宣言 .input((int)<inputData>) //(void)検出したい変数(Data)を引数に代入 .getRise() //(int)立ち上がり検知 検出時は(int)1,それ以外は(int)0を返す .getFall() //(int)立ち下がり検知 検出時は(int)1,それ以外は(int)0を返す ***************************************************************/ class varEvent { public: void input(int inputState) { valState = ((valState<<1)|inputState)&3; if(valState == 1) { riseState = 1; fallState = 0; } else if(valState == 2){ riseState = 0; fallState = 1; } else { riseState = 0; fallState = 0; } } int getRise(){ return riseState; } int getFall(){ return fallState; } private: int inputState, valState; int riseState, fallState; };