diff --git a/devices/geiger/gqgmc.go b/devices/geiger/gqgmc.go index aca8f425b27863fd78f2a64d991f1ff220c1be37..1058bdaf82232773b9fc18c2671f1f372bd57808 100644 --- a/devices/geiger/gqgmc.go +++ b/devices/geiger/gqgmc.go @@ -112,7 +112,7 @@ const ( cmdTurnOnCPS = "<HEARTBEAT1>>" // GMC-280, GMC-300 Re.2.10 cmdTurnOffCPS = "<HEARTBEAT0>>" // Re.2.10 cmdTurnOffPwr = "<POWEROFF>>" // GMC-280, GMC-300 Re.2.11 - cmdTurnOn = "<POWERON>>" // GMC-280, GMC-300 Re.3.10 + cmdTurnOnPwr = "<POWERON>>" // GMC-280, GMC-300 Re.3.10 cmdFactoryReset = "<FACTORYRESET>>" // GMC-280, GMC-300 Re.3.00 cmdReboot = "<REBOOT>>" // GMC-280, GMC-300 Re.3.00 cmdGetTime = "<GETDATETIME>>" // GMC-280, GMC-300 Re.3.00 @@ -273,6 +273,12 @@ func (gc *GQGMCCounter) GetAutoCPS() (uint16, error) { return cps, nil } +// TurnOnPower turns the device on +func (gc *GQGMCCounter) TurnOnPower() { + gc.sendCmd(cmdTurnOnPwr) + return +} + // TurnOffPower turns the device off func (gc *GQGMCCounter) TurnOffPower() { gc.sendCmd(cmdTurnOffPwr) @@ -335,7 +341,7 @@ func (gc *GQGMCCounter) GetTime() (time.Time, error) { return t, nil } -// GetTemp gets the time +// GetTemp gets the temp func (gc *GQGMCCounter) GetTemp() (float64, error) { t, err := gc.communicate(cmdGetTemp, 4) if err != nil { @@ -353,7 +359,20 @@ func (gc *GQGMCCounter) GetTemp() (float64, error) { return temp, nil } -// cmdGetGyro = "<GETGYRO>>" // GMC-320 Re.3.01 +// GetGyro gets the position in space +func (gc *GQGMCCounter) GetGyro() (int16, int16, int16, error) { + buf, err := gc.communicate(cmdGetGyro, 7) + if err != nil { + return 0, 0, 0, err + } + x := (int16(buf[0]) << 8) + x |= (int16(buf[1]) & 0x00ff) + y := (int16(buf[0]) << 8) + y |= (int16(buf[1]) & 0x00ff) + z := (int16(buf[0]) << 8) + z |= (int16(buf[1]) & 0x00ff) + return x, y, z, nil +} // FactoryReset does a factory reset func (gc *GQGMCCounter) FactoryReset() {