Ejemplo n.º 1
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)
	}
}
Ejemplo n.º 2
0
Archivo: leds.go Proyecto: tthk/GoEV3
// Set Brightness (0 - 255)
func SetBrightness(color Color, position Position, brightness uint8) {
	if color == Amber {
		utilities.WriteIntValue(findFilename(Green, position), "brightness", int64(brightness))
		utilities.WriteIntValue(findFilename(Red, position), "brightness", int64(brightness))
	} else {
		utilities.WriteIntValue(findFilename(color, position), "brightness", int64(brightness))
	}

}
Ejemplo n.º 3
0
func setSpeed(folder string, speed int16) {
	regulationMode := utilities.ReadStringValue(folder, regulationModeFD)

	switch regulationMode {
	case "on":
		utilities.WriteIntValue(folder, speedSetterFD, int64(speed))
	case "off":
		if speed > 100 || speed < -100 {
			log.Fatal("The speed must be in range [-100, 100]")
		}
		utilities.WriteIntValue(folder, powerSetterFD, int64(speed))
	}
}
Ejemplo n.º 4
0
Archivo: motors.go Proyecto: tthk/GoEV3
// Runs the motor at the given port.
// The meaning of `speed` parameter depends on whether the regulation mode is turned on or off.
//
// When the regulation mode is off (by default) `speed` ranges from -100 to 100 and
// it's absolute value indicates the percent of motor's power usage. It can be roughly interpreted as
// a motor speed, but deepending on the environment, the actual speed of the motor
// may be lower than the target speed.
//
// When the regulation mode is on (has to be enabled by EnableRegulationMode function) the motor
// driver attempts to keep the motor speed at the `speed` value you've specified
// which ranges from about -1000 to 1000. The actual range depends on the type of the motor - see ev3dev docs.
//
// Negative values indicate reverse motion regardless of the regulation mode.
func Run(port OutPort, speed int16) {
	folder := findFolder(port)
	regulationMode := utilities.ReadStringValue(folder, regulationModeFD)

	switch regulationMode {
	case "on":
		utilities.WriteIntValue(folder, speedSetterFD, int64(speed))
		utilities.WriteStringValue(folder, runFD, "run-forever")
	case "off":
		if speed > 100 || speed < -100 {
			log.Fatal("The speed must be in range [-100, 100]")
		}
		utilities.WriteIntValue(folder, powerSetterFD, int64(speed))
		utilities.WriteStringValue(folder, runFD, "run-forever")
	}
}
Ejemplo n.º 5
0
func setAngle(folder string, angle int16) {
	utilities.WriteIntValue(folder, desiredPositionFD, int64(angle))
}
Ejemplo n.º 6
0
// InitializePosition sets the position of the motor at the given port.
func InitializePosition(port OutPort, value int32) {
	utilities.WriteIntValue(findFolder(port), positionFD, int64(value))
}
Ejemplo n.º 7
0
func setTime(folder string, seconds int32) {
	utilities.WriteIntValue(folder, timeFD, int64(seconds))
}