diff --git a/adxl345/adxl345.go b/adxl345/adxl345.go index 81f1741..f7542f4 100644 --- a/adxl345/adxl345.go +++ b/adxl345/adxl345.go @@ -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" + } +}