Salinity and temperature sensors are implemented in classes.

Dependencies:   mbed

Committer:
mariosimaremare
Date:
Tue Jun 28 12:30:40 2016 +0000
Revision:
15:e112bab9aa2f
Parent:
14:6c24cab82ff0
Using new boxes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mariosimaremare 0:ad9362f18797 1 #include "Flasher.h"
mariosimaremare 0:ad9362f18797 2 #include "mbed.h"
mariosimaremare 14:6c24cab82ff0 3
mariosimaremare 14:6c24cab82ff0 4 Flasher::Flasher(PinName pin) : _pin(pin)
mariosimaremare 14:6c24cab82ff0 5 {
mariosimaremare 0:ad9362f18797 6 _pin = 0;
mariosimaremare 0:ad9362f18797 7 }
mariosimaremare 14:6c24cab82ff0 8
mariosimaremare 14:6c24cab82ff0 9 void Flasher::flash(int n)
mariosimaremare 14:6c24cab82ff0 10 {
mariosimaremare 0:ad9362f18797 11 for(int i=0; i<n*2; i++) {
mariosimaremare 0:ad9362f18797 12 _pin = !_pin;
mariosimaremare 0:ad9362f18797 13 wait(0.2);
mariosimaremare 0:ad9362f18797 14 }
mariosimaremare 11:dcaaf1bb21ce 15 }
mariosimaremare 11:dcaaf1bb21ce 16
mariosimaremare 14:6c24cab82ff0 17 void Flasher::flash(int n, float delay, float waiting_time)
mariosimaremare 14:6c24cab82ff0 18 {
mariosimaremare 11:dcaaf1bb21ce 19 for(int i=0; i<n*2; i++) {
mariosimaremare 11:dcaaf1bb21ce 20 _pin = !_pin;
mariosimaremare 11:dcaaf1bb21ce 21 wait(delay);
mariosimaremare 11:dcaaf1bb21ce 22 }
mariosimaremare 11:dcaaf1bb21ce 23 wait(waiting_time);
mariosimaremare 11:dcaaf1bb21ce 24 }
mariosimaremare 11:dcaaf1bb21ce 25
mariosimaremare 14:6c24cab82ff0 26 void Flasher::danger_flash()
mariosimaremare 14:6c24cab82ff0 27 {
mariosimaremare 13:142a142a7ac5 28 this->flash(3, 0.3, 3.0);
mariosimaremare 14:6c24cab82ff0 29 }
mariosimaremare 14:6c24cab82ff0 30
mariosimaremare 14:6c24cab82ff0 31 void Flasher::danger_flash_long()
mariosimaremare 14:6c24cab82ff0 32 {
mariosimaremare 14:6c24cab82ff0 33 this->flash(3, 0.3, 10.0);
mariosimaremare 14:6c24cab82ff0 34 }
mariosimaremare 14:6c24cab82ff0 35
mariosimaremare 14:6c24cab82ff0 36 void Flasher::water_flash()
mariosimaremare 14:6c24cab82ff0 37 {
mariosimaremare 14:6c24cab82ff0 38 this->flash(1, 0.2, 3.0);
mariosimaremare 14:6c24cab82ff0 39 }
mariosimaremare 14:6c24cab82ff0 40
mariosimaremare 14:6c24cab82ff0 41 void Flasher::salinity_flash()
mariosimaremare 14:6c24cab82ff0 42 {
mariosimaremare 14:6c24cab82ff0 43 this->flash(2, 0.2, 3.0);
mariosimaremare 0:ad9362f18797 44 }