Skip to content

Commit c6b25d1

Browse files
committed
bugfix + missing "ExG 3-unipolar leads"-functionality from dev branch
1 parent a0965b2 commit c6b25d1

1 file changed

Lines changed: 91 additions & 64 deletions

File tree

ShimmerDriver/src/com/shimmerresearch/sensors/SensorEXG.java

Lines changed: 91 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public class GuiLabelConfig{
156156
public static final String EXG_REFERENCE_ELECTRODE = "Reference Electrode";
157157
public static final String EXG_LEAD_OFF_DETECTION = "Lead-Off Detection";
158158
public static final String EXG_LEAD_OFF_CURRENT = "Lead-Off Current";
159-
public static final String EXG_LEAD_OFF_COMPARATOR = "Lead-Off Compartor Threshold";
159+
public static final String EXG_LEAD_OFF_COMPARATOR = "Lead-Off Comparator Threshold";
160160
public static final String EXG_RESPIRATION_DETECT_FREQ = "Respiration Detection Freq";
161161
public static final String EXG_RESPIRATION_DETECT_PHASE = "Respiration Detection Phase";
162162
}
@@ -233,6 +233,9 @@ public static class DatabaseChannelHandles{
233233
public static final String EXG1_STATUS = "ADS1292R_1_STATUS";
234234
public static final String EXG2_STATUS = "ADS1292R_2_STATUS";
235235

236+
public static final String ECG_LL_LA_16BITS = ObjectClusterSensorName.ECG_LL_LA_16BIT.replace("-", "_");
237+
public static final String ECG_LL_LA_24BITS = ObjectClusterSensorName.ECG_LL_LA_24BIT.replace("-", "_");
238+
236239
public static final String EXT_ADC_A7 = "F5437a_Ext_A7"; //channel
237240
public static final String EXT_ADC_A6 = "F5437a_Ext_A6"; //channel
238241

@@ -1577,6 +1580,8 @@ public void infoMemByteArrayParse(ShimmerDevice shimmerDevice, byte[] infoMemByt
15771580
System.arraycopy(infoMemBytes, idxEXGADS1292RChip2Config1, mEXG2RegisterArray, 0, 10);
15781581
}
15791582
exgBytesGetConfigFrom(mEXG1RegisterArray, mEXG2RegisterArray);
1583+
1584+
handleSpecCasesAfterSensorMapUpdateFromEnabledSensors();
15801585
}
15811586

15821587

@@ -1720,6 +1725,10 @@ public void setDefaultECGConfiguration(double shimmerSamplingRate) {
17201725
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG6.RLD_POS_INPUTS_CH1.RLD_CONNECTED_TO_IN1P);
17211726

17221727
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG10.RLD_REFERENCE_SIGNAL.HALF_OF_SUPPLY);
1728+
1729+
if(isTwoChipClocksConnected()){
1730+
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG2.OSCILLATOR_CLOCK_CONNECTION.ON);
1731+
}
17231732

17241733
setExGRateFromFreq(shimmerSamplingRate);
17251734
exgBytesGetConfigFrom(mEXG1RegisterArray, mEXG2RegisterArray);
@@ -1754,6 +1763,10 @@ protected void setDefaultEMGConfiguration(double shimmerSamplingRate){
17541763
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG6.RLD_BUFFER_POWER.ENABLED);
17551764
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG10.RLD_REFERENCE_SIGNAL.HALF_OF_SUPPLY);
17561765

