temp service use begin(sensor)
This commit is contained in:
1 file changed
+34
-39
+34
-39
@@ -110,13 +110,6 @@ Adafruit_SHT31 sht30; // Humid
|
||||
//Adafruit_Madgwick filter; // faster than NXP
|
||||
Adafruit_Mahony filter; // fastest/smalleset
|
||||
|
||||
uint16_t measure_temperature(uint8_t* buf, uint16_t bufsize)
|
||||
{
|
||||
float temp = bmp280.readTemperature();
|
||||
memcpy(buf, &temp, 4);
|
||||
return 4;
|
||||
}
|
||||
|
||||
uint16_t measure_light(uint8_t* buf, uint16_t bufsize)
|
||||
{
|
||||
float lux;
|
||||
@@ -130,35 +123,35 @@ uint16_t measure_light(uint8_t* buf, uint16_t bufsize)
|
||||
return 4;
|
||||
}
|
||||
|
||||
uint16_t measure_gyro(uint8_t* buf, uint16_t bufsize)
|
||||
{
|
||||
float* float_buf = (float*) buf;
|
||||
|
||||
sensors_event_t accel, gyro, temp;
|
||||
(void) accel; (void) temp;
|
||||
|
||||
lsm6ds33.getEvent(&accel, &gyro, &temp);
|
||||
|
||||
float_buf[0] = gyro.gyro.x;
|
||||
float_buf[1] = gyro.gyro.y;
|
||||
float_buf[2] = gyro.gyro.z;
|
||||
|
||||
return 12;
|
||||
}
|
||||
|
||||
uint16_t measure_magnetic(uint8_t* buf, uint16_t bufsize)
|
||||
{
|
||||
float* float_buf = (float*) buf;
|
||||
|
||||
sensors_event_t mag;
|
||||
lis3mdl.getEvent(&mag);
|
||||
|
||||
float_buf[0] = mag.magnetic.x;
|
||||
float_buf[1] = mag.magnetic.y;
|
||||
float_buf[2] = mag.magnetic.z;
|
||||
|
||||
return 12;
|
||||
}
|
||||
//uint16_t measure_gyro(uint8_t* buf, uint16_t bufsize)
|
||||
//{
|
||||
// float* float_buf = (float*) buf;
|
||||
//
|
||||
// sensors_event_t accel, gyro, temp;
|
||||
// (void) accel; (void) temp;
|
||||
//
|
||||
// lsm6ds33.getEvent(&accel, &gyro, &temp);
|
||||
//
|
||||
// float_buf[0] = gyro.gyro.x;
|
||||
// float_buf[1] = gyro.gyro.y;
|
||||
// float_buf[2] = gyro.gyro.z;
|
||||
//
|
||||
// return 12;
|
||||
//}
|
||||
//
|
||||
//uint16_t measure_magnetic(uint8_t* buf, uint16_t bufsize)
|
||||
//{
|
||||
// float* float_buf = (float*) buf;
|
||||
//
|
||||
// sensors_event_t mag;
|
||||
// lis3mdl.getEvent(&mag);
|
||||
//
|
||||
// float_buf[0] = mag.magnetic.x;
|
||||
// float_buf[1] = mag.magnetic.y;
|
||||
// float_buf[2] = mag.magnetic.z;
|
||||
//
|
||||
// return 12;
|
||||
//}
|
||||
|
||||
uint16_t measure_button(uint8_t* buf, uint16_t bufsize)
|
||||
{
|
||||
@@ -267,12 +260,14 @@ void setup()
|
||||
blebas.begin();
|
||||
blebas.write(100);
|
||||
|
||||
// Adafruit Service
|
||||
//------------- Adafruit Service -------------//
|
||||
#ifdef ARDUINO_NRF52840_CIRCUITPLAY
|
||||
bleTemp.begin(measure_temperature);
|
||||
#else
|
||||
bleTemp.begin(bmp280.getTemperatureSensor());
|
||||
#endif
|
||||
|
||||
|
||||
bleAccel.begin(accel_sensor);
|
||||
|
||||
bleLight.begin(measure_light);
|
||||
|
||||
bleButton.begin(measure_button, 100);
|
||||
|
||||
Reference in new issue
Block a user