@@ -35,7 +35,7 @@ private static void applyDetectorMode(byte[] config, StepDetectorMode mode) {
3535 }
3636 }
3737 internal new static string createIdentifier ( DataTypeBase dataType ) {
38- switch ( dataType . eventConfig [ 1 ] ) {
38+ switch ( Util . clearRead ( dataType . eventConfig [ 1 ] ) ) {
3939 case STEP_DETECTOR_INTERRUPT :
4040 return "step-detector" ;
4141 case STEP_COUNTER_DATA :
@@ -79,12 +79,12 @@ internal Bmi160FlatDataProducer(DataTypeBase dataTypeBase, IModuleBoardBridge br
7979
8080 }
8181
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 ) ;
8484 }
8585
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 ) ;
8888 }
8989 }
9090
@@ -95,55 +95,57 @@ internal Bmi160MotionDataProducer(DataTypeBase dataTypeBase, IModuleBoardBridge
9595 base ( dataTypeBase , bridge ) {
9696 }
9797
98- public override void ConfigureAny ( int ? Count = null , float ? Threshold = null ) {
98+ public override void ConfigureAny ( int ? count = null , float ? threshold = null ) {
9999 byte [ ] config = InitialMotionConfig ;
100100 config [ 3 ] &= ( ~ 0x2 ) & 0xff ;
101101
102- ConfigureAnyInner ( config , Count , Threshold ) ;
102+ ConfigureAnyInner ( config , count , threshold ) ;
103103 }
104104
105- public override void ConfigureNo ( int ? Duration = null , float ? Threshold = null ) {
105+ public override void ConfigureNo ( int ? duration = null , float ? threshold = null ) {
106106 byte [ ] config = InitialMotionConfig ;
107107 config [ 3 ] |= 0x1 ;
108108
109- if ( Duration . HasValue ) {
109+ if ( duration . HasValue ) {
110110 config [ 0 ] &= 0x3 ;
111111
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 ) ;
118118 }
119119 }
120120
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 ] ) ;
123123 }
124124
125+ mask = 0x38 ;
125126 bridge . sendCommand ( ACCELEROMETER , MOTION_CONFIG , config ) ;
126127 }
127128
128- public void ConfigureSignificant ( SkipTime ? Skip = null , ProofTime ? Proof = null ) {
129+ public void ConfigureSignificant ( SkipTime ? skip = null , ProofTime ? proof = null ) {
129130 byte [ ] config = InitialMotionConfig ;
130131 config [ 3 ] |= 0x2 ;
131132
132- if ( Skip . HasValue ) {
133- config [ 3 ] |= ( byte ) ( ( int ) Skip << 2 ) ;
133+ if ( skip . HasValue ) {
134+ config [ 3 ] |= ( byte ) ( ( int ) skip << 2 ) ;
134135 }
135- if ( Proof . HasValue ) {
136- config [ 3 ] |= ( byte ) ( ( int ) Proof << 4 ) ;
136+ if ( proof . HasValue ) {
137+ config [ 3 ] |= ( byte ) ( ( int ) proof << 4 ) ;
137138 }
138139
140+ mask = 0x7 ;
139141 bridge . sendCommand ( ACCELEROMETER , MOTION_CONFIG , config ) ;
140142 }
141143
142- public override void ConfigureSlow ( byte ? Count = null , float ? Threshold = null ) {
144+ public override void ConfigureSlow ( byte ? count = null , float ? threshold = null ) {
143145 byte [ ] config = InitialMotionConfig ;
144146 config [ 3 ] &= ( ~ 0x1 ) & 0xff ;
145147
146- ConfigureSlowInner ( config , Count , Threshold ) ;
148+ ConfigureSlowInner ( config , count , threshold ) ;
147149 }
148150 }
149151
@@ -172,25 +174,25 @@ public IStepDetectorDataProducer StepDetector {
172174 return stepDetector ;
173175 }
174176 }
175- IBmi160FlatDataProducer IAccelerometerBmi160 . Flat {
177+ IBmi160FlatDataProducer IAccelerometerBmi160 . Flat => Flat as IBmi160FlatDataProducer ;
178+ public override IFlatDataProducer Flat {
176179 get {
177180 if ( flatDetector == null ) {
178181 flatDetector = new Bmi160FlatDataProducer ( flatDataType , bridge ) ;
179182 }
180183 return flatDetector ;
181184 }
182185 }
183- public override IFlatDataProducer Flat => Flat ;
184186
185- IBmi160MotionDataProducer IAccelerometerBmi160 . Motion {
187+ IBmi160MotionDataProducer IAccelerometerBmi160 . Motion => Motion as IBmi160MotionDataProducer ;
188+ public override IMotionDataProducer Motion {
186189 get {
187190 if ( motion == null ) {
188191 motion = new Bmi160MotionDataProducer ( motionDataType , bridge ) ;
189192 }
190193 return motion ;
191194 }
192195 }
193- public override IMotionDataProducer Motion => Motion ;
194196
195197 protected override float DataScale {
196198 get {
@@ -251,13 +253,8 @@ protected override void init() {
251253 response => readConfigTask . SetResult ( response ) ) ;
252254 }
253255
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 ) ) ;
261258 accDataConfig [ 1 ] &= 0xf0 ;
262259 accDataConfig [ 1 ] |= RANGE_BIT_MASKS [ ( int ) range ] ;
263260
0 commit comments