@@ -35,7 +35,7 @@ private static void applyDetectorMode(byte[] config, StepDetectorMode mode) {
35
35
}
36
36
}
37
37
internal new static string createIdentifier ( DataTypeBase dataType ) {
38
- switch ( dataType . eventConfig [ 1 ] ) {
38
+ switch ( Util . clearRead ( dataType . eventConfig [ 1 ] ) ) {
39
39
case STEP_DETECTOR_INTERRUPT :
40
40
return "step-detector" ;
41
41
case STEP_COUNTER_DATA :
@@ -79,12 +79,12 @@ internal Bmi160FlatDataProducer(DataTypeBase dataTypeBase, IModuleBoardBridge br
79
79
80
80
}
81
81
82
- public override void Configure ( ushort ? Hold = null , float ? Theta = null ) {
83
- Configure ( ( FlatHoldTime ) Util . closestIndexUShort ( HOLD_TIMES , Hold ?? 640 ) , Theta ) ;
82
+ public override void Configure ( ushort ? hold = null , float ? theta = null ) {
83
+ Configure ( ( FlatHoldTime ) Util . closestIndexUShort ( HOLD_TIMES , hold ?? 640 ) , theta ) ;
84
84
}
85
85
86
- public void Configure ( FlatHoldTime ? Hold = null , float ? Theta = null ) {
87
- Write ( ( byte ) ( Hold ?? FlatHoldTime . _640ms ) , Theta ?? 5.6889f ) ;
86
+ public void Configure ( FlatHoldTime ? hold = null , float ? theta = null ) {
87
+ Write ( ( byte ) ( hold ?? FlatHoldTime . _640ms ) , theta ?? 5.6889f ) ;
88
88
}
89
89
}
90
90
@@ -95,55 +95,57 @@ internal Bmi160MotionDataProducer(DataTypeBase dataTypeBase, IModuleBoardBridge
95
95
base ( dataTypeBase , bridge ) {
96
96
}
97
97
98
- public override void ConfigureAny ( int ? Count = null , float ? Threshold = null ) {
98
+ public override void ConfigureAny ( int ? count = null , float ? threshold = null ) {
99
99
byte [ ] config = InitialMotionConfig ;
100
100
config [ 3 ] &= ( ~ 0x2 ) & 0xff ;
101
101
102
- ConfigureAnyInner ( config , Count , Threshold ) ;
102
+ ConfigureAnyInner ( config , count , threshold ) ;
103
103
}
104
104
105
- public override void ConfigureNo ( int ? Duration = null , float ? Threshold = null ) {
105
+ public override void ConfigureNo ( int ? duration = null , float ? threshold = null ) {
106
106
byte [ ] config = InitialMotionConfig ;
107
107
config [ 3 ] |= 0x1 ;
108
108
109
- if ( Duration . HasValue ) {
109
+ if ( duration . HasValue ) {
110
110
config [ 0 ] &= 0x3 ;
111
111
112
- if ( Duration >= 1280 && Duration <= 20480 ) {
113
- config [ 0 ] |= ( byte ) ( ( ( byte ) ( Duration / 1280f - 1 ) ) << 2 ) ;
114
- } else if ( Duration >= 25600 && Duration <= 102400 ) {
115
- config [ 0 ] |= ( byte ) ( ( ( ( byte ) ( Duration / 5120f - 5 ) ) << 2 ) | 0x40 ) ;
116
- } else if ( Duration >= 112640 && Duration <= 430080 ) {
117
- config [ 0 ] |= ( byte ) ( ( ( ( byte ) ( Duration / 10240f - 11 ) ) << 2 ) | 0x80 ) ;
112
+ if ( duration >= 1280 && duration <= 20480 ) {
113
+ config [ 0 ] |= ( byte ) ( ( ( byte ) ( duration / 1280f - 1 ) ) << 2 ) ;
114
+ } else if ( duration >= 25600 && duration <= 102400 ) {
115
+ config [ 0 ] |= ( byte ) ( ( ( ( byte ) ( duration / 5120f - 5 ) ) << 2 ) | 0x40 ) ;
116
+ } else if ( duration >= 112640 && duration <= 430080 ) {
117
+ config [ 0 ] |= ( byte ) ( ( ( ( byte ) ( duration / 10240f - 11 ) ) << 2 ) | 0x80 ) ;
118
118
}
119
119
}
120
120
121
- if ( Threshold . HasValue ) {
122
- config [ 2 ] = ( byte ) ( Threshold / BOSCH_NO_MOTION_THS_STEPS [ ( accelerometer as AccelerometerBmi160 ) . DataScaleIndex ] ) ;
121
+ if ( threshold . HasValue ) {
122
+ config [ 2 ] = ( byte ) ( threshold / BOSCH_NO_MOTION_THS_STEPS [ ( accelerometer as AccelerometerBmi160 ) . DataScaleIndex ] ) ;
123
123
}
124
124
125
+ mask = 0x38 ;
125
126
bridge . sendCommand ( ACCELEROMETER , MOTION_CONFIG , config ) ;
126
127
}
127
128
128
- public void ConfigureSignificant ( SkipTime ? Skip = null , ProofTime ? Proof = null ) {
129
+ public void ConfigureSignificant ( SkipTime ? skip = null , ProofTime ? proof = null ) {
129
130
byte [ ] config = InitialMotionConfig ;
130
131
config [ 3 ] |= 0x2 ;
131
132
132
- if ( Skip . HasValue ) {
133
- config [ 3 ] |= ( byte ) ( ( int ) Skip << 2 ) ;
133
+ if ( skip . HasValue ) {
134
+ config [ 3 ] |= ( byte ) ( ( int ) skip << 2 ) ;
134
135
}
135
- if ( Proof . HasValue ) {
136
- config [ 3 ] |= ( byte ) ( ( int ) Proof << 4 ) ;
136
+ if ( proof . HasValue ) {
137
+ config [ 3 ] |= ( byte ) ( ( int ) proof << 4 ) ;
137
138
}
138
139
140
+ mask = 0x7 ;
139
141
bridge . sendCommand ( ACCELEROMETER , MOTION_CONFIG , config ) ;
140
142
}
141
143
142
- public override void ConfigureSlow ( byte ? Count = null , float ? Threshold = null ) {
144
+ public override void ConfigureSlow ( byte ? count = null , float ? threshold = null ) {
143
145
byte [ ] config = InitialMotionConfig ;
144
146
config [ 3 ] &= ( ~ 0x1 ) & 0xff ;
145
147
146
- ConfigureSlowInner ( config , Count , Threshold ) ;
148
+ ConfigureSlowInner ( config , count , threshold ) ;
147
149
}
148
150
}
149
151
@@ -172,25 +174,25 @@ public IStepDetectorDataProducer StepDetector {
172
174
return stepDetector ;
173
175
}
174
176
}
175
- IBmi160FlatDataProducer IAccelerometerBmi160 . Flat {
177
+ IBmi160FlatDataProducer IAccelerometerBmi160 . Flat => Flat as IBmi160FlatDataProducer ;
178
+ public override IFlatDataProducer Flat {
176
179
get {
177
180
if ( flatDetector == null ) {
178
181
flatDetector = new Bmi160FlatDataProducer ( flatDataType , bridge ) ;
179
182
}
180
183
return flatDetector ;
181
184
}
182
185
}
183
- public override IFlatDataProducer Flat => Flat ;
184
186
185
- IBmi160MotionDataProducer IAccelerometerBmi160 . Motion {
187
+ IBmi160MotionDataProducer IAccelerometerBmi160 . Motion => Motion as IBmi160MotionDataProducer ;
188
+ public override IMotionDataProducer Motion {
186
189
get {
187
190
if ( motion == null ) {
188
191
motion = new Bmi160MotionDataProducer ( motionDataType , bridge ) ;
189
192
}
190
193
return motion ;
191
194
}
192
195
}
193
- public override IMotionDataProducer Motion => Motion ;
194
196
195
197
protected override float DataScale {
196
198
get {
@@ -251,13 +253,8 @@ protected override void init() {
251
253
response => readConfigTask . SetResult ( response ) ) ;
252
254
}
253
255
254
- public void Configure ( OutputDataRate odr , DataRange range ) {
255
- accDataConfig [ 0 ] &= 0xf0 ;
256
- accDataConfig [ 0 ] |= ( byte ) ( odr + 1 ) ;
257
-
258
- accDataConfig [ 0 ] &= 0xf ;
259
- accDataConfig [ 0 ] |= ( byte ) ( ( FREQUENCIES [ ( int ) odr ] < 12.5f ) ? 0x80 : 0x20 ) ;
260
-
256
+ public void Configure ( OutputDataRate odr = OutputDataRate . _100Hz , DataRange range = DataRange . _2g , FilterMode filter = FilterMode . Normal ) {
257
+ accDataConfig [ 0 ] = ( byte ) ( ( ( int ) odr + 1 ) | ( ( FREQUENCIES [ ( int ) odr ] < 12.5f ) ? 0x80 : ( int ) filter << 4 ) ) ;
261
258
accDataConfig [ 1 ] &= 0xf0 ;
262
259
accDataConfig [ 1 ] |= RANGE_BIT_MASKS [ ( int ) range ] ;
263
260
0 commit comments