Temporary Connector Reversed Version

Dependencies:   UniGraphic mbed vt100

afero_poc15_180403R , J1 のピン配置を反転させたヴァージョンです。

Color2系を使用するためには以下のピンをジャンパで接続してください。
J1-D7 <-> J1-D0
J1-D6 <-> J1-D1

(調査中) また、こちらでテストした範囲では、
FRDM-KL25Z の V3.3 を、Modulo2 の VCC_3V3 ピンに接続してやる必要がありました。

尚、J1-D1, D0 を使用するために UART を無効にしているため
ログは表示されません。

TFTモジュールについて 
aitendoのTFTモジュールはデフォルトでは8bit bus モードになっています。
/media/uploads/Rhyme/img_2364.jpg

半田のジャンパを変えて、SPIの設定にしてください。
/media/uploads/Rhyme/img_2363.jpg

サーミスタについて
POC1.5 では サーミスタは 25℃の時に抵抗値が 50.0kΩになる502AT-11 が
4.95kΩのプルアップ(実際は10kΩx2の並列)で使用されていました。

今回の試作では抵抗値が 10.0kΩの 103AT-11 が
5.1kΩのプルアップで使用されていますので、係数を合わせるために
SMTC502AT-11 のコンストラクタを 
R0 = 10.0
R1 = 5.1
B = 3435
T0 = 298.15
で呼ぶように変更しました。

