def __init__(self): # Init I2C for communication with Arduino if (hal.isSimulation()): # import stub for simulation from components.i2cstub import I2CStub self.arduinoC = wpilib.I2C(wpilib.I2C.Port.kOnboard, 4, I2CStub()) else: self.arduinoC = wpilib.I2C(wpilib.I2C.Port.kOnboard, 4) self.allianceColor = 'red'
def __init__(self, port: wpilib.I2C.Port = None, address: int = None) -> None: super().__init__() if address is None: address = self.ADDRESS_A if port is None: port = wpilib.I2C.Port.kMXP sim_port = None if hal.isSimulation(): from .bno055_sim import BNO055Sim sim_port = BNO055Sim() self.i2c = wpilib.I2C(port, address, sim_port) # set the units that we want self.offset = 0.0 current_units = self.i2c.read(self.Register.UNIT_SEL, 1)[0] for wanted, index in self.UNIT_SEL_LIST: if wanted == 1: current_units = current_units | (1 << index) elif wanted == 0: current_units = current_units & ~(1 << index) self.i2c.write(self.Register.UNIT_SEL, current_units) self.setOperationMode(self.OperationMode.IMUPLUS) # accelerometer and gyro self.reverse_axis(False, False, False) self.cache_heading()
def __init__(self, addr=4): self.i2c = wpilib.I2C(wpilib.I2C.Port.kOnboard, addr) self.msg_length = 8 self.data = [] self.offset = 0 self.distance = 0
def __init__(self, port): simPort = None if hal.HALIsSimulation(): from ._impl.sim_io import NavXI2CSim simPort = NavXI2CSim() self.port = wpilib.I2C(port, 0x32, simPort=simPort)
def getBlocks(signature): address=0x54 bus = wpilib.I2C(wpilib.I2C.Port.kOnboard,address) data=[174,193,32,2,255,1] bus.writeBulk(data) time.sleep(0.05) res=bus.read(address, 18) if res[6]+255*res[7]==signature: return {'s':signature,'x':res[8]+255*res[9],'y':res[10]+255*res[11],'w':res[12]+255*res[13],'h':res[14]+255*res[15]}
def __init__(self): self.i2c = wpilib.I2C(wpilib.I2C.Port.kOnboard, 0x69) self.x = 0 self.y = 0 self.z = 0 self.xbuf = [0] * 50 self.ybuf = [0] * 50 self.zbuf = [0] * 50 self.i = 0
def __init__(self, port: wpilib.I2C.Port = 0): super().__init__() if port is None: port = wpilib.I2C.Port.kOnboard simPort = None if hal.HALIsSimulation(): simPort = REV_Color_Sim(self) self.i2c = wpilib.I2C(port, self.ADDRESS, simPort=simPort) self.clearChannel = 0 self.setName("REV_Robotics_Color_Sensor_V2", port)
def __init__(self, robot): super().__init__('arduino') self.table = networktables.NetworkTables.getTable("arduino") self.i2c = wpilib.I2C(wpilib.I2C.Port.kOnboard, const.ARDUINO_DEVICE_ADDRESS) self.robot = robot self.led_state = self.Led_State.DEFAULT self.set_led_state(self.Led_State.DEFAULT) # Used in log below, to print/log line sensor value only when it changes self._last_line_value = -1 # Current line value self.current_line_value = -1
def __init__(self, integration_time=TCS34725_INTEGRATIONTIME_2_4MS, gain=TCS34725_GAIN_4X, address=TCS34725_ADDRESS, **kwargs): """Initialize the TCS34725 sensor.""" # Setup I2C interface for the device. self._device = wpilib.I2C(wpilib.I2C.Port.kOnboard, address) # Make sure we're connected to the sensor. chip_id = self._readU8(TCS34725_ID) if chip_id != 0x44: raise RuntimeError( 'Failed to read TCS34725 chip ID, check your wiring.') # Set default integration time and gain. self.set_integration_time(integration_time) self.set_gain(gain) # Enable the device (by default, the device is in power down mode on bootup). self.enable()
def __init__(self, port, addr=DEFAULT_ADDR, integrate=True): self.i2c = wpilib.I2C(port, addr) self.addr = addr self.resetAngle() self.centerX = 0 self.centerY = 0 self.centerZ = 0 self.xGyro = self.Gyro(self.Axis.X, self) self.yGyro = self.Gyro(self.Axis.Y, self) self.zGyro = self.Gyro(self.Axis.Z, self) self.intrTask = None if integrate: self.intrTask = TimerTask("ITG3200 Integrate", 0.05, self.update) self.intrTask.start() self.enabled = True
def setLamp(status): bus =wpilib.I2C(wpilib.I2C.Port.kOnboard,4) adddress=0x54 data=[174,193,22,2,status,0] bus.writeBulk(adddress,data)
def __init__(self): self.lidar = wpilib.I2C(wpilib.I2C.Port.kOnboard, 0x03) self.liftMotor = WPI_TalonSRX(ELEVATOR_TALON) self.elevatorPID = ProtoPID(1 / 18.0, 0.0, 0.0, 0.0, .02)
def __init__(self): self.drivetrain = DriveTrain self.cubemech = CubeMech self.i2c = wpilib.I2C(wpilib.I2C.Port.kOnboard, 4)
def create_i2c(port, deviceAddress, simPort=None): return wpilib.I2C(port, deviceAddress, simPort)
def __init__(self, port=wpilib.I2C.Port.kOnboard): ''' Constructor ''' self.i2c = wpilib.I2C(port, 0x4A)