Sensitivity String returns a human readable value

pull/66/head
bpds 2 years ago
parent 9f4770f8c7
commit 75b1480cb3
No known key found for this signature in database
GPG Key ID: B666D5C1144EADD6

@ -85,7 +85,7 @@ type Dev struct {
}
func (d *Dev) String() string {
return fmt.Sprintf("ADXL345{Sensitivity:%d}", d.sensitivity)
return fmt.Sprintf("ADXL345{Sensitivity:%s}", d.sensitivity)
}
// New creates a new ADXL345 Dev or returns an error.
@ -213,3 +213,18 @@ type Acceleration struct {
func (a Acceleration) String() string {
return fmt.Sprintf("X:%d Y:%d Z:%d", a.X, a.Y, a.Z)
}
func (s Sensitivity) String() string {
switch s {
case S2G:
return "+/-2g"
case S4G:
return "+/-4g"
case S8G:
return "+/-8g"
case S16G:
return "+/-16g"
default:
return "unsupported"
}
}

Loading…
Cancel
Save