示例#1
0
文件: color.go 项目: rwaldron/GoEV3
// Reads the ambient light intensity in range [0, 100].
func (self *ColorSensor) ReadAmbientLightIntensity() uint8 {
	snr := findSensor(self.port, TypeColor)

	path := fmt.Sprintf("/sys/class/msensor/%s", snr)
	utilities.WriteStringValue(path, "mode", "COL-AMBIENT")
	value := utilities.ReadUInt8Value(path, "value0")

	return value
}
示例#2
0
文件: color.go 项目: rwaldron/GoEV3
// Reads one of seven color values.
func (self *ColorSensor) ReadColor() Color {
	snr := findSensor(self.port, TypeColor)

	path := fmt.Sprintf("/sys/class/msensor/%s", snr)
	utilities.WriteStringValue(path, "mode", "COL-COLOR")
	value := utilities.ReadUInt8Value(path, "value0")

	return Color(value)
}
示例#3
0
// Reads the distance (in centimeters) reported by the ultrasonic sensor.
func (self *UltrasonicSensor) ReadDistance() uint16 {
	snr := findSensor(self.port, TypeUltrasonic)

	path := fmt.Sprintf("/sys/class/msensor/%s", snr)
	utilities.WriteStringValue(path, "mode", "US-SI-CM")
	value := utilities.ReadUInt16Value(path, "value0")

	return (value / 10)
}
示例#4
0
// Reads the proximity value (in range 0 - 100) reported by the infrared sensor. A value of 100 corresponds to a range of approximately 70 cm.
func (self *InfraredSensor) ReadProximity() uint8 {
	snr := findSensor(self.port, TypeInfrared)

	path := fmt.Sprintf("/sys/class/msensor/%s", snr)
	utilities.WriteStringValue(path, "mode", "IR-PROX")
	value := utilities.ReadUInt8Value(path, "value0")

	return value
}
示例#5
0
// Looks for other nearby ultrasonic sensors and returns true if one is found.
func (self *UltrasonicSensor) Listen() bool {
	snr := findSensor(self.port, TypeUltrasonic)

	path := fmt.Sprintf("/sys/class/msensor/%s", snr)
	utilities.WriteStringValue(path, "mode", "US-LISTEN")
	value := utilities.ReadUInt8Value(path, "value0")

	if value == 1 {
		return true
	}

	return false
}
示例#6
0
文件: motors.go 项目: rwaldron/GoEV3
// Disables brake mode, causing the motor at the given port to coast to stops. Brake mode is off by default.
func DisableBrakeMode(port OutPort) {
	utilities.WriteStringValue(findFilename(port), "brake_mode", "off")
}
示例#7
0
文件: motors.go 项目: rwaldron/GoEV3
// Disables regulation mode. Regulation mode is off by default.
func DisableRegulationMode(port OutPort) {
	utilities.WriteStringValue(findFilename(port), "regulation_mode", "off")
}