1766+
if(isTwoChipClocksConnected()){
1767+
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG2.OSCILLATOR_CLOCK_CONNECTION.ON);
1768+
}
1769+
17571770
setExGRateFromFreq(shimmerSamplingRate);
17581771
exgBytesGetConfigFrom(mEXG1RegisterArray, mEXG2RegisterArray);
17591772
}
@@ -1780,6 +1793,10 @@ protected void setEXGTestSignal(double shimmerSamplingRate){
17801793
setExgPropertyBothChips(EXG_SETTING_OPTIONS.REG4.CH1_INPUT_SELECTION.TEST_SIGNAL);
17811794
setExgPropertyBothChips(EXG_SETTING_OPTIONS.REG5.CH2_INPUT_SELECTION.TEST_SIGNAL);
17821795

1796+
if(isTwoChipClocksConnected()){
1797+
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG2.OSCILLATOR_CLOCK_CONNECTION.ON);
1798+
}
1799+
17831800
setExGRateFromFreq(shimmerSamplingRate);
17841801
exgBytesGetConfigFrom(mEXG1RegisterArray, mEXG2RegisterArray);
17851802
}
@@ -1814,6 +1831,10 @@ protected void setDefaultRespirationConfiguration(double shimmerSamplingRate) {
18141831
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP2,EXG_SETTING_OPTIONS.REG9.RESPIRATION_MOD_CIRCUITRY.ON);
18151832
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP2,EXG_SETTING_OPTIONS.REG9.RESPIRATION_PHASE_AT_32KHZ.PHASE_112_5);
18161833

1834+
if(isTwoChipClocksConnected()){
1835+
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG2.OSCILLATOR_CLOCK_CONNECTION.ON);
1836+
}
1837+
18171838
setExGRateFromFreq(shimmerSamplingRate);
18181839
exgBytesGetConfigFrom(mEXG1RegisterArray, mEXG2RegisterArray);
18191840
}
@@ -1858,6 +1879,10 @@ protected void setEXGCustom(double shimmerSamplingRate){
18581879
setExgPropertyBothChips(EXG_SETTING_OPTIONS.REG4.CH1_INPUT_SELECTION.RLDIN_CONNECTED_TO_NEG_INPUT);
18591880
setExgPropertyBothChips(EXG_SETTING_OPTIONS.REG5.CH2_INPUT_SELECTION.RLDIN_CONNECTED_TO_NEG_INPUT);
18601881

1882+
if(isTwoChipClocksConnected()){
1883+
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG2.OSCILLATOR_CLOCK_CONNECTION.ON);
1884+
}
1885+
18611886
setExGRateFromFreq(shimmerSamplingRate);
18621887
exgBytesGetConfigFrom(mEXG1RegisterArray, mEXG2RegisterArray);
18631888
}
@@ -1895,6 +1920,10 @@ public void setExgGq(double shimmerSamplingRate){
18951920

18961921
setExGRateFromFreq(shimmerSamplingRate);
18971922

1923+
if(isTwoChipClocksConnected()){
1924+
setExgPropertySingleChip(EXG_CHIP_INDEX.CHIP1,EXG_SETTING_OPTIONS.REG2.OSCILLATOR_CLOCK_CONNECTION.ON);
1925+
}
1926+
18981927
exgBytesGetConfigFrom(mEXG1RegisterArray, mEXG2RegisterArray);
18991928
}
19001929

