/* SPDX-License-Identifier: MIT * * Copyright (C) 2020 jet tsang zeon-git. All Rights Reserved. */ package servo // MoveTimeWrite func (s *Servo) MoveTimeWrite(position uint16, ms uint16) error { return s.sendInstruction(MoveTimeWrite, []uint16{position, ms}) } // MoveTimeRead func (s *Servo) MoveTimeRead() ([]byte, error) { return s.getData(MoveTimeRead) } // MoveTimeWaitWrite func (s *Servo) MoveTimeWaitWrite(position uint16, ms uint16) error { return s.sendInstruction(MoveTimeWaitWrite, []uint16{position, ms}) } // MoveTimeWaitRead func (s *Servo) MoveTimeWaitRead() ([]byte, error) { return s.getData(MoveTimeWaitRead) } // MoveStart func (s *Servo) MoveStart() error { return s.sendInstruction(MoveStart, nil) } // MoveStop func (s *Servo) MoveStop() ([]byte, error) { return s.getData(MoveStop) } // IDWrite func (s *Servo) IDWrite(newID uint16) error { return s.sendInstruction(IDWrite, []uint16{newID}) } // IDRead func (s *Servo) IDRead() ([]byte, error) { return s.getData(IDRead) } // AngleOffsetAdjust func (s *Servo) AngleOffsetAdjust(adjust uint16) error { return s.sendInstruction(AngleOffsetAdjust, []uint16{adjust}) } // AngleOffsetWrite: Save Offset to Servo's EEPROM func (s *Servo) AngleOffsetWrite() error { return s.sendInstruction(AngleOffsetWrite, nil) } // AngleOffsetRead: Read Offset from Servo's EEPROM func (s *Servo) AngleOffsetRead() ([]byte, error) { return s.getData(AngleOffsetRead) } // AngleLimitWrite: Set angle limit func (s *Servo) AngleLimitWrite(minAngle uint16, maxAngle uint16) error { return s.sendInstruction(AngleLimitWrite, []uint16{minAngle, maxAngle}) } // AngleLimitRead // TODO: translate byte to angle and position func (s *Servo) AngleLimitRead() ([]byte, error) { return s.getData(AngleLimitRead) } // VoltageLimitWrite func (s *Servo) VoltageLimitWrite(minVoltage uint16, maxVoltage uint16) error { return s.sendInstruction(VoltageLimitWrite, []uint16{minVoltage, maxVoltage}) } // VoltageLimitRead func (s *Servo) VoltageLimitRead() ([]byte, error) { return s.getData(VoltageLimitRead) } // TemperatureMaxLimitWrite func (s *Servo) TemperatureMaxLimitWrite(maxTemperature uint16) error { return s.sendInstruction(TemperatureMaxLimitWrite, []uint16{maxTemperature}) } // TemperatureMaxLimitRead func (s *Servo) TemperatureMaxLimitRead() ([]byte, error) { return s.getData(TemperatureMaxLimitRead) } // TemperatureRead func (s *Servo) TemperatureRead() ([]byte, error) { return s.getData(TemperatureRead) } // VoltageRead func (s *Servo) VoltageRead() ([]byte, error) { return s.getData(VoltageRead) } // PositionRead func (s *Servo) PositionRead() ([]byte, error) { return s.getData(PositionRead) } // MotorModeWrite // speed: -1000 to 1000 func (s *Servo) MotorModeWrite(isMotor uint16, speed uint16) error { return s.sendInstruction(MotorModeWrite, []uint16{isMotor << 8, speed}) } // MotorModeRead func (s *Servo) MotorModeRead() ([]byte, error) { return s.getData(MotorModeRead) } // LoadOrUnloadWrite func (s *Servo) LoadOrUnloadWrite(isLoad uint16) error { return s.sendInstruction(LoadOrUnloadWrite, []uint16{isLoad}) } // LoadOrUnloadRead func (s *Servo) LoadOrUnloadRead() ([]byte, error) { return s.getData(LoadOrUnloadRead) } // LEDControlWrite func (s *Servo) LEDControlWrite(isAlwayOn uint16) error { return s.sendInstruction(LEDControlWrite, []uint16{isAlwayOn}) } // LEDControlRead func (s *Servo) LEDControlRead() ([]byte, error) { return s.getData(LEDControlRead) } // LEDErrorWrite // lightColor: 1~7 func (s *Servo) LEDErrorWrite(lightColor uint16) error { return s.sendInstruction(LEDErrorWrite, []uint16{lightColor}) } // LEDErrorRead func (s *Servo) LEDErrorRead() ([]byte, error) { return s.getData(LEDErrorRead) }