Committer:
Rhyme
Date:
Tue Apr 24 12:18:10 2018 +0000
Revision:
1:6c54dc8acf96
Parent:
0:0b6732b53bf4
to adjust with 103AT-11 with 5.1k pull-up, the constructor of 502AT-11 is called with R0=10.0, R1=5.1, B=3435, T0=298.15

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:0b6732b53bf4 1 #ifndef _EDGE_COLOR_H_
Rhyme 0:0b6732b53bf4 2 #define _EDGE_COLOR_H_
Rhyme 0:0b6732b53bf4 3 #include "mbed.h"
Rhyme 0:0b6732b53bf4 4 #include "edge_sensor.h"
Rhyme 0:0b6732b53bf4 5 #include "VEML6040.h"
Rhyme 0:0b6732b53bf4 6
Rhyme 0:0b6732b53bf4 7 /**
Rhyme 0:0b6732b53bf4 8 * edge_color edge_sensor which manages LED and color sensor (VEML6040)
Rhyme 0:0b6732b53bf4 9 */
Rhyme 0:0b6732b53bf4 10
Rhyme 0:0b6732b53bf4 11 class edge_color : public edge_sensor {
Rhyme 0:0b6732b53bf4 12 public:
Rhyme 0:0b6732b53bf4 13 /**
Rhyme 0:0b6732b53bf4 14 * constructor
Rhyme 0:0b6732b53bf4 15 * @param *sensor VEML6040 object
Rhyme 0:0b6732b53bf4 16 * @param *led[] PwmOuts for LEDs
Rhyme 0:0b6732b53bf4 17 * @param *pwm[] uint16_t pwm duty values
Rhyme 0:0b6732b53bf4 18 */
Rhyme 0:0b6732b53bf4 19 edge_color(VEML6040 *sensor, PwmOut *led[], uint16_t *pwm) ;
Rhyme 0:0b6732b53bf4 20
Rhyme 0:0b6732b53bf4 21 /**
Rhyme 0:0b6732b53bf4 22 * destructor
Rhyme 0:0b6732b53bf4 23 */
Rhyme 0:0b6732b53bf4 24 ~edge_color(void) ;
Rhyme 0:0b6732b53bf4 25
Rhyme 0:0b6732b53bf4 26 /**
Rhyme 0:0b6732b53bf4 27 * reset and clear internal values
Rhyme 0:0b6732b53bf4 28 */
Rhyme 0:0b6732b53bf4 29 virtual void reset(void) ;
Rhyme 0:0b6732b53bf4 30
Rhyme 0:0b6732b53bf4 31 /**
Rhyme 0:0b6732b53bf4 32 * prepare at first this was planned to set LEDs
Rhyme 0:0b6732b53bf4 33 * before sampling, but turned out to be not neccesarry
Rhyme 0:0b6732b53bf4 34 */
Rhyme 0:0b6732b53bf4 35 virtual void prepare(void) ;
Rhyme 0:0b6732b53bf4 36
Rhyme 0:0b6732b53bf4 37 /**
Rhyme 0:0b6732b53bf4 38 * sample sampling the color value(s) is some what complicated.
Rhyme 0:0b6732b53bf4 39 * At first leds are turned on using the pwm values _pwm[].
Rhyme 0:0b6732b53bf4 40 * then VEML6040 is triggered with config value, which includes
Rhyme 0:0b6732b53bf4 41 * the trigger method and integration time.
Rhyme 0:0b6732b53bf4 42 * Wait for the integration time (actually x 1.25 of the value)
Rhyme 0:0b6732b53bf4 43 * then acquire the color values from VEML6040 and turn the leds off.
Rhyme 0:0b6732b53bf4 44 */
Rhyme 0:0b6732b53bf4 45 virtual int sample(void) ;
Rhyme 0:0b6732b53bf4 46
Rhyme 0:0b6732b53bf4 47 /**
Rhyme 0:0b6732b53bf4 48 * Deliver the sampled value to the afero cloud.
Rhyme 0:0b6732b53bf4 49 */
Rhyme 0:0b6732b53bf4 50 virtual int deliver(void) ;
Rhyme 0:0b6732b53bf4 51
Rhyme 0:0b6732b53bf4 52 /**
Rhyme 0:0b6732b53bf4 53 * Show the value(s) in the display (TFT)
Rhyme 0:0b6732b53bf4 54 */
Rhyme 0:0b6732b53bf4 55 virtual void show(void) ;
Rhyme 0:0b6732b53bf4 56
Rhyme 0:0b6732b53bf4 57 /**
Rhyme 0:0b6732b53bf4 58 * calibrate: caribrate the led pwm values trying to adjust the measured
Rhyme 0:0b6732b53bf4 59 * values to the values given in target[]. Measurements are repeated
Rhyme 0:0b6732b53bf4 60 * num_ave+2 times and the minimum and maximum values will be discarded
Rhyme 0:0b6732b53bf4 61 * then average values are calculated using the remaining values.
Rhyme 0:0b6732b53bf4 62 * @param target[] uint16_t target values for R, G, B measurement
Rhyme 0:0b6732b53bf4 63 * @param result[] uint16_t calibrated pwm R,G,B values
Rhyme 0:0b6732b53bf4 64 * @param num_ave repeat time for averaging the measurement data
Rhyme 0:0b6732b53bf4 65 */
Rhyme 0:0b6732b53bf4 66 void calibrate(uint16_t target[], uint16_t result[], int num_ave) ;
Rhyme 0:0b6732b53bf4 67
Rhyme 0:0b6732b53bf4 68 /**
Rhyme 0:0b6732b53bf4 69 * request_calibration: set the flag to calibrate next avilable time slot
Rhyme 0:0b6732b53bf4 70 */
Rhyme 0:0b6732b53bf4 71 void request_calibration(void) { _calibration_request = 1 ; }
Rhyme 0:0b6732b53bf4 72
Rhyme 0:0b6732b53bf4 73 /**
Rhyme 0:0b6732b53bf4 74 * calibration_requested
Rhyme 0:0b6732b53bf4 75 * @returns if the calibration is due
Rhyme 0:0b6732b53bf4 76 */
Rhyme 0:0b6732b53bf4 77 int calibration_requested(void) { return _calibration_request ; }
Rhyme 0:0b6732b53bf4 78
Rhyme 0:0b6732b53bf4 79 /**
Rhyme 0:0b6732b53bf4 80 * getAveColor
Rhyme 0:0b6732b53bf4 81 * @param led[] uint16_t pwm values for R,G,B
Rhyme 0:0b6732b53bf4 82 * @param v[] uint16_t averaged measurement value
Rhyme 0:0b6732b53bf4 83 * @param num_ave int measurment repeat time for averaging
Rhyme 0:0b6732b53bf4 84 */
Rhyme 0:0b6732b53bf4 85 void getAveColor(uint16_t led[], uint16_t v[], int num_ave) ;
Rhyme 0:0b6732b53bf4 86
Rhyme 0:0b6732b53bf4 87 /**
Rhyme 0:0b6732b53bf4 88 * getRGB
Rhyme 0:0b6732b53bf4 89 * @param v[] uint16_t measured R,G,B values
Rhyme 0:0b6732b53bf4 90 * @returns 0: success non-0: failure
Rhyme 0:0b6732b53bf4 91 */
Rhyme 0:0b6732b53bf4 92 int getRGB(uint16_t v[]) ;
Rhyme 0:0b6732b53bf4 93
Rhyme 0:0b6732b53bf4 94 /**
Rhyme 0:0b6732b53bf4 95 * getConfig
Rhyme 0:0b6732b53bf4 96 * @returns config this value is used to trigger VEML6040 measurement
Rhyme 0:0b6732b53bf4 97 */
Rhyme 0:0b6732b53bf4 98 uint8_t getConfig(void) { return _sensor_config ; }
Rhyme 0:0b6732b53bf4 99
Rhyme 0:0b6732b53bf4 100 /**
Rhyme 0:0b6732b53bf4 101 * setConfig
Rhyme 0:0b6732b53bf4 102 * @param config uint8_t 8bit value to use trigger VEML6040 measurement
Rhyme 0:0b6732b53bf4 103 */
Rhyme 0:0b6732b53bf4 104 void setConfig(uint8_t config) { _sensor_config = config ; }
Rhyme 0:0b6732b53bf4 105
Rhyme 0:0b6732b53bf4 106 /**
Rhyme 0:0b6732b53bf4 107 * get_pwm_period
Rhyme 0:0b6732b53bf4 108 * @returns pwm_period in us
Rhyme 0:0b6732b53bf4 109 */
Rhyme 0:0b6732b53bf4 110 uint16_t get_pwm_period(void) { return _pwm_period ; }
Rhyme 0:0b6732b53bf4 111
Rhyme 0:0b6732b53bf4 112 /**
Rhyme 0:0b6732b53bf4 113 * set_pwm_period
Rhyme 0:0b6732b53bf4 114 * @param pwm_period uint16_t pwm period in us
Rhyme 0:0b6732b53bf4 115 */
Rhyme 0:0b6732b53bf4 116 void set_pwm_period(uint16_t period) { _pwm_period = period ; }
Rhyme 0:0b6732b53bf4 117
Rhyme 0:0b6732b53bf4 118 /**
Rhyme 0:0b6732b53bf4 119 * get_pwm_target
Rhyme 0:0b6732b53bf4 120 * @returns measurment target value controlled by the pwm
Rhyme 0:0b6732b53bf4 121 */
Rhyme 0:0b6732b53bf4 122 uint16_t get_pwm_target(void) { return _pwm_target ; }
Rhyme 0:0b6732b53bf4 123
Rhyme 0:0b6732b53bf4 124 /**
Rhyme 0:0b6732b53bf4 125 * set_pwm_target
Rhyme 0:0b6732b53bf4 126 * @param target uint16_t measurement target value
Rhyme 0:0b6732b53bf4 127 */
Rhyme 0:0b6732b53bf4 128 void set_pwm_target(uint16_t target) { _pwm_target = target ; }
Rhyme 0:0b6732b53bf4 129
Rhyme 0:0b6732b53bf4 130 /**
Rhyme 0:0b6732b53bf4 131 * getR
Rhyme 0:0b6732b53bf4 132 * @returns measured value of R
Rhyme 0:0b6732b53bf4 133 */
Rhyme 0:0b6732b53bf4 134 uint16_t getR(void) { return _value[0] ; }
Rhyme 0:0b6732b53bf4 135
Rhyme 0:0b6732b53bf4 136 /**
Rhyme 0:0b6732b53bf4 137 * getG
Rhyme 0:0b6732b53bf4 138 * @returns measured value of G
Rhyme 0:0b6732b53bf4 139 */
Rhyme 0:0b6732b53bf4 140 uint16_t getG(void) { return _value[1] ; }
Rhyme 0:0b6732b53bf4 141
Rhyme 0:0b6732b53bf4 142 /**
Rhyme 0:0b6732b53bf4 143 * getB
Rhyme 0:0b6732b53bf4 144 * @returns measured value of B
Rhyme 0:0b6732b53bf4 145 */
Rhyme 0:0b6732b53bf4 146 uint16_t getB(void) { return _value[2] ; }
Rhyme 0:0b6732b53bf4 147
Rhyme 0:0b6732b53bf4 148 /**
Rhyme 0:0b6732b53bf4 149 * getPwmR
Rhyme 0:0b6732b53bf4 150 * @returns PWM value of R LED
Rhyme 0:0b6732b53bf4 151 */
Rhyme 0:0b6732b53bf4 152 uint16_t getPwmR(void) { return _pwm[0] ; }
Rhyme 0:0b6732b53bf4 153
Rhyme 0:0b6732b53bf4 154 /**
Rhyme 0:0b6732b53bf4 155 * setPwmR
Rhyme 0:0b6732b53bf4 156 * @param pwm_r
Rhyme 0:0b6732b53bf4 157 */
Rhyme 0:0b6732b53bf4 158 void setPwmR(uint16_t pwm_r) { _pwm[0] = pwm_r ; }
Rhyme 0:0b6732b53bf4 159
Rhyme 0:0b6732b53bf4 160 /**
Rhyme 0:0b6732b53bf4 161 * getPwmG
Rhyme 0:0b6732b53bf4 162 * @returns PWM value of G LED
Rhyme 0:0b6732b53bf4 163 */
Rhyme 0:0b6732b53bf4 164 uint16_t getPwmG(void) { return _pwm[1] ; }
Rhyme 0:0b6732b53bf4 165
Rhyme 0:0b6732b53bf4 166 /**
Rhyme 0:0b6732b53bf4 167 * setPwmG
Rhyme 0:0b6732b53bf4 168 * @param pwm_g
Rhyme 0:0b6732b53bf4 169 */
Rhyme 0:0b6732b53bf4 170 void setPwmG(uint16_t pwm_g) { _pwm[1] = pwm_g ; }
Rhyme 0:0b6732b53bf4 171
Rhyme 0:0b6732b53bf4 172 /**
Rhyme 0:0b6732b53bf4 173 * getPwmB
Rhyme 0:0b6732b53bf4 174 * @returns PWM value of B LED
Rhyme 0:0b6732b53bf4 175 */
Rhyme 0:0b6732b53bf4 176 uint16_t getPwmB(void) { return _pwm[2] ; }
Rhyme 0:0b6732b53bf4 177
Rhyme 0:0b6732b53bf4 178 /**
Rhyme 0:0b6732b53bf4 179 * setPwmB
Rhyme 0:0b6732b53bf4 180 * @param pwm_b
Rhyme 0:0b6732b53bf4 181 */
Rhyme 0:0b6732b53bf4 182 void setPwmB(uint16_t pwm_b) { _pwm[2] = pwm_b ; }
Rhyme 0:0b6732b53bf4 183
Rhyme 0:0b6732b53bf4 184 /**
Rhyme 0:0b6732b53bf4 185 * setLEDs set pwm values to PwmOut pins to drive LEDS
Rhyme 0:0b6732b53bf4 186 * @param led_value[] uint16_t pwm values for R, G, B
Rhyme 0:0b6732b53bf4 187 */
Rhyme 0:0b6732b53bf4 188 void setLEDs(uint16_t led_value[]) ;
Rhyme 0:0b6732b53bf4 189
Rhyme 0:0b6732b53bf4 190 /**
Rhyme 0:0b6732b53bf4 191 * setLEDs set pwm values to PwmOut pins to drive LEDS
Rhyme 0:0b6732b53bf4 192 * @param r uint16_t pwm value of R LED
Rhyme 0:0b6732b53bf4 193 * @param g uint16_t pwm value of G LED
Rhyme 0:0b6732b53bf4 194 * @param b uint16_t pwm value of B LED
Rhyme 0:0b6732b53bf4 195 */
Rhyme 0:0b6732b53bf4 196 void setLEDs(uint16_t r, uint16_t g, uint16_t b) ;
Rhyme 0:0b6732b53bf4 197
Rhyme 0:0b6732b53bf4 198 protected:
Rhyme 0:0b6732b53bf4 199 VEML6040 *_sensor ;
Rhyme 0:0b6732b53bf4 200 uint8_t _sensor_config ;
Rhyme 0:0b6732b53bf4 201 PwmOut *_led[3] ;
Rhyme 0:0b6732b53bf4 202 uint16_t _pwm_period ;
Rhyme 0:0b6732b53bf4 203 uint16_t _pwm_target ;
Rhyme 0:0b6732b53bf4 204 uint16_t _value[3] ; /* r, g, b */
Rhyme 0:0b6732b53bf4 205 uint16_t _pwm[3] ; /* r, g, b */
Rhyme 0:0b6732b53bf4 206 uint16_t _probe ; /* probing value for calibration */
Rhyme 0:0b6732b53bf4 207 uint8_t _calibration_request ;
Rhyme 0:0b6732b53bf4 208 } ;
Rhyme 0:0b6732b53bf4 209
Rhyme 0:0b6732b53bf4 210 extern uint16_t color0_pwm[3] ;
Rhyme 0:0b6732b53bf4 211 extern uint16_t color1_pwm[3] ;
Rhyme 0:0b6732b53bf4 212 extern uint16_t color0_target[3] ;
Rhyme 0:0b6732b53bf4 213 extern uint16_t color1_target[3] ;
Rhyme 0:0b6732b53bf4 214
Rhyme 0:0b6732b53bf4 215 #endif /* _EDGE_COLOR_H_ */