File tree Expand file tree Collapse file tree 3 files changed +8
-17
lines changed Expand file tree Collapse file tree 3 files changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,8 @@ func main() {
13
13
14
14
mpuDevice := mpu6050 .New (machine .I2C0 , mpu6050 .DefaultAddress )
15
15
16
- err := mpuDevice .Configure (mpu6050.Config {
17
- AccelRange : mpu6050 .ACCEL_RANGE_16 ,
18
- GyroRange : mpu6050 .GYRO_RANGE_2000 ,
19
- })
16
+ // Configure the device with default configuration.
17
+ err := mpuDevice .Configure (mpu6050.Config {})
20
18
if err != nil {
21
19
panic (err .Error ())
22
20
}
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ func (p *Device) setRangeGyro(gyroRange RangeGyro) (err error) {
167
167
p .gRange = 500
168
168
case RangeGyro1000 :
169
169
p .gRange = 1000
170
- case RangeGyro2000 :
170
+ case RangeGyro2000 , rangeGyroDefault :
171
171
p .gRange = 2000
172
172
default :
173
173
return errInvalidRangeGyro
@@ -187,7 +187,7 @@ func (p *Device) setRangeAccel(accRange RangeAccel) (err error) {
187
187
p .aRange = 4
188
188
case RangeAccel8 :
189
189
p .aRange = 8
190
- case RangeAccel16 :
190
+ case RangeAccel16 , rangeGyroDefault :
191
191
p .aRange = 16
192
192
default :
193
193
return errInvalidRangeAccel
@@ -218,12 +218,3 @@ func b2u8(b bool) byte {
218
218
}
219
219
return 0
220
220
}
221
-
222
- func DefaultConfig () Config {
223
- return Config {
224
- AccelRange : RangeAccel16 ,
225
- GyroRange : RangeGyro2000 ,
226
- sampleRatio : 0 , // TODO add const values.
227
- clkSel : 0 ,
228
- }
229
- }
Original file line number Diff line number Diff line change @@ -41,8 +41,9 @@ const (
41
41
42
42
// Gyroscope ranges for Init configuration
43
43
const (
44
+ rangeGyroDefault = iota
44
45
// 250°/s
45
- RangeGyro250 RangeGyro = iota
46
+ RangeGyro250
46
47
// 500°/s
47
48
RangeGyro500
48
49
// 1000°/s
@@ -53,8 +54,9 @@ const (
53
54
54
55
// Accelerometer ranges for Init configuration
55
56
const (
57
+ rangeAccelDefault RangeAccel = iota
56
58
// 2g
57
- RangeAccel2 RangeAccel = iota
59
+ RangeAccel2
58
60
// 4g
59
61
RangeAccel4
60
62
// 8g
You can’t perform that action at this time.
0 commit comments