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.
GRIDDLE.cpp
00001 #include "mbed.h" 00002 #include "GRIDDLE.h" 00003 00004 GRIDDLE::GRIDDLE(PinName Pwm,PinName Up,PinName Down,PinName Home): 00005 GriddlePWM(Pwm), 00006 GriddleMotorUp(Up,0), 00007 GriddleMotorDown(Down,0), 00008 GriddleHome(Home,PullUp){ 00009 TimerDown=0; 00010 GriddlePWM.write(1); 00011 timer=999999; 00012 }//Constructor 00013 00014 void GRIDDLE::Init(void){ 00015 GriddleMotorUp=GriddleHome.read(); 00016 GriddleMotorDown=0; 00017 while(GriddleHome.read()){wait(0.01);} 00018 GriddleMotorUp=0; 00019 GriddleMotorDown=0; 00020 return; 00021 }//Init 00022 00023 void GRIDDLE::Home(void){ 00024 GriddleMotorUp=GriddleHome.read(); 00025 GriddleMotorDown=0; 00026 while(GriddleHome.read()); 00027 GriddleMotorUp=0; 00028 GriddleMotorDown=0; 00029 return; 00030 }//Home 00031 00032 void GRIDDLE::press(void){ 00033 GriddleMotorDown=1; 00034 GriddleMotorUp=0; 00035 TimerDown=0; 00036 return; 00037 }//press 00038 00039 bool GRIDDLE::isFree(void){ 00040 return (!GriddleHome.read()&&!GriddleMotorDown&&!GriddleMotorUp); 00041 }//isFree 00042 00043 bool GRIDDLE::check(void){ 00044 timer++; 00045 if((GriddleMotorDown==1)&&(GriddleMotorUp==0)){ 00046 if(TimerDown==GRIDDLE_PRESS){ 00047 TimerDown=0; 00048 GriddleMotorDown=0; 00049 GriddleMotorUp=1; 00050 }else 00051 TimerDown++; 00052 }else if((GriddleMotorDown==0)&&(GriddleMotorUp==1)){ 00053 GriddleMotorUp=GriddleHome.read(); 00054 if(!GriddleHome.read()){ 00055 GriddleMotorDown=0; 00056 GriddleMotorUp=0; 00057 }//if 00058 }//else if 00059 return (GriddleMotorDown||GriddleMotorUp); 00060 }//check 00061 00062 void GRIDDLE::setTimer(int t){ 00063 timer=t; 00064 return; 00065 }//setTimer 00066 00067 int GRIDDLE::getTimer(void){ 00068 return timer; 00069 }//getTimer
Generated on Wed Jul 20 2022 02:15:49 by
1.7.2