dd

Dependencies:   BufferedSerial FastAnalogIn FastPWM mbed SHT75

Committer:
sbh9428
Date:
Mon Jul 11 01:05:52 2016 +0000
Revision:
10:c751a0e8b7f9
Parent:
0:9bfc4aea91e2
fff;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sbh9428 0:9bfc4aea91e2 1 /*
sbh9428 0:9bfc4aea91e2 2 * peltiert.cpp
sbh9428 0:9bfc4aea91e2 3 *
sbh9428 0:9bfc4aea91e2 4 * Created on: 2016. 2. 19.
sbh9428 0:9bfc4aea91e2 5 * Author: sbh9428
sbh9428 0:9bfc4aea91e2 6 */
sbh9428 0:9bfc4aea91e2 7
sbh9428 0:9bfc4aea91e2 8 #include "peltiert.h"
sbh9428 0:9bfc4aea91e2 9
sbh9428 0:9bfc4aea91e2 10 peltier_t::peltier_t() {
sbh9428 0:9bfc4aea91e2 11 // TODO Auto-generated constructor stub
sbh9428 0:9bfc4aea91e2 12
sbh9428 0:9bfc4aea91e2 13 }
sbh9428 0:9bfc4aea91e2 14
sbh9428 0:9bfc4aea91e2 15 peltier_t::peltier_t(FastPWM* _peltier_pin, DigitalOut* _direction_pin) {
sbh9428 0:9bfc4aea91e2 16 peltier_pin=_peltier_pin;
sbh9428 0:9bfc4aea91e2 17 direction_pin=_direction_pin;
sbh9428 0:9bfc4aea91e2 18
sbh9428 0:9bfc4aea91e2 19 peltier_pin->period_ms(1);
sbh9428 0:9bfc4aea91e2 20 }
sbh9428 0:9bfc4aea91e2 21
sbh9428 0:9bfc4aea91e2 22 peltier_t::~peltier_t() {
sbh9428 0:9bfc4aea91e2 23 // TODO Auto-generated destructor stub
sbh9428 0:9bfc4aea91e2 24 }
sbh9428 0:9bfc4aea91e2 25
sbh9428 0:9bfc4aea91e2 26 void peltier_t::set_PWM(float duty_ratio)
sbh9428 0:9bfc4aea91e2 27 {
sbh9428 0:9bfc4aea91e2 28 if(duty_ratio>0)
sbh9428 10:c751a0e8b7f9 29 *direction_pin=0;
sbh9428 0:9bfc4aea91e2 30 else
sbh9428 10:c751a0e8b7f9 31 *direction_pin=1;
sbh9428 0:9bfc4aea91e2 32 peltier_pin->pulsewidth_us(1000*abs(duty_ratio));
sbh9428 0:9bfc4aea91e2 33 }