TAKT 平林 / SwitchBaseClass
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SwitchBaseClass.cpp Source File

SwitchBaseClass.cpp

00001 #include "SwitchBaseClass.h"
00002 #include "mbed.h"
00003  
00004 SwitchBaseClass::SwitchBaseClass(PinName pin) : _pin(pin) {
00005 }
00006 int SwitchBaseClass::On(void){
00007     if(_pin == 0) {
00008         wait(0.1);
00009         if (_pin == 0){
00010             return 0;
00011         }
00012     }
00013     return 1;
00014 }
00015 
00016 int SwitchBaseClass::Off(void){
00017     if (_pin ==1) {
00018         wait(0.1);
00019         if(_pin == 1){
00020             return 0;
00021         }
00022     }
00023     return 1;
00024 }
00025 
00026 int SwitchBaseClass::On_Off(void){
00027     if(On() == 0){
00028         for(int i = 0; i < 20; i++){
00029             if(Off() ==0){
00030                 return 0;
00031             }
00032         }
00033     }
00034     return 1;
00035 }