当前位置: 首页>>代码示例>>Java>>正文


Java TypeConversion类代码示例

本文整理汇总了Java中com.qualcomm.robotcore.util.TypeConversion的典型用法代码示例。如果您正苦于以下问题:Java TypeConversion类的具体用法?Java TypeConversion怎么用?Java TypeConversion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypeConversion类属于com.qualcomm.robotcore.util包,在下文中一共展示了TypeConversion类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: foundExpectedBytes

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
private boolean foundExpectedBytes(int[] byteArray, Lock lock, byte[] cache) {
  try {
    lock.lock();
    boolean allMatch = true;
    StringBuilder s = new StringBuilder(300 * 4);
    String mismatch = "";
    for (int i = 0; i < byteArray.length; i++) {
      s.append(String.format("expected: %02x, got: %02x \n", TypeConversion.unsignedByteToInt( (byte) byteArray[i]), cache[i]));
      if (TypeConversion.unsignedByteToInt(cache[i]) != TypeConversion.unsignedByteToInt( (byte) byteArray[i])) {
        mismatch = String.format("i: %d, byteArray[i]: %02x, cache[i]: %02x", i, byteArray[i], cache[i]);
        allMatch = false;
      }
    }
    RobotLog.e(s.toString() + "\n allMatch: " + allMatch + ", mismatch: " + mismatch);
    return allMatch;
  } finally {
    lock.unlock();
  }
}
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:20,代码来源:ConceptI2cAddressChange.java

示例2: notFoundExpectedBytes

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
private boolean notFoundExpectedBytes(int[] byteArray, Lock lock, byte[] cache) {
    try {
        lock.lock();
        boolean allMatch = true;
        StringBuilder s = new StringBuilder(300 * 4);
        String mismatch = "";
        for (int i = 0; i < byteArray.length; i++) {
            s.append(String.format("expected: %02x, got: %02x \n", TypeConversion.unsignedByteToInt((byte) byteArray[i]), cache[i]));
            if (TypeConversion.unsignedByteToInt(cache[i]) != TypeConversion.unsignedByteToInt((byte) byteArray[i])) {
                mismatch = String.format("i: %d, byteArray[i]: %02x, cache[i]: %02x", i, byteArray[i], cache[i]);
                allMatch = false;
                break;
            }
        }
        RobotLog.e(s.toString() + "\n allMatch: " + allMatch + ", mismatch: " + mismatch);
        return !allMatch;
    } finally {
        lock.unlock();
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:21,代码来源:LinearI2cAddressChange.java

示例3: write2

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
private void write2(final byte[] var1) {
    if (this.DEBUG_LOGGING) {
        RobotLog.d(this.serialNumber + " USB recd: " + Arrays.toString(var1));
    }

    (new Thread() {
        public void run() {
            int var1x = TypeConversion.unsignedByteToInt(var1[3]);
            int var2 = TypeConversion.unsignedByteToInt(var1[4]);

            try {
                Thread.sleep(10L);
                byte[] var3;
                switch (var1[2]) {
                    case -128:
                        var3 = new byte[e.length + var2];
                        System.arraycopy(e, 0, var3, 0, e.length);
                        var3[3] = var1[3];
                        var3[4] = var1[4];
                        System.arraycopy(f, var1x, var3, e.length, var2);
                        break;
                    case 0:
                        var3 = new byte[d.length];
                        System.arraycopy(d, 0, var3, 0, d.length);
                        var3[3] = var1[3];
                        var3[4] = 0;
                        System.arraycopy(var1, 5, f, var1x, var2);
                        break;
                    default:
                        var3 = Arrays.copyOf(var1, var1.length);
                        var3[2] = -1;
                        var3[3] = var1[3];
                        var3[4] = 0;
                }

                h.put(var3);
            } catch (InterruptedException var4) {
                RobotLog.w("USB mock bus interrupted during write");
            }

        }
    }).start();
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:44,代码来源:XtensibleEventLoop.java

示例4: setMotorTargetPosition

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
@Override
public synchronized void setMotorTargetPosition(int motor, int position) {
    this.validateMotor(motor);
    byte[] bytes = TypeConversion.intToByteArray(position, ByteOrder.BIG_ENDIAN);
    this.write(mpMotorRegTargetEncoderValue[motor], bytes);
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:7,代码来源:HiTechnicDcMotorController.java

示例5: getMotorTargetPosition

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
@Override
public synchronized int getMotorTargetPosition(int motor) {
    this.validateMotor(motor);
    byte[] bytes = this.i2cDeviceClient.read(mpMotorRegTargetEncoderValue[motor], cbEncoder);
    return TypeConversion.byteArrayToInt(bytes, ByteOrder.BIG_ENDIAN);
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:7,代码来源:HiTechnicDcMotorController.java

示例6: getMotorCurrentPosition

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
@Override
public synchronized int getMotorCurrentPosition(int motor) {
    this.validateMotor(motor);
    byte[] bytes = this.i2cDeviceClient.read(mpMotorRegCurrentEncoderValue[motor], cbEncoder);
    return TypeConversion.byteArrayToInt(bytes, ByteOrder.BIG_ENDIAN);
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:7,代码来源:HiTechnicDcMotorController.java

示例7: read8

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
int read8(int ireg) {
    byte b = this.i2cDeviceClient.read8(ireg);
    return TypeConversion.unsignedByteToInt(b);
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:5,代码来源:AdaFruitTCS34725ColorSensor.java

示例8: readLH

import com.qualcomm.robotcore.util.TypeConversion; //导入依赖的package包/类
int readLH(int ireg) {
    byte[] bytes = this.i2cDeviceClient.read(ireg, 2);
    return TypeConversion.byteArrayToInt(bytes, ByteOrder.LITTLE_ENDIAN);
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:5,代码来源:AdaFruitTCS34725ColorSensor.java


注:本文中的com.qualcomm.robotcore.util.TypeConversion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。