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_fuzi by
varEvent_.h
00001 /****************************************************** 00002 -Class [varEvent] 00003 00004 The [varEvent] is used to trigger an event when input data state changes. 00005 00006 目的: 00007 入力された状態の[立ち上がり],[立ち下がり]を検知する 00008 [Rise(0->1)],[Fall(1->0)] 00009 Sbdbt用として作成,流用可 00010 00011 使い方: 00012 Public Member Functions: 00013 00014 varEvent <useName> //宣言 00015 .input((int)<inputData>) //(void)検出したい変数(Data)を引数に代入 00016 .getRise() //(int)立ち上がり検知 検出時は(int)1,それ以外は(int)0を返す 00017 .getFall() //(int)立ち下がり検知 検出時は(int)1,それ以外は(int)0を返す 00018 00019 ***************************************************************/ 00020 00021 class varEvent { 00022 public: 00023 void input(int inputState) { 00024 valState = ((valState<<1)|inputState)&3; 00025 if(valState == 1) { 00026 riseState = 1; 00027 fallState = 0; 00028 } else if(valState == 2){ 00029 riseState = 0; 00030 fallState = 1; 00031 } else { 00032 riseState = 0; 00033 fallState = 0; 00034 } 00035 } 00036 00037 int getRise(){ 00038 return riseState; 00039 } 00040 00041 int getFall(){ 00042 return fallState; 00043 } 00044 00045 private: 00046 int inputState, valState; 00047 int riseState, fallState; 00048 };
Generated on Mon Aug 8 2022 20:27:09 by