@@ -2049,7 +2078,7 @@ private void setExgChannelBitsPerMode(int sensorMapKey){
20492078
chip1Enabled = false;
20502079
chip2Enabled = false;
20512080
}
2052-
else if(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_ECG
2081+
else if((sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_ECG)
20532082
|| (sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_RESPIRATION)
20542083
|| (sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_CUSTOM)
20552084
|| (sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_TEST)
@@ -2061,18 +2090,7 @@ else if(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EMG){
20612090
chip1Enabled = true;
20622091
chip2Enabled = false;
20632092
}
2064-
// else if(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_RESPIRATION){
2065-
// chip1Enabled = true;
2066-
// chip2Enabled = true;
2067-
// }
2068-
// else if(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_CUSTOM){
2069-
// chip1Enabled = true;
2070-
// chip2Enabled = true;
2071-
// }
2072-
// else if(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_TEST){
2073-
// chip1Enabled = true;
2074-
// chip2Enabled = true;
2075-
// }
2093+
20762094

20772095
if(mExGResolution==1){
20782096
mIsExg1_24bitEnabled = chip1Enabled;
@@ -2681,7 +2699,7 @@ public int setExGRateFromFreq(double freq) {
26812699

26822700
private void internalCheckExgModeAndUpdateSensorMap(){
26832701
Map<Integer, SensorDetails> sensorMap = mShimmerDevice.getSensorMap();
2684-
if(sensorMap!=null){
2702+
if(sensorMap!=null && sensorMap.keySet().size()>0){
26852703
if(mShimmerVerObject.isShimmerGenGq()){
26862704
//TODO handle ShimmerGQ
26872705
}
@@ -2746,6 +2764,7 @@ else if(isEXGUsingCustomSignalConfiguration()){
27462764
sensorMap.get(Configuration.Shimmer3.SensorMapKey.HOST_EXG_TEST).setIsEnabled(false);
27472765
sensorMap.get(Configuration.Shimmer3.SensorMapKey.HOST_EXG_CUSTOM).setIsEnabled(false);
27482766
sensorMap.get(Configuration.Shimmer3.SensorMapKey.HOST_EXG_RESPIRATION).setIsEnabled(false);
2767+
sensorMap.get(Configuration.Shimmer3.SensorMapKey.HOST_EXG_THREE_UNIPOLAR).setIsEnabled(false);
27492768
}
27502769
}
27512770
}
@@ -2819,51 +2838,59 @@ else if(isEXGUsingDefaultTestSignalConfiguration()) {
28192838
public Object setConfigValueUsingConfigLabel(Integer sensorMapKey, String configLabel, Object valueToSet) {
28202839
Object returnValue = null;
28212840
switch(configLabel){
2822-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_RESOLUTION):
2823-
setExGResolution((int)valueToSet);
2824-
returnValue = valueToSet;
2825-
break;
2826-
2827-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_GAIN):
2828-
//consolePrintLn("before set " + getExGGain());
2829-
setExGGainSetting((int)valueToSet);
2830-
returnValue = valueToSet;
2831-
//consolePrintLn("after set " + getExGGain());
2832-
break;
2833-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_RATE):
2834-
returnValue = getEXG1RateSetting();
2835-
//returnValue = getEXG2RateSetting();
2836-
break;
2837-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_REFERENCE_ELECTRODE):
2838-
returnValue = getEXGReferenceElectrode();
2839-
break;
2840-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_LEAD_OFF_DETECTION):
2841-
returnValue = getEXGLeadOffCurrentMode();
2842-
break;
2843-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_LEAD_OFF_CURRENT):
2844-
returnValue = getEXGLeadOffDetectionCurrent();
2845-
break;
2846-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_LEAD_OFF_COMPARATOR):
2847-
returnValue = getEXGLeadOffComparatorTreshold();
2848-
break;
2849-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_RESPIRATION_DETECT_FREQ):
2850-
returnValue = getEXG2RespirationDetectFreq();
2851-
break;
2852-
case(Configuration.Shimmer3.GuiLabelConfig.EXG_RESPIRATION_DETECT_PHASE):
2853-
returnValue = getEXG2RespirationDetectPhase();
2854-
break;
2841+
case(GuiLabelConfig.EXG_RESOLUTION):
2842+
setExGResolution((int)valueToSet);
2843+
returnValue = valueToSet;
2844+
break;
2845+
2846+
case(GuiLabelConfig.EXG_GAIN):
2847+
//consolePrintLn("before set " + getExGGain());
2848+
setExGGainSetting((int)valueToSet);
2849+
returnValue = valueToSet;
2850+
//consolePrintLn("after set " + getExGGain());
2851+
break;
2852+
case(GuiLabelConfig.EXG_RATE):
2853+
// setEXG1RateSetting((int)valueToSet);
2854+
// setEXG2RateSetting((int)valueToSet);
2855+
setEXGRateSetting((int)valueToSet);
2856+
returnValue = valueToSet;
2857+
break;
2858+
case(GuiLabelConfig.EXG_REFERENCE_ELECTRODE):
2859+
setEXGReferenceElectrode((int)valueToSet);
2860+
returnValue = valueToSet;
2861+
break;
2862+
case(GuiLabelConfig.EXG_LEAD_OFF_DETECTION):
2863+
setEXGLeadOffCurrentMode((int)valueToSet);
2864+
returnValue = valueToSet;
2865+
break;
2866+
case(GuiLabelConfig.EXG_LEAD_OFF_CURRENT):
2867+
setEXGLeadOffDetectionCurrent((int)valueToSet);
2868+
returnValue = valueToSet;
2869+
break;
2870+
case(GuiLabelConfig.EXG_LEAD_OFF_COMPARATOR):
2871+
setEXGLeadOffComparatorTreshold((int)valueToSet);
2872+
returnValue = valueToSet;
2873+
break;
2874+
case(GuiLabelConfig.EXG_RESPIRATION_DETECT_FREQ):
2875+
setEXG2RespirationDetectFreq((int)valueToSet);
2876+
returnValue = valueToSet;
2877+
break;
2878+
case(GuiLabelConfig.EXG_RESPIRATION_DETECT_PHASE):
2879+
setEXG2RespirationDetectPhase((int)valueToSet);
2880+
returnValue = valueToSet;
2881+
break;
2882+
2883+
default:
2884+
//TODO not needed here - only a ShimmerObject thing or do we want to set properties in AbstractSensor?
2885+
// returnValue = super.setConfigValueUsingConfigLabel(componentName, valueToSet);
2886+
break;
2887+
}
28552888

