Color sensor reset at the end of calibration added. sensor id auto assignment was changed to be a fixed value assignment to avoid sensor id shift when some sensor is absent.

Dependencies:   UniGraphic mbed vt100

Committer:
Rhyme
Date:
Fri Feb 23 07:51:55 2018 +0000
Revision:
1:8818b793d147
Parent:
0:ce97f6d34336
Wrong behavior when one of color sensor is missing has been fixed.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:ce97f6d34336 1 #ifndef _EDGE_PRESSURE_H_
Rhyme 0:ce97f6d34336 2 #define _EDGE_PRESSURE_H_
Rhyme 0:ce97f6d34336 3 #include "mbed.h"
Rhyme 0:ce97f6d34336 4 #include "edge_sensor.h"
Rhyme 0:ce97f6d34336 5 #include "PSE530.h"
Rhyme 0:ce97f6d34336 6
Rhyme 0:ce97f6d34336 7 /**
Rhyme 0:ce97f6d34336 8 * edge_pressure edge_sensor for measuring gas presssure
Rhyme 0:ce97f6d34336 9 */
Rhyme 0:ce97f6d34336 10
Rhyme 0:ce97f6d34336 11 class edge_pressure : public edge_sensor {
Rhyme 0:ce97f6d34336 12 public:
Rhyme 0:ce97f6d34336 13 /**
Rhyme 0:ce97f6d34336 14 * constructor
Rhyme 0:ce97f6d34336 15 * @param *pse PSE530 pressure sensor object
Rhyme 0:ce97f6d34336 16 */
Rhyme 0:ce97f6d34336 17 edge_pressure(PSE530 *pse, DigitalOut *en) ;
Rhyme 0:ce97f6d34336 18
Rhyme 0:ce97f6d34336 19 /**
Rhyme 0:ce97f6d34336 20 * destructor
Rhyme 0:ce97f6d34336 21 */
Rhyme 0:ce97f6d34336 22 ~edge_pressure(void) ;
Rhyme 0:ce97f6d34336 23
Rhyme 0:ce97f6d34336 24 /**
Rhyme 0:ce97f6d34336 25 * reset and clear internal values
Rhyme 0:ce97f6d34336 26 */
Rhyme 0:ce97f6d34336 27 virtual void reset(void) ;
Rhyme 0:ce97f6d34336 28
Rhyme 0:ce97f6d34336 29 /**
Rhyme 0:ce97f6d34336 30 * prepare for sampling (not used)
Rhyme 0:ce97f6d34336 31 */
Rhyme 0:ce97f6d34336 32 virtual void prepare(void) ;
Rhyme 0:ce97f6d34336 33
Rhyme 0:ce97f6d34336 34 /**
Rhyme 0:ce97f6d34336 35 * sample the value
Rhyme 0:ce97f6d34336 36 * @returns 0: success non-0: failure
Rhyme 0:ce97f6d34336 37 */
Rhyme 0:ce97f6d34336 38 virtual int sample(void) ;
Rhyme 0:ce97f6d34336 39
Rhyme 0:ce97f6d34336 40 /**
Rhyme 0:ce97f6d34336 41 * deliver the sampled value to afero cloud
Rhyme 0:ce97f6d34336 42 */
Rhyme 0:ce97f6d34336 43 virtual int deliver(void) ;
Rhyme 0:ce97f6d34336 44
Rhyme 0:ce97f6d34336 45 /**
Rhyme 0:ce97f6d34336 46 * show the value in the display (TFT)
Rhyme 0:ce97f6d34336 47 */
Rhyme 0:ce97f6d34336 48 virtual void show(void) ;
Rhyme 0:ce97f6d34336 49 // virtual void send_config(void) ; /* send config data to cloud */
Rhyme 0:ce97f6d34336 50 // virtual void recv_config(void) ; /* receive config data from cloud */
Rhyme 0:ce97f6d34336 51
Rhyme 0:ce97f6d34336 52 /**
Rhyme 0:ce97f6d34336 53 * get_value sample sensor value and calcurate it to the metric value
Rhyme 0:ce97f6d34336 54 * @returns measured value in kgf/cm2
Rhyme 0:ce97f6d34336 55 */
Rhyme 0:ce97f6d34336 56 float get_value(void) ;
Rhyme 0:ce97f6d34336 57
Rhyme 0:ce97f6d34336 58 /**
Rhyme 0:ce97f6d34336 59 * Set threshold mode
Rhyme 0:ce97f6d34336 60 * @param mode int 0: absolute value 1: relative value in percent
Rhyme 0:ce97f6d34336 61 */
Rhyme 0:ce97f6d34336 62 void set_thr_mode(int mode) { _thr_mode = mode ; }
Rhyme 0:ce97f6d34336 63
Rhyme 0:ce97f6d34336 64 /**
Rhyme 0:ce97f6d34336 65 * Get threshold mode
Rhyme 0:ce97f6d34336 66 * @returns the mode 0: absolute value 1: relative value in percent
Rhyme 0:ce97f6d34336 67 */
Rhyme 0:ce97f6d34336 68 int get_thr_mode(void) { return _thr_mode ; }
Rhyme 0:ce97f6d34336 69
Rhyme 0:ce97f6d34336 70 /**
Rhyme 0:ce97f6d34336 71 * Set higher threshold
Rhyme 0:ce97f6d34336 72 * @param thr_high int16_t the higher threshold
Rhyme 0:ce97f6d34336 73 */
Rhyme 0:ce97f6d34336 74 void set_thr_high(int16_t thr_high) ;
Rhyme 0:ce97f6d34336 75
Rhyme 0:ce97f6d34336 76 /**
Rhyme 0:ce97f6d34336 77 * Get higher threshold, the value is calcurated with expected value
Rhyme 0:ce97f6d34336 78 * @param expected float the expected pressure value for current temperature
Rhyme 0:ce97f6d34336 79 */
Rhyme 0:ce97f6d34336 80 float get_thr_high(float expected) ;
Rhyme 0:ce97f6d34336 81
Rhyme 0:ce97f6d34336 82 /**
Rhyme 0:ce97f6d34336 83 * Set lower threshold
Rhyme 0:ce97f6d34336 84 * @param thr_low int16_t the lower threshold
Rhyme 0:ce97f6d34336 85 */
Rhyme 0:ce97f6d34336 86 void set_thr_low(int16_t thr_low) ;
Rhyme 0:ce97f6d34336 87
Rhyme 0:ce97f6d34336 88 /**
Rhyme 0:ce97f6d34336 89 * Get lower threshold, the value is calcurated with expected value
Rhyme 0:ce97f6d34336 90 * @param expected float the expected pressure value for current temperature
Rhyme 0:ce97f6d34336 91 */
Rhyme 0:ce97f6d34336 92 float get_thr_low(float expected) ;
Rhyme 0:ce97f6d34336 93
Rhyme 0:ce97f6d34336 94 private:
Rhyme 0:ce97f6d34336 95 PSE530 *_pse ;
Rhyme 0:ce97f6d34336 96 DigitalOut *_en ;
Rhyme 0:ce97f6d34336 97 float _value ;
Rhyme 0:ce97f6d34336 98 float _thr_high ;
Rhyme 0:ce97f6d34336 99 float _thr_low ;
Rhyme 0:ce97f6d34336 100 int _thr_mode ;
Rhyme 0:ce97f6d34336 101 float _expected ;
Rhyme 0:ce97f6d34336 102 float _higher ;
Rhyme 0:ce97f6d34336 103 float _lower ;
Rhyme 0:ce97f6d34336 104 } ;
Rhyme 0:ce97f6d34336 105
Rhyme 0:ce97f6d34336 106 float temp2expected(float temp) ;
Rhyme 0:ce97f6d34336 107 extern float *current_temp ;
Rhyme 0:ce97f6d34336 108
Rhyme 0:ce97f6d34336 109 #endif /* _EDGE_PRESSURE_H_ */