11using System ;
22using System . ComponentModel ;
3+ using System . Linq ;
34
45namespace OpenEphys . Onix1
56{
67 /// <summary>
7- /// Configures a Bosch Bno055 9-axis inertial measurement unit (IMU) that is polled by the computer.
8+ /// Configures a Bosch Bno055 9-axis inertial measurement unit (IMU) that is polled by the
9+ /// computer.
810 /// </summary>
911 /// <remarks>
1012 /// This configuration operator can be linked to a data IO operator, such as <see
@@ -37,7 +39,7 @@ public ConfigurePolledBno055(ConfigurePolledBno055 configurePolledBno055)
3739 }
3840
3941 /// <summary>
40- /// Gets or sets the device enable state .
42+ /// Gets or sets a value specifying whether the Bno055 device is enabled .
4143 /// </summary>
4244 /// <remarks>
4345 /// If set to true, <see cref="PolledBno055Data"/> will produce data. If set to false,
@@ -50,14 +52,26 @@ public ConfigurePolledBno055(ConfigurePolledBno055 configurePolledBno055)
5052 /// <summary>
5153 /// Gets or sets the axis map that will be applied during configuration.
5254 /// </summary>
53- [ Browsable ( false ) ]
54- public Bno055AxisMap AxisMap { get ; set ; }
55+ /// <remarks>
56+ /// This value can be changed to compensate for the Bno055's mounting orientation.
57+ /// Specifically, this value can be set to rotate the Bno055's coordinate system compared
58+ /// to the default orientation presented on page 24 of the Bno055 datasheet.
59+ /// </remarks>
60+ [ Category ( ConfigurationCategory ) ]
61+ [ Description ( "Specifies the axis map that will be applied during configuration." ) ]
62+ public Bno055AxisMap AxisMap { get ; set ; } = Bno055AxisMap . XYZ ;
5563
5664 /// <summary>
57- /// Gets or sets the axis map sign that will be applied during configuration
65+ /// Gets or sets the axis sign that will be applied during configuration.
5866 /// </summary>
59- [ Browsable ( false ) ]
60- public Bno055AxisSign AxisSign { get ; set ; }
67+ /// <remarks>
68+ /// This value can be changed to compensate for the Bno055's mounting orientation.
69+ /// Specifically, this value can be set to mirror specific axes in the Bno055's coordinate
70+ /// system compared to the default orientation presented on page 24 of the Bno055 datasheet.
71+ /// </remarks>
72+ [ Category ( ConfigurationCategory ) ]
73+ [ Description ( "Specifies axis sign that will be applied during configuration." ) ]
74+ public Bno055AxisSign AxisSign { get ; set ; } = Bno055AxisSign . Default ;
6175
6276 /// <summary>
6377 /// Configures a PolledBno055 device.
@@ -135,12 +149,14 @@ public PolledBno055DeviceInfo(ContextTask context, Type deviceType, uint deviceA
135149 }
136150
137151 /// <summary>
138- /// Specifies the axis map of a Bno055 IMU
152+ /// Specifies the axis map of a Bno055 compared to the default orientation.
153+ /// the datasheet.
139154 /// </summary>
140155 /// <remarks>
141156 /// The axis of the device can be reconfigured to the new reference axis to account for
142157 /// differences in its mounting position. The following values can be applied to the Bno055's
143- /// AXIS_MAP_CONFIG register at address 0x41.
158+ /// AXIS_MAP_CONFIG register at address 0x41 in order to rotate the Bno055's coordinate system
159+ /// compared to the default orientation presented on page 24 of the Bno055 datasheet.
144160 /// </remarks>
145161 public enum Bno055AxisMap : uint
146162 {
@@ -176,7 +192,8 @@ public enum Bno055AxisMap : uint
176192 /// <remarks>
177193 /// The axis of the device can be reconfigured to the new reference axis to account for
178194 /// differences in its mounting position. The following values can be applied to the Bno055's
179- /// AXIS_MAP_SIGN register at address 0x42.
195+ /// AXIS_MAP_SIGN register at address 0x42 to mirror specific axes in the Bno055's coordinate
196+ /// system compared to the default orientation presented on page 24 of the Bno055 datasheet.
180197 /// </remarks>
181198 [ Flags ]
182199 public enum Bno055AxisSign : uint
@@ -188,27 +205,75 @@ public enum Bno055AxisSign : uint
188205 /// <summary>
189206 /// Specifies that Z axis should be mirrored.
190207 /// </summary>
191- NegZ = 0b00000_001 ,
208+ MirrorZ = 0b00000_001 ,
192209 /// <summary>
193210 /// Specifies that Y axis should be mirrored.
194211 /// </summary>
195- NegY = 0b00000_010 ,
212+ MirrorY = 0b00000_010 ,
196213 /// <summary>
197214 /// Specifies that X axis should be mirrored.
198215 /// </summary>
199- NegX = 0b00000_100 ,
216+ MirrorX = 0b00000_100 ,
217+ }
218+
219+ // NB: Can be used to remove axis map and sign properties from MutliDeviceFactories that include a
220+ // ConfigurePolledBno055 when having those options would cause confusion and potential
221+ // commutator malfunction
222+ internal class PolledBno055SingleDeviceFactoryConverter : SingleDeviceFactoryConverter
223+ {
224+ public override PropertyDescriptorCollection GetProperties ( ITypeDescriptorContext context , object value , Attribute [ ] attributes )
225+ {
226+ var properties = ( from property in base . GetProperties ( context , value , attributes ) . Cast < PropertyDescriptor > ( )
227+ where ! property . IsReadOnly &&
228+ ! ( property . PropertyType == typeof ( Bno055AxisMap ) ) &&
229+ ! ( property . PropertyType == typeof ( Bno055AxisSign ) ) &&
230+ property . ComponentType != typeof ( SingleDeviceFactory )
231+ select property )
232+ . ToArray ( ) ;
233+ return new PropertyDescriptorCollection ( properties ) . Sort ( properties . Select ( p => p . Name ) . ToArray ( ) ) ;
234+ }
200235 }
201236
202237 /// <inheritdoc cref = "ConfigurePolledBno055"/>
203238 [ Obsolete ( "This operator is obsolete. Use ConfigurePolledBno055 instead. Will be removed in version 1.0.0." ) ]
204- public class ConfigureNeuropixelsV1eBno055 : ConfigurePolledBno055 { }
239+ public class ConfigureNeuropixelsV1eBno055 : ConfigurePolledBno055
240+ {
241+ /// <summary>
242+ /// Initializes a new instance of the <see cref="ConfigureNeuropixelsV1eBno055"/> class.
243+ /// </summary>
244+ public ConfigureNeuropixelsV1eBno055 ( )
245+ {
246+ AxisMap = Bno055AxisMap . ZXY ;
247+ AxisSign = Bno055AxisSign . MirrorZ | Bno055AxisSign . MirrorY ;
248+ }
249+ }
205250
206251 /// <inheritdoc cref = "ConfigurePolledBno055"/>
207252 [ Obsolete ( "This operator is obsolete. Use ConfigurePolledBno055 instead. Will be removed in version 1.0.0." ) ]
208- public class ConfigureNeuropixelsV2eBno055 : ConfigurePolledBno055 { }
253+ public class ConfigureNeuropixelsV2eBno055 : ConfigurePolledBno055
254+ {
255+ /// <summary>
256+ /// Initializes a new instance of the <see cref="ConfigureNeuropixelsV2eBno055"/> class.
257+ /// </summary>
258+ public ConfigureNeuropixelsV2eBno055 ( )
259+ {
260+ AxisMap = Bno055AxisMap . ZXY ;
261+ AxisSign = Bno055AxisSign . Default ;
262+ }
263+ }
209264
210265 /// <inheritdoc cref = "ConfigurePolledBno055"/>
211266 [ Obsolete ( "This operator is obsolete. Use ConfigurePolledBno055 instead. Will be removed in version 1.0.0." ) ]
212- public class ConfigureNeuropixelsV2eBetaBno055 : ConfigurePolledBno055 { }
267+ public class ConfigureNeuropixelsV2eBetaBno055 : ConfigurePolledBno055
268+ {
269+ /// <summary>
270+ /// Initializes a new instance of the <see cref="ConfigureNeuropixelsV2eBetaBno055"/> class.
271+ /// </summary>
272+ public ConfigureNeuropixelsV2eBetaBno055 ( )
273+ {
274+ AxisMap = Bno055AxisMap . ZXY ;
275+ AxisSign = Bno055AxisSign . Default ;
276+ }
277+ }
213278}
214279
0 commit comments