2856-
default:
2857-
//TODO not needed here - only a ShimmerObject thing or do we want to set properties in AbstractSensor?
2858-
// returnValue = super.setConfigValueUsingConfigLabel(componentName, valueToSet);
2859-
break;
2889+
if((configLabel.equals(Configuration.Shimmer3.GuiLabelConfig.EXG_RESPIRATION_DETECT_PHASE))
2890+
||(configLabel.equals(Configuration.Shimmer3.GuiLabelConfig.EXG_REFERENCE_ELECTRODE))){
2891+
checkConfigOptionValues(configLabel);
28602892
}
2861-
2862-
if((configLabel.equals(Configuration.Shimmer3.GuiLabelConfig.EXG_RESPIRATION_DETECT_PHASE))
2863-
||(configLabel.equals(Configuration.Shimmer3.GuiLabelConfig.EXG_REFERENCE_ELECTRODE))){
2864-
checkConfigOptionValues(configLabel);
2865-
}
2866-
2893+
28672894
return returnValue;
28682895
}
28692896

@@ -3118,12 +3145,12 @@ public void handleSpecCasesBeforeSensorMapUpdateGeneral(ShimmerDevice shimmerDev
31183145

31193146
@Override
31203147
public boolean handleSpecCasesBeforeSensorMapUpdatePerSensor(ShimmerDevice shimmerDevice, Integer sensorMapKey){
3121-
if((sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_ECG)
3122-
||(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EMG)
3123-
||(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_TEST)
3124-
||(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_CUSTOM)
3125-
||(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_RESPIRATION)
3126-
||(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_THREE_UNIPOLAR)) {
3148+
if(sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_ECG
3149+
|| sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EMG
3150+
|| sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_TEST
3151+
|| sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_CUSTOM
3152+
|| sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_RESPIRATION
3153+
|| sensorMapKey==Configuration.Shimmer3.SensorMapKey.HOST_EXG_THREE_UNIPOLAR) {
31273154
mShimmerDevice.getSensorMap().get(sensorMapKey).setIsEnabled(false);
31283155
return true;
31293156
}

0 commit comments

Comments
 (0)