sampleProgram

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_fuzi by kusano kiyoshige

Committer:
echo_piyo
Date:
Wed Sep 13 02:58:53 2017 +0000
Revision:
51:70d45b959d6b
Parent:
50:e4e1f38d1bd5
Child:
52:f5ae47e683fa
(??)RiseEvent???????varEvent???????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
echo_piyo 51:70d45b959d6b 1 /******************************************************
echo_piyo 51:70d45b959d6b 2 -Class [varEvent]
echo_piyo 51:70d45b959d6b 3
echo_piyo 51:70d45b959d6b 4 The [varEvent] interface is used to trigger an event when input data state changes.
echo_piyo 51:70d45b959d6b 5
echo_piyo 51:70d45b959d6b 6 目的:
echo_piyo 51:70d45b959d6b 7 入力された状態の[立ち上がり],[立ち下がり]を検知する
echo_piyo 51:70d45b959d6b 8 [Rise(0->1)],[Fall(1->0)]
echo_piyo 51:70d45b959d6b 9 Sbdbt用として作成,流用可
echo_piyo 51:70d45b959d6b 10
echo_piyo 51:70d45b959d6b 11 使い方:
echo_piyo 51:70d45b959d6b 12 Public Member Functions:
echo_piyo 51:70d45b959d6b 13
echo_piyo 51:70d45b959d6b 14 varEvent <useName> //宣言
echo_piyo 51:70d45b959d6b 15 .input((int)<inputData>) //(void)検出したい変数(Data)を引数に代入
echo_piyo 51:70d45b959d6b 16 .getRise() //(int)立ち上がり検知 検出時は(int)1,それ以外は(int)0を返す
echo_piyo 51:70d45b959d6b 17 .getFall() //(int)立ち下がり検知 検出時は(int)1,それ以外は(int)0を返す
echo_piyo 51:70d45b959d6b 18
echo_piyo 51:70d45b959d6b 19 ***************************************************************/
echo_piyo 51:70d45b959d6b 20
echo_piyo 50:e4e1f38d1bd5 21 class varEvent {
echo_piyo 50:e4e1f38d1bd5 22 public:
echo_piyo 50:e4e1f38d1bd5 23 void input(int inputState) {
echo_piyo 50:e4e1f38d1bd5 24 valState = ((valState<<1)|inputState)&3;
echo_piyo 50:e4e1f38d1bd5 25 if(valState == 1) {
echo_piyo 50:e4e1f38d1bd5 26 riseState = 1;
echo_piyo 50:e4e1f38d1bd5 27 fallState = 0;
echo_piyo 50:e4e1f38d1bd5 28 } else if(valState == 2){
echo_piyo 50:e4e1f38d1bd5 29 riseState = 0;
echo_piyo 50:e4e1f38d1bd5 30 fallState = 1;
echo_piyo 50:e4e1f38d1bd5 31 } else {
echo_piyo 50:e4e1f38d1bd5 32 riseState = 0;
echo_piyo 50:e4e1f38d1bd5 33 fallState = 0;
echo_piyo 50:e4e1f38d1bd5 34 }
echo_piyo 50:e4e1f38d1bd5 35 }
echo_piyo 50:e4e1f38d1bd5 36
echo_piyo 51:70d45b959d6b 37 int getRise(){
echo_piyo 50:e4e1f38d1bd5 38 return riseState;
echo_piyo 50:e4e1f38d1bd5 39 }
echo_piyo 50:e4e1f38d1bd5 40
echo_piyo 51:70d45b959d6b 41 int getFall(){
echo_piyo 50:e4e1f38d1bd5 42 return fallState;
echo_piyo 50:e4e1f38d1bd5 43 }
echo_piyo 50:e4e1f38d1bd5 44
echo_piyo 50:e4e1f38d1bd5 45 private:
echo_piyo 50:e4e1f38d1bd5 46 int inputState, valState;
echo_piyo 50:e4e1f38d1bd5 47 int riseState, fallState;
echo_piyo 50:e4e1f38d1bd5 48 };