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.
pump.h
00001 class Pump { 00002 private: 00003 DigitalOut *io; 00004 DigitalOut *led; 00005 int on_v, off_v; 00006 Timeout timeout; 00007 unsigned char status; 00008 00009 public: 00010 Pump(PinName p, DigitalOut *led, int on_value) { 00011 this->io = new DigitalOut(p); 00012 if(on_value == 1) { 00013 this->on_v = 1; 00014 this->off_v = 0; 00015 } else { 00016 this->on_v = 0; 00017 this->off_v = 1; 00018 } 00019 this->led = led; 00020 this->off(); 00021 } 00022 00023 void set_status(int s) { 00024 this->status = s; 00025 this->led->write(s); 00026 } 00027 00028 void on(float time) { 00029 while(this->status); 00030 this->io->write(this->on_v); 00031 this->set_status(1); 00032 this->timeout.attach(this, &Pump::off, time); 00033 } 00034 00035 void off() { 00036 this->io->write(this->off_v); 00037 this->set_status(0); 00038 } 00039 00040 ~Pump() { 00041 this->off(); 00042 delete io; 00043 } 00044 }; 00045
Generated on Tue Jul 19 2022 15:52:20 by
 1.7.2
 1.7.2