Complete sensor demo.

Dependencies:   modem_ref_helper X_NUCLEO_IKS01A1 DebouncedInterrupt

Committer:
Jeej
Date:
Thu Oct 11 15:15:30 2018 +0000
Revision:
14:8fd5405f7ab2
Parent:
6:c17f7cbdeb1a
Child:
15:1271f3566b98
Relaxed modem version check.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeej 0:87c57e1b1e1c 1 #include "mbed.h"
Jeej 0:87c57e1b1e1c 2 #include "WizziDebug.h"
Jeej 0:87c57e1b1e1c 3 #include "sensors.h"
Jeej 0:87c57e1b1e1c 4 #include "hwcfg.h"
Jeej 1:4d3968b2941b 5 #include "simul.h"
Jeej 1:4d3968b2941b 6 #include "sensors_cfg.h"
Jeej 0:87c57e1b1e1c 7
Jeej 0:87c57e1b1e1c 8 #if defined(TARGET_STM32L152RE)
Jeej 0:87c57e1b1e1c 9 LIS3MDL *magnetometer;
Jeej 0:87c57e1b1e1c 10 LSM6DS0 *accelerometer;
Jeej 0:87c57e1b1e1c 11 LSM6DS0 *gyroscope;
Jeej 0:87c57e1b1e1c 12 #elif defined(TARGET_STM32L432KC)
Jeej 0:87c57e1b1e1c 13 LSM303C_ACC_Sensor *accelerometer;
Jeej 0:87c57e1b1e1c 14 LSM303C_MAG_Sensor *magnetometer;
Jeej 0:87c57e1b1e1c 15 #if defined(SENSOR_LIGHT_MEAS) && defined(SENSOR_LIGHT_EN)
Jeej 0:87c57e1b1e1c 16 AnalogIn g_light_meas(SENSOR_LIGHT_MEAS);
Jeej 0:87c57e1b1e1c 17 DigitalOut g_light_en_l(SENSOR_LIGHT_EN);
Jeej 0:87c57e1b1e1c 18 #endif
Jeej 0:87c57e1b1e1c 19 #endif
Jeej 0:87c57e1b1e1c 20 LPS25H *pressure_sensor;
Jeej 0:87c57e1b1e1c 21 LPS25H *temp_sensor2;
Jeej 0:87c57e1b1e1c 22 HTS221 *humidity_sensor;
Jeej 0:87c57e1b1e1c 23 HTS221 *temp_sensor1;
Jeej 0:87c57e1b1e1c 24
Jeej 0:87c57e1b1e1c 25
Jeej 0:87c57e1b1e1c 26
Jeej 0:87c57e1b1e1c 27 bool Init_HTS221(HTS221* ht_sensor)
Jeej 0:87c57e1b1e1c 28 {
Jeej 0:87c57e1b1e1c 29 uint8_t ht_id = 0;
Jeej 0:87c57e1b1e1c 30 HUM_TEMP_InitTypeDef InitStructure;
Jeej 0:87c57e1b1e1c 31
Jeej 0:87c57e1b1e1c 32 /* Check presence */
Jeej 0:87c57e1b1e1c 33 if((ht_sensor->ReadID(&ht_id) != HUM_TEMP_OK) ||
Jeej 0:87c57e1b1e1c 34 (ht_id != I_AM_HTS221))
Jeej 0:87c57e1b1e1c 35 {
Jeej 0:87c57e1b1e1c 36 delete ht_sensor;
Jeej 0:87c57e1b1e1c 37 ht_sensor = NULL;
Jeej 0:87c57e1b1e1c 38 return false;
Jeej 0:87c57e1b1e1c 39 }
Jeej 0:87c57e1b1e1c 40
Jeej 0:87c57e1b1e1c 41 /* Configure sensor */
Jeej 0:87c57e1b1e1c 42 InitStructure.OutputDataRate = HTS221_ODR_12_5Hz;
Jeej 0:87c57e1b1e1c 43
Jeej 0:87c57e1b1e1c 44 if(ht_sensor->Init(&InitStructure) != HUM_TEMP_OK)
Jeej 0:87c57e1b1e1c 45 {
Jeej 0:87c57e1b1e1c 46 delete ht_sensor;
Jeej 0:87c57e1b1e1c 47 ht_sensor = NULL;
Jeej 0:87c57e1b1e1c 48 return false;
Jeej 0:87c57e1b1e1c 49 }
Jeej 0:87c57e1b1e1c 50
Jeej 0:87c57e1b1e1c 51 return true;
Jeej 0:87c57e1b1e1c 52 }
Jeej 0:87c57e1b1e1c 53
Jeej 0:87c57e1b1e1c 54 bool Init_LIS3MDL(LIS3MDL* magnetometer)
Jeej 0:87c57e1b1e1c 55 {
Jeej 0:87c57e1b1e1c 56 uint8_t m_id = 0;
Jeej 0:87c57e1b1e1c 57 MAGNETO_InitTypeDef InitStructure;
Jeej 0:87c57e1b1e1c 58
Jeej 0:87c57e1b1e1c 59 /* Check presence */
Jeej 0:87c57e1b1e1c 60 if((magnetometer->ReadID(&m_id) != MAGNETO_OK) ||
Jeej 0:87c57e1b1e1c 61 (m_id != I_AM_LIS3MDL_M))
Jeej 0:87c57e1b1e1c 62 {
Jeej 0:87c57e1b1e1c 63 delete magnetometer;
Jeej 0:87c57e1b1e1c 64 magnetometer = NULL;
Jeej 0:87c57e1b1e1c 65 return false;
Jeej 0:87c57e1b1e1c 66 }
Jeej 0:87c57e1b1e1c 67
Jeej 0:87c57e1b1e1c 68 /* Configure sensor */
Jeej 0:87c57e1b1e1c 69 InitStructure.M_FullScale = LIS3MDL_M_FS_4;
Jeej 0:87c57e1b1e1c 70 InitStructure.M_OperatingMode = LIS3MDL_M_MD_CONTINUOUS;
Jeej 0:87c57e1b1e1c 71 InitStructure.M_XYOperativeMode = LIS3MDL_M_OM_HP;
Jeej 0:87c57e1b1e1c 72 InitStructure.M_OutputDataRate = LIS3MDL_M_DO_80;
Jeej 0:87c57e1b1e1c 73
Jeej 0:87c57e1b1e1c 74 if(magnetometer->Init(&InitStructure) != MAGNETO_OK)
Jeej 0:87c57e1b1e1c 75 {
Jeej 0:87c57e1b1e1c 76 return false;
Jeej 0:87c57e1b1e1c 77 }
Jeej 0:87c57e1b1e1c 78
Jeej 0:87c57e1b1e1c 79 return true;
Jeej 0:87c57e1b1e1c 80 }
Jeej 0:87c57e1b1e1c 81
Jeej 0:87c57e1b1e1c 82 bool Init_LPS25H(LPS25H* pt_sensor)
Jeej 0:87c57e1b1e1c 83 {
Jeej 0:87c57e1b1e1c 84 uint8_t p_id = 0;
Jeej 0:87c57e1b1e1c 85 PRESSURE_InitTypeDef InitStructure;
Jeej 0:87c57e1b1e1c 86
Jeej 0:87c57e1b1e1c 87 /* Check presence */
Jeej 0:87c57e1b1e1c 88 if((pt_sensor->ReadID(&p_id) != PRESSURE_OK) ||
Jeej 0:87c57e1b1e1c 89 (p_id != I_AM_LPS25H))
Jeej 0:87c57e1b1e1c 90 {
Jeej 0:87c57e1b1e1c 91 delete pt_sensor;
Jeej 0:87c57e1b1e1c 92 pt_sensor = NULL;
Jeej 0:87c57e1b1e1c 93 return false;
Jeej 0:87c57e1b1e1c 94 }
Jeej 0:87c57e1b1e1c 95
Jeej 0:87c57e1b1e1c 96 /* Configure sensor */
Jeej 0:87c57e1b1e1c 97 InitStructure.OutputDataRate = LPS25H_ODR_1Hz;
Jeej 0:87c57e1b1e1c 98 InitStructure.BlockDataUpdate = LPS25H_BDU_CONT;
Jeej 0:87c57e1b1e1c 99 InitStructure.DiffEnable = LPS25H_DIFF_DISABLE;
Jeej 0:87c57e1b1e1c 100 InitStructure.SPIMode = LPS25H_SPI_SIM_4W;
Jeej 0:87c57e1b1e1c 101 InitStructure.PressureResolution = LPS25H_P_RES_AVG_8;
Jeej 0:87c57e1b1e1c 102 InitStructure.TemperatureResolution = LPS25H_T_RES_AVG_8;
Jeej 0:87c57e1b1e1c 103
Jeej 0:87c57e1b1e1c 104 if(pt_sensor->Init(&InitStructure) != PRESSURE_OK)
Jeej 0:87c57e1b1e1c 105 {
Jeej 0:87c57e1b1e1c 106 return false;
Jeej 0:87c57e1b1e1c 107 }
Jeej 0:87c57e1b1e1c 108
Jeej 0:87c57e1b1e1c 109 return true;
Jeej 0:87c57e1b1e1c 110 }
Jeej 0:87c57e1b1e1c 111
Jeej 0:87c57e1b1e1c 112 bool Init_LSM6DS0(LSM6DS0* gyro_lsm6ds0)
Jeej 0:87c57e1b1e1c 113 {
Jeej 0:87c57e1b1e1c 114 IMU_6AXES_InitTypeDef InitStructure;
Jeej 0:87c57e1b1e1c 115 uint8_t xg_id = 0;
Jeej 0:87c57e1b1e1c 116
Jeej 0:87c57e1b1e1c 117 /* Check presence */
Jeej 0:87c57e1b1e1c 118 if((gyro_lsm6ds0->ReadID(&xg_id) != IMU_6AXES_OK) ||
Jeej 0:87c57e1b1e1c 119 (xg_id != I_AM_LSM6DS0_XG))
Jeej 0:87c57e1b1e1c 120 {
Jeej 0:87c57e1b1e1c 121 delete gyro_lsm6ds0;
Jeej 0:87c57e1b1e1c 122 gyro_lsm6ds0 = NULL;
Jeej 0:87c57e1b1e1c 123 return false;
Jeej 0:87c57e1b1e1c 124 }
Jeej 0:87c57e1b1e1c 125
Jeej 0:87c57e1b1e1c 126 /* Configure sensor */
Jeej 0:87c57e1b1e1c 127 InitStructure.G_FullScale = 2000.0f; /* 2000DPS */
Jeej 0:87c57e1b1e1c 128 InitStructure.G_OutputDataRate = 119.0f; /* 119HZ */
Jeej 0:87c57e1b1e1c 129 InitStructure.G_X_Axis = 1; /* Enable */
Jeej 0:87c57e1b1e1c 130 InitStructure.G_Y_Axis = 1; /* Enable */
Jeej 0:87c57e1b1e1c 131 InitStructure.G_Z_Axis = 1; /* Enable */
Jeej 0:87c57e1b1e1c 132
Jeej 0:87c57e1b1e1c 133 InitStructure.X_FullScale = 2.0f; /* 2G */
Jeej 0:87c57e1b1e1c 134 InitStructure.X_OutputDataRate = 119.0f; /* 119HZ */
Jeej 0:87c57e1b1e1c 135 InitStructure.X_X_Axis = 1; /* Enable */
Jeej 0:87c57e1b1e1c 136 InitStructure.X_Y_Axis = 1; /* Enable */
Jeej 0:87c57e1b1e1c 137 InitStructure.X_Z_Axis = 1; /* Enable */
Jeej 0:87c57e1b1e1c 138
Jeej 0:87c57e1b1e1c 139 if(gyro_lsm6ds0->Init(&InitStructure) != IMU_6AXES_OK)
Jeej 0:87c57e1b1e1c 140 {
Jeej 2:cbe6dca8a632 141 return false;
Jeej 0:87c57e1b1e1c 142 }
Jeej 0:87c57e1b1e1c 143
Jeej 0:87c57e1b1e1c 144 return true;
Jeej 0:87c57e1b1e1c 145 }
Jeej 0:87c57e1b1e1c 146
Jeej 0:87c57e1b1e1c 147 bool Init_LSM303C_MAG(LSM303C_MAG_Sensor* magnetometer)
Jeej 0:87c57e1b1e1c 148 {
Jeej 0:87c57e1b1e1c 149 uint8_t id = 0;
Jeej 0:87c57e1b1e1c 150 uint8_t error = 0;
Jeej 0:87c57e1b1e1c 151
Jeej 0:87c57e1b1e1c 152 error = magnetometer->ReadID(&id);
Jeej 0:87c57e1b1e1c 153
Jeej 0:87c57e1b1e1c 154 /* Check presence */
Jeej 0:87c57e1b1e1c 155 if(error)
Jeej 0:87c57e1b1e1c 156 {
Jeej 0:87c57e1b1e1c 157 EPRINT("LSM303C_MAG Not detected!\r\n");
Jeej 0:87c57e1b1e1c 158 delete magnetometer;
Jeej 0:87c57e1b1e1c 159 magnetometer = NULL;
Jeej 0:87c57e1b1e1c 160 return false;
Jeej 0:87c57e1b1e1c 161 }
Jeej 0:87c57e1b1e1c 162
Jeej 0:87c57e1b1e1c 163 if (id != I_AM_LSM303C_MAG)
Jeej 0:87c57e1b1e1c 164 {
Jeej 0:87c57e1b1e1c 165 EPRINT("This is not a LSM303C_MAG (0x02X != 0x02X)\r\n", id, I_AM_LSM303C_MAG);
Jeej 0:87c57e1b1e1c 166 delete magnetometer;
Jeej 0:87c57e1b1e1c 167 magnetometer = NULL;
Jeej 0:87c57e1b1e1c 168 return false;
Jeej 0:87c57e1b1e1c 169 }
Jeej 0:87c57e1b1e1c 170
Jeej 0:87c57e1b1e1c 171 if(magnetometer->Init(NULL))
Jeej 0:87c57e1b1e1c 172 {
Jeej 0:87c57e1b1e1c 173 return false;
Jeej 0:87c57e1b1e1c 174 }
Jeej 0:87c57e1b1e1c 175
Jeej 0:87c57e1b1e1c 176 if(magnetometer->Set_M_ODR(1.250))
Jeej 0:87c57e1b1e1c 177 {
Jeej 0:87c57e1b1e1c 178 return false;
Jeej 0:87c57e1b1e1c 179 }
Jeej 0:87c57e1b1e1c 180
Jeej 0:87c57e1b1e1c 181 if(magnetometer->Enable())
Jeej 0:87c57e1b1e1c 182 {
Jeej 0:87c57e1b1e1c 183 return false;
Jeej 0:87c57e1b1e1c 184 }
Jeej 0:87c57e1b1e1c 185
Jeej 0:87c57e1b1e1c 186 return true;
Jeej 0:87c57e1b1e1c 187 }
Jeej 0:87c57e1b1e1c 188
Jeej 0:87c57e1b1e1c 189 bool Init_LSM303C_ACC(LSM303C_ACC_Sensor* accelerometer)
Jeej 0:87c57e1b1e1c 190 {
Jeej 0:87c57e1b1e1c 191 uint8_t id = 0;
Jeej 0:87c57e1b1e1c 192 uint8_t error = 0;
Jeej 0:87c57e1b1e1c 193
Jeej 0:87c57e1b1e1c 194 error = accelerometer->ReadID(&id);
Jeej 0:87c57e1b1e1c 195
Jeej 0:87c57e1b1e1c 196 /* Check presence */
Jeej 0:87c57e1b1e1c 197 if(error)
Jeej 0:87c57e1b1e1c 198 {
Jeej 0:87c57e1b1e1c 199 EPRINT("LSM303C_ACC Not detected!\r\n");
Jeej 0:87c57e1b1e1c 200 delete accelerometer;
Jeej 0:87c57e1b1e1c 201 accelerometer = NULL;
Jeej 0:87c57e1b1e1c 202 return false;
Jeej 0:87c57e1b1e1c 203 }
Jeej 0:87c57e1b1e1c 204
Jeej 0:87c57e1b1e1c 205 if (id != I_AM_LSM303C_ACC)
Jeej 0:87c57e1b1e1c 206 {
Jeej 0:87c57e1b1e1c 207 EPRINT("This is not a LSM303C_ACC (0x02X != 0x02X)\r\n", id, I_AM_LSM303C_ACC);
Jeej 0:87c57e1b1e1c 208 delete accelerometer;
Jeej 0:87c57e1b1e1c 209 accelerometer = NULL;
Jeej 0:87c57e1b1e1c 210 return false;
Jeej 0:87c57e1b1e1c 211 }
Jeej 0:87c57e1b1e1c 212
Jeej 0:87c57e1b1e1c 213 if(accelerometer->Init(NULL))
Jeej 0:87c57e1b1e1c 214 {
Jeej 0:87c57e1b1e1c 215 return false;
Jeej 0:87c57e1b1e1c 216 }
Jeej 0:87c57e1b1e1c 217
Jeej 0:87c57e1b1e1c 218 if(accelerometer->Set_X_ODR(10))
Jeej 0:87c57e1b1e1c 219 {
Jeej 0:87c57e1b1e1c 220 return false;
Jeej 0:87c57e1b1e1c 221 }
Jeej 0:87c57e1b1e1c 222
Jeej 0:87c57e1b1e1c 223 if(accelerometer->Enable())
Jeej 0:87c57e1b1e1c 224 {
Jeej 0:87c57e1b1e1c 225 return false;
Jeej 0:87c57e1b1e1c 226 }
Jeej 0:87c57e1b1e1c 227
Jeej 0:87c57e1b1e1c 228 return true;
Jeej 0:87c57e1b1e1c 229 }
Jeej 0:87c57e1b1e1c 230
Jeej 0:87c57e1b1e1c 231 // Cal method
Jeej 0:87c57e1b1e1c 232 #define CALL_METH(obj, meth, param, ret) ((obj == NULL) ? \
Jeej 0:87c57e1b1e1c 233 ((*(param) = (ret)), 0) : \
Jeej 0:87c57e1b1e1c 234 ((obj)->meth(param)) \
Jeej 0:87c57e1b1e1c 235 )
Jeej 0:87c57e1b1e1c 236
Jeej 0:87c57e1b1e1c 237 __inline int32_t float2_to_int(float v)
Jeej 0:87c57e1b1e1c 238 {
Jeej 0:87c57e1b1e1c 239 return (int32_t)(v*100);
Jeej 0:87c57e1b1e1c 240 }
Jeej 0:87c57e1b1e1c 241
Jeej 0:87c57e1b1e1c 242 bool mag_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 243 {
Jeej 0:87c57e1b1e1c 244 #if (_MAG_EN_ == 0)
Jeej 0:87c57e1b1e1c 245 return simul_sensor_value(buf, 3, -1900, 1900);
Jeej 0:87c57e1b1e1c 246 #elif (_MAG_EN_ == 1)
Jeej 0:87c57e1b1e1c 247 return CALL_METH(magnetometer, Get_M_Axes, buf, 0)? true : false;
Jeej 0:87c57e1b1e1c 248 #else
Jeej 0:87c57e1b1e1c 249 return false;
Jeej 0:87c57e1b1e1c 250 #endif
Jeej 0:87c57e1b1e1c 251 }
Jeej 0:87c57e1b1e1c 252
Jeej 0:87c57e1b1e1c 253 bool acc_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 254 {
Jeej 0:87c57e1b1e1c 255 #if (_ACC_EN_ == 0)
Jeej 0:87c57e1b1e1c 256 return simul_sensor_value(buf, 3, -1900, 1900);
Jeej 0:87c57e1b1e1c 257 #elif (_ACC_EN_ == 1)
Jeej 0:87c57e1b1e1c 258 return CALL_METH(accelerometer, Get_X_Axes, buf, 0)? true : false;
Jeej 0:87c57e1b1e1c 259 #else
Jeej 0:87c57e1b1e1c 260 return false;
Jeej 0:87c57e1b1e1c 261 #endif
Jeej 0:87c57e1b1e1c 262 }
Jeej 0:87c57e1b1e1c 263
Jeej 0:87c57e1b1e1c 264 bool gyr_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 265 {
Jeej 0:87c57e1b1e1c 266 #if (_GYR_EN_ == 0)
Jeej 0:87c57e1b1e1c 267 return simul_sensor_value(buf, 3, -40000, 40000);
Jeej 0:87c57e1b1e1c 268 #elif (_GYR_EN_ == 1)
Jeej 0:87c57e1b1e1c 269 return CALL_METH(gyroscope, Get_G_Axes, buf, 0)? true : false;
Jeej 0:87c57e1b1e1c 270 #else
Jeej 0:87c57e1b1e1c 271 return false;
Jeej 0:87c57e1b1e1c 272 #endif
Jeej 0:87c57e1b1e1c 273 }
Jeej 0:87c57e1b1e1c 274
Jeej 0:87c57e1b1e1c 275 bool pre_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 276 {
Jeej 0:87c57e1b1e1c 277 #if (_PRE_EN_ == 0)
Jeej 0:87c57e1b1e1c 278 return simul_sensor_value(buf, 1, 96000, 104000);
Jeej 0:87c57e1b1e1c 279 #elif (_PRE_EN_ == 1)
Jeej 0:87c57e1b1e1c 280 bool err;
Jeej 0:87c57e1b1e1c 281 float tmp;
Jeej 0:87c57e1b1e1c 282 err = CALL_METH(pressure_sensor, GetPressure, &tmp, 0.0f)? true : false;
Jeej 0:87c57e1b1e1c 283 buf[0] = float2_to_int(tmp);
Jeej 0:87c57e1b1e1c 284 return err;
Jeej 0:87c57e1b1e1c 285 #else
Jeej 0:87c57e1b1e1c 286 return false;
Jeej 0:87c57e1b1e1c 287 #endif
Jeej 0:87c57e1b1e1c 288 }
Jeej 0:87c57e1b1e1c 289
Jeej 0:87c57e1b1e1c 290 bool hum_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 291 {
Jeej 0:87c57e1b1e1c 292 #if (_HUM_EN_ == 0)
Jeej 0:87c57e1b1e1c 293 return simul_sensor_value(buf, 1, 1000, 9000);
Jeej 0:87c57e1b1e1c 294 #elif (_HUM_EN_ == 1)
Jeej 0:87c57e1b1e1c 295 bool err;
Jeej 0:87c57e1b1e1c 296 float tmp;
Jeej 0:87c57e1b1e1c 297 err = CALL_METH(humidity_sensor, GetHumidity, &tmp, 0.0f)? true : false;
Jeej 0:87c57e1b1e1c 298 buf[0] = float2_to_int(tmp);
Jeej 0:87c57e1b1e1c 299 return err;
Jeej 0:87c57e1b1e1c 300 #else
Jeej 0:87c57e1b1e1c 301 return false;
Jeej 0:87c57e1b1e1c 302 #endif
Jeej 0:87c57e1b1e1c 303 }
Jeej 0:87c57e1b1e1c 304
Jeej 0:87c57e1b1e1c 305 bool tem1_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 306 {
Jeej 0:87c57e1b1e1c 307 #if (_TEM1_EN_ == 0)
Jeej 0:87c57e1b1e1c 308 return simul_sensor_value(buf, 1, 1100, 3900);
Jeej 0:87c57e1b1e1c 309 #elif (_TEM1_EN_ == 1)
Jeej 0:87c57e1b1e1c 310 bool err;
Jeej 0:87c57e1b1e1c 311 float tmp;
Jeej 0:87c57e1b1e1c 312 err = CALL_METH(temp_sensor1, GetTemperature, &tmp, 0.0f)? true : false;
Jeej 0:87c57e1b1e1c 313 buf[0] = float2_to_int(tmp);
Jeej 0:87c57e1b1e1c 314 return err;
Jeej 0:87c57e1b1e1c 315 #else
Jeej 0:87c57e1b1e1c 316 return false;
Jeej 0:87c57e1b1e1c 317 #endif
Jeej 0:87c57e1b1e1c 318 }
Jeej 0:87c57e1b1e1c 319
Jeej 0:87c57e1b1e1c 320 bool tem2_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 321 {
Jeej 0:87c57e1b1e1c 322 #if (_TEM2_EN_ == 0)
Jeej 0:87c57e1b1e1c 323 return simul_sensor_value(buf, 1, 5100, 10100);
Jeej 0:87c57e1b1e1c 324 #elif (_TEM2_EN_ == 1)
Jeej 0:87c57e1b1e1c 325 bool err;
Jeej 0:87c57e1b1e1c 326 float tmp;
Jeej 0:87c57e1b1e1c 327 err = CALL_METH(temp_sensor2, GetFahrenheit, &tmp, 0.0f)? true : false;
Jeej 0:87c57e1b1e1c 328 buf[0] = float2_to_int(tmp);
Jeej 0:87c57e1b1e1c 329 return err;
Jeej 0:87c57e1b1e1c 330 #else
Jeej 0:87c57e1b1e1c 331 return false;
Jeej 0:87c57e1b1e1c 332 #endif
Jeej 0:87c57e1b1e1c 333 }
Jeej 0:87c57e1b1e1c 334
Jeej 0:87c57e1b1e1c 335 bool light_get_value(int32_t* buf)
Jeej 0:87c57e1b1e1c 336 {
Jeej 0:87c57e1b1e1c 337 #if (_LIGHT_EN_ == 0)
Jeej 6:c17f7cbdeb1a 338 return simul_sensor_value(buf, 1, 0, 1000);
Jeej 0:87c57e1b1e1c 339 #elif (_LIGHT_EN_ == 1) && defined(SENSOR_LIGHT_MEAS) && defined(SENSOR_LIGHT_EN)
Jeej 0:87c57e1b1e1c 340 float tmp;
Jeej 0:87c57e1b1e1c 341 g_light_en_l = 0;
Jeej 0:87c57e1b1e1c 342 Thread::wait(10);
Jeej 0:87c57e1b1e1c 343 tmp = g_light_meas;
Jeej 0:87c57e1b1e1c 344 g_light_en_l = 1;
Jeej 6:c17f7cbdeb1a 345 buf[0] = (int32_t)(tmp*1000);
Jeej 0:87c57e1b1e1c 346 return false;
Jeej 0:87c57e1b1e1c 347 #else
Jeej 0:87c57e1b1e1c 348 return false;
Jeej 0:87c57e1b1e1c 349 #endif
Jeej 0:87c57e1b1e1c 350 }