Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3341,7 +3341,11 @@ public void readPressureCalibrationCoefficients() {
}
}
} else if (getHardwareVersion() == HW_ID.SHIMMER_3R) {
writeInstruction(GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND);
// BMP581 self-compensates and has no coefficients; its firmware NACKs
// GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND, so don't send it.
if (!isSupportedBmp581()) {
writeInstruction(GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import com.shimmerresearch.sensors.bmpX80.SensorBMP180;
import com.shimmerresearch.sensors.bmpX80.SensorBMP280;
import com.shimmerresearch.sensors.bmpX80.SensorBMP390;
import com.shimmerresearch.sensors.bmpX80.SensorBMP581;
import com.shimmerresearch.sensors.kionix.SensorKionixAccel;
import com.shimmerresearch.sensors.kionix.SensorKionixKXRB52042;
import com.shimmerresearch.sensors.lisxmdl.SensorLIS3MDL;
Expand Down Expand Up @@ -733,6 +734,7 @@ public static class SENSOR_ID{
public static final int SHIMMER_LIS2MDL_MAG = 42;
public static final int SHIMMER_LIS3MDL_MAG_ALT = 41;
public static final int SHIMMER_BMP390_PRESSURE = 43;
public static final int SHIMMER_BMP581_PRESSURE = 44;

// public static final int SHIMMER_EXG1_24BIT = 3;
// public static final int SHIMMER_EXG2_24BIT = 4;
Expand Down Expand Up @@ -924,6 +926,7 @@ public enum LABEL_SENSOR_TILE{
PRESSURE_TEMPERATURE_BMP180(SensorBMP180.LABEL_SENSOR_TILE.PRESSURE_TEMPERATURE),
PRESSURE_TEMPERATURE_BMP280(SensorBMP280.LABEL_SENSOR_TILE.PRESSURE_TEMPERATURE),
PRESSURE_TEMPERATURE_BMP390(SensorBMP390.LABEL_SENSOR_TILE.PRESSURE_TEMPERATURE),
PRESSURE_TEMPERATURE_BMP581(SensorBMP581.LABEL_SENSOR_TILE.PRESSURE_TEMPERATURE),
BATTERY_MONITORING(SensorBattVoltage.LABEL_SENSOR_TILE.BATTERY_MONITORING),
EXTERNAL_EXPANSION_ADC(SensorADC.LABEL_SENSOR_TILE.EXTERNAL_EXPANSION_ADC),
INTERNAL_EXPANSION_ADC(SensorADC.LABEL_SENSOR_TILE.INTERNAL_EXPANSION_ADC),
Expand Down Expand Up @@ -1478,7 +1481,15 @@ public static class CompatibilityInfoForMaps{
svoShimmer3RExgUnifiedLogAndStream,
svoShimmer3RBrAmpUnifiedLogAndStream,
svoShimmer3RProto3DeluxeLogAndStream,
svoShimmer4Stock);
svoShimmer4Stock);

public static final List<ShimmerVerObject> listOfCompatibleVersionInfoBMP581 = Arrays.asList(
svoShimmer3RImuLogAndStream, svoShimmer3RLogAndStream,
svoShimmer3RImuAnyExpBrdLogAndStream,
svoShimmer3RGsrUnifiedLogAndStream,
svoShimmer3RExgUnifiedLogAndStream,
svoShimmer3RBrAmpUnifiedLogAndStream,
svoShimmer3RProto3DeluxeLogAndStream);

public static final List<ShimmerVerObject> listOfCompatibleVersionInfoMPU9250 = Arrays.asList(
svoNewImuSdLog, svoNewImuLogAndStream, svoShimmer3RLogAndStream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import com.shimmerresearch.sensors.bmpX80.SensorBMP180;
import com.shimmerresearch.sensors.bmpX80.SensorBMP280;
import com.shimmerresearch.sensors.bmpX80.SensorBMP390;
import com.shimmerresearch.sensors.bmpX80.SensorBMP581;
import com.shimmerresearch.sensors.bmpX80.SensorBMPX80;
import com.shimmerresearch.sensors.kionix.SensorKionixAccel;
import com.shimmerresearch.sensors.kionix.SensorKionixKXRB52042;
Expand Down Expand Up @@ -1995,8 +1996,13 @@ else if (isEXGUsingDefaultThreeUnipolarConfiguration()){
String signalNameBmpX80Temperature = SensorBMP180.ObjectClusterSensorName.TEMPERATURE_BMP180;
String signalNameBmpX80Pressure = SensorBMP180.ObjectClusterSensorName.PRESSURE_BMP180;
if (getHardwareVersion()==HW_ID.SHIMMER_3R) {
signalNameBmpX80Temperature = SensorBMP390.ObjectClusterSensorName.TEMPERATURE_BMP390;
signalNameBmpX80Pressure = SensorBMP390.ObjectClusterSensorName.PRESSURE_BMP390;
boolean isBmp581 = isSupportedBmp581();
signalNameBmpX80Temperature = isBmp581
? SensorBMP581.ObjectClusterSensorName.TEMPERATURE_BMP581
: SensorBMP390.ObjectClusterSensorName.TEMPERATURE_BMP390;
signalNameBmpX80Pressure = isBmp581
? SensorBMP581.ObjectClusterSensorName.PRESSURE_BMP581
: SensorBMP390.ObjectClusterSensorName.PRESSURE_BMP390;
} else if(isSupportedBmp280()){
signalNameBmpX80Temperature = SensorBMP280.ObjectClusterSensorName.TEMPERATURE_BMP280;
signalNameBmpX80Pressure = SensorBMP280.ObjectClusterSensorName.PRESSURE_BMP280;
Expand Down Expand Up @@ -3449,7 +3455,9 @@ else if ((byte)signalId[i-iTS]==(byte)0x1A){
packetSize=packetSize+2;
enabledSensors |= SENSOR_BMPX80;
}else if (getHardwareVersion()==HW_ID.SHIMMER_3R) {
String signalName = SensorBMP390.ObjectClusterSensorName.TEMPERATURE_BMP390;
String signalName = isSupportedBmp581()
? SensorBMP581.ObjectClusterSensorName.TEMPERATURE_BMP581
: SensorBMP390.ObjectClusterSensorName.TEMPERATURE_BMP390;
signalNameArray[i+1]=signalName;
signalDataTypeArray[i+1] = "u24";
packetSize=packetSize+3;
Expand All @@ -3467,7 +3475,9 @@ else if ((byte)signalId[i-iTS]==(byte)0x1B){
packetSize=packetSize+3;
enabledSensors |= SENSOR_BMPX80;
}else if (getHardwareVersion()==HW_ID.SHIMMER_3R) {
String signalName=SensorBMP390.ObjectClusterSensorName.PRESSURE_BMP390;
String signalName = isSupportedBmp581()
? SensorBMP581.ObjectClusterSensorName.PRESSURE_BMP581
: SensorBMP390.ObjectClusterSensorName.PRESSURE_BMP390;
signalNameArray[i+1]=signalName;
signalDataTypeArray[i+1] = "u24";
packetSize=packetSize+3;
Expand Down Expand Up @@ -5476,7 +5486,11 @@ else if(isSupportedNewImuSensors()){
}

} else if(isShimmerGen3R()){
mSensorBMPX80 = new SensorBMP390(this);
if(isSupportedBmp581()){
mSensorBMPX80 = new SensorBMP581(this);
} else {
mSensorBMPX80 = new SensorBMP390(this);
}
addSensorClass(mSensorBMPX80);

mSensorLSM6DSV = new SensorLSM6DSV(this);
Expand Down Expand Up @@ -10741,6 +10755,46 @@ public static boolean isSupportedBmp280(ShimmerVerObject svo, ExpansionBoardDeta
return isSupportedNewImuSensors(svo, ebd);
}

/** Returns true if this Shimmer3R uses the BMP581 pressure sensor (instead of
* the BMP390). The BMP581 is fitted to up-rev'd Shimmer3R boards; unlike the
* BMP390 it streams pre-compensated pressure/temperature, so no calibration
* coefficients are fetched or applied. Selection is gated on both the board
* SR number/revision and the firmware version that produces the new output
* format.
*
* @return true if the connected Shimmer3R board revision and firmware version indicate BMP581 output support
*/
Comment thread
Copilot marked this conversation as resolved.
public boolean isSupportedBmp581() {
return isSupportedBmp581(getShimmerVerObject(), getExpansionBoardDetails());
}

public static boolean isSupportedBmp581(ShimmerVerObject svo, ExpansionBoardDetails ebd) {
if(svo==null || ebd==null || svo.getHardwareVersion()!=HW_ID.SHIMMER_3R){
return false;
}

// SR48 (GSR+): BMP581 spans two bands - 7.2..7.x AND 8.2 and above.
// 7.0/7.1 and 8.0/8.1 are BMP390, so a single lexicographic ">=" can't
// express it (8.0/8.1 fall between the two BMP581 bands).
boolean sr48Bmp581 =
(ebd.getExpansionBoardId()==HW_ID_SR_CODES.EXP_BRD_GSR_UNIFIED
&& ebd.getExpansionBoardRev()==7
&& ebd.getExpansionBoardRevSpecial()>=2) // SR48 7.2..7.x
|| ebd.isSrNumberGte(HW_ID_SR_CODES.EXP_BRD_GSR_UNIFIED, 8, 2); // SR48 8.2 and above

boolean boardEligible =
ebd.isSrNumberGte(HW_ID_SR_CODES.SHIMMER3, 11, 2) // SR31 >= 11.2
|| ebd.isSrNumberGte(HW_ID_SR_CODES.EXP_BRD_EXG_UNIFIED, 8, 2) // SR47 >= 8.2
|| sr48Bmp581 // SR48 7.2..7.x and 8.2+
|| ebd.isSrNumberGte(HW_ID_SR_CODES.EXP_BRD_BR_AMP_UNIFIED, 4, 2); // SR49 >= 4.2

// Format guard: BMP581 (pre-compensated) output only exists from
// LogAndStream_Shimmer3R v1.01.006 onwards.
boolean fwEligible = svo.compareVersions(FW_ID.LOGANDSTREAM, 1, 1, 6);

return boardEligible && fwEligible;
}

/** Returns true if the Shimmer is using new sensors. These sensors are:
* <li> Use BMP280 instead of BMP180 as barometer.
* <li> Use MPU9250 instead of MPU9150 as IMU.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,29 @@ public int getExpansionBoardRevSpecial() {
return mExpansionBoardRevSpecial;
}

/**
* Lexicographic "&gt;=" comparison over (revision, special revision) for a
* given SR number. The revision is the primary key: e.g. board SR48.8.0 is
* considered &gt;= threshold SR48.7.2 because the revision (8) already exceeds
* the threshold revision (7), regardless of the special-rev values.
* <p>
* NB: a naive {@code rev&gt;=minRev && special&gt;=minSpecial} check is WRONG
* (it would reject SR48.8.0 against threshold SR48.7.2) - keep this
* lexicographic.
*
* @param srNumber the SR number (expansion-board id) to match
* @param minRev minimum board revision
* @param minSpecial minimum special revision (only compared when rev is equal)
* @return true if this board's SR number matches and (rev, special) &gt;= (minRev, minSpecial)
*/
public boolean isSrNumberGte(int srNumber, int minRev, int minSpecial) {
if (mExpansionBoardId != srNumber) {
return false;
}
if (mExpansionBoardRev != minRev) {
return mExpansionBoardRev > minRev;
}
return mExpansionBoardRevSpecial >= minSpecial;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public enum SENSORS{
LSM6DSV("LSM6DSV"),
VD6283("VD6283"),
MLX90632("MLX90632"),
BMP390("BMP390");
BMP390("BMP390"),
BMP581("BMP581");

private final String text;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.shimmerresearch.sensors.bmpX80;

import com.shimmerresearch.driver.calibration.CalibDetails.CALIB_READ_SOURCE;

/**
* BMP581 streams already-compensated values, so there are no per-device trim
* coefficients to parse or store (unlike BMP180/BMP280/BMP390). This CalibDetails
* is therefore a pass-through scaler:
* <li> pressure = raw / 64 -> Pa
* <li> temperature = raw / 65536 -> deg C
* (see BST-BMP581-DS004).
*
* @author Shimmer
*/
public class CalibDetailsBmp581 extends CalibDetailsBmpX80 {

private static final long serialVersionUID = 8046182982777461001L;

public String mSensorMacID;

public CalibDetailsBmp581(String mMacIdFromUart) {
mSensorMacID = mMacIdFromUart;
}

@Override
public double[] calibratePressureSensorData(double UP, double UT) {
double[] caldata = new double[2];
caldata[0] = UP / 64.0; // Pa (downstream /1000 -> kPa, same as BMP390 legacy path)
caldata[1] = UT / 65536.0; // deg C
return caldata;
}

@Override
public byte[] generateCalParamByteArray() {
// No coefficients on BMP581.
return null;
}

@Override
public void parseCalParamByteArray(byte[] bufferCalibrationParameters, CALIB_READ_SOURCE calibReadSource) {
// No-op: BMP581 self-compensates; no coefficient block exists.
}

@Override
public void resetToDefaultParameters() {
// No calibration state to reset.
}

}
Loading
Loading