test
counter.cpp
- Committer:
- kikuchi8810
- Date:
- 2020-03-27
- Revision:
- 0:e6feca04bdcc
File content as of revision 0:e6feca04bdcc:
//最終更新2020年03月16日 #include "counter.h" #include "mbed.h" Counter::Counter(int button){ //スイッチの場合はNULL data = button; pre_recv_data = 0; pre_sw = 1; counts = 0; } void Counter::getCount(int Recv_Data,int con_or_sw){ switch (con_or_sw){ case CON: if((~pre_recv_data & data) &&(Recv_Data & data))counts++; pre_recv_data = Recv_Data; break; case SW: if( pre_sw == 1 && Recv_Data == 0 )counts++; pre_sw = Recv_Data; break; } } void Counter::setCount(int num,int mode){ switch (mode){ case ADD: counts += num; break; case SET: counts = num; break; } } void Counter::resetCount(void){ counts = 0; } int Counter::getCounts(){ return counts; }