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 @@ -94,6 +94,7 @@
import com.shimmerresearch.sensors.adxl371.SensorADXL371;
import com.shimmerresearch.sensors.lsm6dsv.SensorLSM6DSV;
import com.shimmerresearch.sensors.lis2dw12.SensorLIS2DW12;
import com.shimmerresearch.sensors.soundlevel.SensorSoundLevel;
import com.shimmerresearch.verisense.sensors.SensorLSM6DS3;
//import com.shimmerresearch.verisense.sensors.SensorLIS2DW12;
import com.shimmerresearch.verisense.sensors.SensorBattVoltageVerisense;
Expand Down Expand Up @@ -158,6 +159,8 @@ public static class CHANNEL_UNITS{
public static final String GRAVITY = "g";
public static final String RPM = "rpm";
public static final String POWER = "dB";
/** A-weighted sound pressure level, the Shimmer3R sound level channel's unit (DEV-1413) */
public static final String DECIBELS_A = "dB(A)";
public static final String SCORE = "Score";

public static final String ACCEL_CAL_UNIT = METER_PER_SECOND_SQUARE;
Expand Down Expand Up @@ -735,6 +738,8 @@ public static class SENSOR_ID{
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;
/** Shimmer3R microphone sound level, channel 0x38 (DEV-1413): enabled through configuration byte 233 bit 4, not a sensor bitmap bit */
public static final int SHIMMER_SOUND_LEVEL = 45;

// public static final int SHIMMER_EXG1_24BIT = 3;
// public static final int SHIMMER_EXG2_24BIT = 4;
Expand Down Expand Up @@ -943,7 +948,8 @@ public enum LABEL_SENSOR_TILE{
MPU_OTHER(SensorMPU9X50.LABEL_SENSOR_TILE.MPU_OTHER),
GPS("GPS"),
STC3100_MONITORING (SensorSTC3100.LABEL_SENSOR_TILE.STC3100_MONITORING),
SWEATCH_ADC ("Sweatch ADC");
SWEATCH_ADC ("Sweatch ADC"),
SOUND_LEVEL(SensorSoundLevel.LABEL_SENSOR_TILE.SOUND_LEVEL);

private String tileText = "";
LABEL_SENSOR_TILE(String text){
Expand Down Expand Up @@ -1331,6 +1337,8 @@ public static class CompatibilityInfoForMaps{
private static final ShimmerVerObject svoShimmer3RImuAnyExpBrdLogAndStream = new ShimmerVerObject(HW_ID.SHIMMER_3R,FW_ID.LOGANDSTREAM,0,1,0,ShimmerVerDetails.ANY_VERSION, ShimmerVerDetails.ANY_VERSION, NEW_IMU_EXP_REV.IMU);

public static final ShimmerVerObject svoShimmer3RLogAndStream = new ShimmerVerObject(HW_ID.SHIMMER_3R,FW_ID.LOGANDSTREAM,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION);
/** LogAndStream_Shimmer3R v1.01.026 and later: the first release with the sound level channel (DEV-1413) */
public static final ShimmerVerObject svoShimmer3RLogAndStreamSoundLevel = new ShimmerVerObject(HW_ID.SHIMMER_3R,FW_ID.LOGANDSTREAM,1,1,26,ShimmerVerDetails.ANY_VERSION);
public static final ShimmerVerObject svoShimmer3LogAndStreamWithSDLogSyncSupport = new ShimmerVerObject(HW_ID.SHIMMER_3,FW_ID.LOGANDSTREAM,0,16,11,ShimmerVerDetails.ANY_VERSION);
public static final ShimmerVerObject svoShimmer3RLogAndStreamWithSDLogSyncSupport = new ShimmerVerObject(HW_ID.SHIMMER_3R,FW_ID.LOGANDSTREAM,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION);

Expand Down Expand Up @@ -1538,6 +1546,13 @@ public static class CompatibilityInfoForMaps{
svoShimmer3RBrAmpUnifiedLogAndStream,
svoShimmer3RProto3DeluxeLogAndStream);

//Shimmer3r sound level (DEV-1413), from LogAndStream_Shimmer3R v1.01.026,
//the first release with the channel. Earlier releases store
//configuration byte 233 untouched, so bit 4 would read back set there
//with no channel behind it: the tile is not offered on them.
public static final List<ShimmerVerObject> listOfCompatibleVersionInfoSoundLevel = Arrays.asList(
svoShimmer3RLogAndStreamSoundLevel);

//TODO need to update this list and remove "any"
public static final List<ShimmerVerObject> listOfCompatibleVersionInfoKionixKXRB52042 = Arrays.asList(
svoAnyIntExpBoardAndSdlog, svoAnyIntExpBoardAndBtStream, svoAnyIntExpBoardAndLogAndStream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import com.shimmerresearch.sensors.shimmer2.SensorMMA736x;
import com.shimmerresearch.sensors.shimmer2.SensorShimmer2Gyro;
import com.shimmerresearch.sensors.shimmer2.SensorShimmer2Mag;
import com.shimmerresearch.sensors.soundlevel.SensorSoundLevel;
import com.shimmerresearch.algorithms.orientation.GradDes3DOrientation;
import com.shimmerresearch.algorithms.orientation.GradDes3DOrientation9DoF;
import com.shimmerresearch.algorithms.orientation.Orientation3DObject;
Expand Down Expand Up @@ -2378,6 +2379,23 @@ else if (isEXGUsingDefaultThreeUnipolarConfiguration()){
calibratedDataUnits[sigIndex]=CHANNEL_UNITS.BEATS_PER_MINUTE;
}

// Sound level (DEV-1413, Shimmer3R). Enabled through configuration
// byte 233 bit 4 rather than a sensor bitmap bit, so it is decoded
// whenever the channel list carries it. 0x8000 (no level) is NaN.
int iSoundLevel = getSignalIndex(SensorSoundLevel.ObjectClusterSensorName.SOUND_LEVEL);
if (iSoundLevel!=-1){
double soundLevelRaw = (double)newPacketInt[iSoundLevel];
objectCluster.addDataToMap(SensorSoundLevel.ObjectClusterSensorName.SOUND_LEVEL,CHANNEL_TYPE.UNCAL.toString(),CHANNEL_UNITS.NO_UNITS,soundLevelRaw);
uncalibratedData[iSoundLevel]=soundLevelRaw;
uncalibratedDataUnits[iSoundLevel]=CHANNEL_UNITS.NO_UNITS;
if (mEnableCalibration){
double soundLevelDbA = SensorSoundLevel.calibrateSoundLevel(soundLevelRaw);
objectCluster.addDataToMap(SensorSoundLevel.ObjectClusterSensorName.SOUND_LEVEL,CHANNEL_TYPE.CAL.toString(),CHANNEL_UNITS.DECIBELS_A,soundLevelDbA);
calibratedData[iSoundLevel]=soundLevelDbA;
calibratedDataUnits[iSoundLevel]=CHANNEL_UNITS.DECIBELS_A;
}
}

//Additional Channels Offset
int additionalChannelsOffset = calibratedData.length-numAdditionalChannels;
if(fwType == COMMUNICATION_TYPE.BLUETOOTH) {
Expand Down Expand Up @@ -3631,6 +3649,14 @@ else if ((byte)signalId[i-iTS]==(byte)0x28){
enabledSensors |= SENSOR_BRIDGE_AMP;
}
}
else if ((byte)signalId[i-iTS]==SensorSoundLevel.CHANNEL_ID && getHardwareVersion()==HW_ID.SHIMMER_3R){
// Sound level (DEV-1413): a signed 16-bit little-endian count of
// 0.01 dB(A). A Shimmer3 never sends 0x38 and keeps the unknown
// channel handling below.
signalNameArray[i+1]=SensorSoundLevel.ObjectClusterSensorName.SOUND_LEVEL;
signalDataTypeArray[i+1] = "i16";
packetSize=packetSize+2;
}
else{
signalNameArray[i+1]=Byte.toString(signalId[i-iTS]);
signalDataTypeArray[i+1] = "u12";
Expand Down Expand Up @@ -5605,6 +5631,10 @@ else if(isSupportedNewImuSensors()){

mSensorLIS2MDL = new SensorLIS2MDL(this);
addSensorClass(mSensorLIS2MDL);

// Every Shimmer3R has the microphone; whether its firmware has the
// channel is learnt from configuration byte 233 (DEV-1413)
addSensorClass(new SensorSoundLevel(this));
}
}

Expand Down Expand Up @@ -5858,6 +5888,11 @@ else if(sensorId == Configuration.Shimmer3.SENSOR_ID.HOST_SHIMMER_STREAMING_PROP
mSensorMap.get(sensorId).setIsEnabled(true);
return true;
}
// The sound level (DEV-1413) has no sensor bitmap bit, so the bitmap
// would always turn it off: its state comes from configuration byte 233
else if(sensorId == Configuration.Shimmer3.SENSOR_ID.SHIMMER_SOUND_LEVEL){
return true;
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ public class ConfigByteLayoutShimmer3 extends ConfigByteLayout implements Serial
public int maskLIS2MDLMagRateMSB = 0x07;
public int bitShiftLIS2MDLMagRateMSB = 3;

//Config Byte 233, Shimmer3R only (0 where there is none): the microphone.
//Bits 0-1 are the audio mode and bits 2-3 the gain preset (DEV-99), kept as
//read on a configuration write. Bit 4 turns on the sound level channel,
//0x38 (DEV-1413). The firmware clears bits 5-6, and reads the whole byte
//as 0 when bit 7 is set, as it is in erased flash (0xFF).
public int idxAudioConfig = 0;
public int maskAudioModeAndGain = 0x0F;
public int bitShiftSoundLevel = 4;
public int maskSoundLevel = 0x01;
public int maskAudioConfigInvalid = 0x80;

// Derived Channels - used by SW not FW
public int maskDerivedChannelsByte = 0xFF;
public int byteShiftDerivedSensors0 = 8*0;
Expand Down Expand Up @@ -395,6 +406,12 @@ public ConfigByteLayoutShimmer3(int firmwareIdentifier, int firmwareVersionMajor
maskShowErrorLedsSd = 0x01;
}

// Any Shimmer3R firmware: older builds store the byte untouched, so
// writing back what was read is safe on them too
if(mShimmerVerObject.mHardwareVersion == HW_ID.SHIMMER_3R) {
idxAudioConfig = 128+105;
}

if(mShimmerVerObject.mHardwareVersion == HW_ID.SHIMMER_3R
|| compareVersions(FW_ID.LOGANDSTREAM,0,8,1)) {
idxBtFactoryReset = 128+103;
Expand Down Expand Up @@ -537,6 +554,9 @@ public HashMap<Integer, String> getMapOfByteDescriptions(){
mapOfByteDescriptions.put(idxMaxExpLengthLsb, "idxMaxExpLengthLsb");
mapOfByteDescriptions.put(idxMacAddress, "idxMacAddress");
mapOfByteDescriptions.put(idxSDConfigDelayFlag, "idxSDConfigDelayFlag");
if(idxAudioConfig>0){
mapOfByteDescriptions.put(idxAudioConfig, "idxAudioConfig");
}

if(idxBtFactoryReset>0){
mapOfByteDescriptions.put(idxBtFactoryReset, "idxBtFactoryReset");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public enum SENSORS{
VD6283("VD6283"),
MLX90632("MLX90632"),
BMP390("BMP390"),
BMP581("BMP581");
BMP581("BMP581"),
SOUND_LEVEL("Sound Level");

private final String text;

Expand Down
Loading
Loading