Skip to content
Snippets Groups Projects
Commit d569371e authored by Kevin Lyda's avatar Kevin Lyda :speech_balloon:
Browse files

More functions.

parent cb6a4150
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment