Пример #1
0
// Runs the motor at the given port.
// `speed` ranges from -100 to 100 and indicates the target speed of the motor, with negative values indicating reverse motion. Depending on the environment, the actual speed of the motor may be lower than the target speed.
func Run(port OutPort, speed int16) {
	if speed > 100 || speed < -100 {
		log.Fatal("The speed must be in range [-100, 100]")
	}

	utilities.WriteIntValue(findFilename(port), "run", 1)
	utilities.WriteIntValue(findFilename(port), "speed_setpoint", int64(speed))
}
Пример #2
0
// Turns off the given LED with the specified color.
func TurnOff(color Color, position Position) {
	if color == Amber {
		utilities.WriteIntValue(findFilename(Green, position), "brightness", 0)
		utilities.WriteIntValue(findFilename(Red, position), "brightness", 0)
	} else {
		utilities.WriteIntValue(findFilename(color, position), "brightness", 0)
	}
}
Пример #3
0
// Stops the motor at the given port.
func Stop(port OutPort) {
	utilities.WriteIntValue(findFilename(port), "run", 0)
}