a sensor hub for monitoring home environment
Dependencies: HTS221 LIS3MDL LPS22HB LSM303AGR LSM6DSL VL53L0X picojson
Fork of HelloWorld_ST_Sensors by
Diff: main.cpp
- Revision:
- 4:a876fbe13688
- Parent:
- 3:82e8968382d6
- Child:
- 5:2fdca1624a33
--- a/main.cpp Wed Sep 27 15:32:47 2017 +0000 +++ b/main.cpp Mon Oct 02 09:30:24 2017 +0200 @@ -53,14 +53,33 @@ /* Retrieve the composing elements of the expansion board */ #ifdef TARGET_DISCO_L475VG_IOT01A -static DevI2C devI2c = DevI2C(PB_11,PB_10); +static DevI2C devI2c(PB_11,PB_10); #else // X-Nucleo-IKS01A2 +//#define SPI3W_TEST // or SPI4W_TEST +#ifdef SPI3W_TEST +SPI devSPI(PB_15, NC, PB_13); // 3W +#else +#ifdef SPI4W_TEST +SPI devSPI(PB_15, PB_14, PB_13); // 4W +#else static DevI2C devI2c(D14,D15); #endif +#endif +#endif -//static HTS221Sensor hum_temp = HTS221Sensor(&devI2c); +//static DevI2C devI2c(D14,D15); /** FIXME temporary **/ + static HTS221Sensor hum_temp(&devI2c); +#if defined (SPI3W_TEST) || defined (SPI4W_TEST) +#ifdef SPI3W_TEST +#define SPI_TYPE LPS22HBSensor::SPI3W +#else +#define SPI_TYPE LPS22HBSensor::SPI4W +#endif +static LPS22HBSensor press_temp(&devSPI, PA_10, NC, SPI_TYPE); +#else // target Nucleoxxx + IKS01A2 static LPS22HBSensor press_temp(&devI2c); +#endif #ifdef TARGET_DISCO_L475VG_IOT01A static LSM6DSLSensor acc_gyro(&devI2c,LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW,PD_11); // low address @@ -151,11 +170,11 @@ hum_temp.get_temperature(&value1); hum_temp.get_humidity(&value2); - printf("HTS221: [temp] %7s C, [hum] %s%%\r\n", print_double(buffer1, value1), print_double(buffer2, value2)); - + printf("HTS221: [temp] %7f C, [hum] %f%%\r\n", value1, value2); + value1=value2=0; press_temp.get_temperature(&value1); press_temp.get_pressure(&value2); - printf("LPS22HB: [temp] %7s C, [press] %s mbar\r\n", print_double(buffer1, value1), print_double(buffer2, value2)); + printf("LPS22HB: [temp] %7f C, [press] %f mbar\r\n", value1, value2); printf("---\r\n");