|
@@ -53,7 +53,7 @@ public class NoiseAnalysis extends AppCompatActivity implements OpenDevicesRecei
|
|
|
|
|
|
private Context mAlertContext;
|
|
|
//MainActivity mMainAct = new MainActivity();
|
|
|
- private byte[] mRawdataBytes = new byte[42*30*2+64*2];
|
|
|
+ private byte[] mRawdataBytes = new byte[256];
|
|
|
|
|
|
private static final int RAWDATA_MESSAGE = 0;
|
|
|
private static final int LOG1_MESSAG = 1;
|
|
@@ -97,6 +97,7 @@ public class NoiseAnalysis extends AppCompatActivity implements OpenDevicesRecei
|
|
|
private UsbInterface mUsbInterface;
|
|
|
private StringBuffer mStringBuffer = new StringBuffer();
|
|
|
private Context mDataContext;
|
|
|
+ private int iProductId;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -162,20 +163,42 @@ public class NoiseAnalysis extends AppCompatActivity implements OpenDevicesRecei
|
|
|
//获取噪声数据
|
|
|
//if((mUsbEndpointIn != null) || (mUsbEndpointOut != null)) {
|
|
|
if (bIsconnected == true){
|
|
|
- addressH = (byte) 0xc6;
|
|
|
- addressL = (byte) 0xe6;
|
|
|
- if (!iicRead(addressH, addressL, mRawdataBytes, 156)) { //读取ADC噪声
|
|
|
-
|
|
|
- startFreq = 0;
|
|
|
- continue;
|
|
|
- } else {
|
|
|
-
|
|
|
- startFreq = mRawdataBytes[0];
|
|
|
- endFreq = mRawdataBytes[1];
|
|
|
- freqNum = endFreq-startFreq ;
|
|
|
- bitFreq = ((mRawdataBytes[2] & 0xFF) << 8) + (mRawdataBytes[3] & 0xFF);
|
|
|
- currentFreqIndex = mRawdataBytes[5];
|
|
|
- currentFreq = currentFreqIndex * bitFreq;
|
|
|
+ if ((iProductId == 0x0819) || (iProductId == 0x8191))
|
|
|
+ {
|
|
|
+ addressH = (byte) 0xF3;
|
|
|
+ addressL = (byte) 0xB4;
|
|
|
+ if (!iicRead(addressH, addressL, mRawdataBytes, 156)) { //读取ADC噪声
|
|
|
+ startFreq = 0;
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ iicRead((byte)0x81, (byte)0xBD, mConfigData,1);
|
|
|
+
|
|
|
+ startFreq = mRawdataBytes[0];
|
|
|
+ endFreq = mRawdataBytes[1];
|
|
|
+ freqNum = endFreq - startFreq + 1;
|
|
|
+ bitFreq = 1000000 / (mConfigData[0] & 0xFF);
|
|
|
+ currentFreqIndex = mRawdataBytes[5];
|
|
|
+ currentFreq = currentFreqIndex * bitFreq;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ addressH = (byte) 0xc6;
|
|
|
+ addressL = (byte) 0xe6;
|
|
|
+ if (!iicRead(addressH, addressL, mRawdataBytes, 156)) { //读取ADC噪声
|
|
|
+
|
|
|
+ startFreq = 0;
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ startFreq = mRawdataBytes[0];
|
|
|
+ endFreq = mRawdataBytes[1];
|
|
|
+ freqNum = endFreq - startFreq + 1;
|
|
|
+ bitFreq = ((mRawdataBytes[2] & 0xFF) << 8) + (mRawdataBytes[3] & 0xFF);
|
|
|
+ currentFreqIndex = mRawdataBytes[5];
|
|
|
+ currentFreq = currentFreqIndex * bitFreq;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
@@ -197,8 +220,8 @@ public class NoiseAnalysis extends AppCompatActivity implements OpenDevicesRecei
|
|
|
//xAxis.setGranularity(1f); //比例间隔
|
|
|
if(startFreq != 0){
|
|
|
xAxis.setLabelCount(freqNum, true);//刻度数量 此函数只能显示26个标签
|
|
|
- xAxis.setAxisMinimum(startFreq*bitFreq);// x刻度最小值
|
|
|
- xAxis.setAxisMaximum((endFreq-1)*bitFreq); //x刻度最大值
|
|
|
+ xAxis.setAxisMinimum(startFreq * bitFreq);// x刻度最小值
|
|
|
+ xAxis.setAxisMaximum(endFreq * bitFreq); //x刻度最大值
|
|
|
}
|
|
|
else {
|
|
|
xAxis.setLabelCount(21, true);//刻度数量
|
|
@@ -405,8 +428,9 @@ public class NoiseAnalysis extends AppCompatActivity implements OpenDevicesRecei
|
|
|
for (UsbDevice usbDevice : deviceList.values()) {
|
|
|
//int productId = usbDevice.getProductId();
|
|
|
int vendorId = usbDevice.getVendorId();
|
|
|
- if (( vendorId == 0x27C0)
|
|
|
- ||(vendorId == 0x222A)) //奕力的VID
|
|
|
+ if ((vendorId == 0x27C0)
|
|
|
+ ||(vendorId == 0x222A) //奕力的VID
|
|
|
+ ||(vendorId == 0x056A)) //8191主动笔和Wacom主动笔
|
|
|
{
|
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
|
//initAccessory(usbDevice);
|
|
@@ -443,8 +467,9 @@ public class NoiseAnalysis extends AppCompatActivity implements OpenDevicesRecei
|
|
|
//int productId = usbDevice.getProductId();
|
|
|
int vendorId = usbDevice.getVendorId();
|
|
|
//if (productId == 0x0818 || productId == 0x0001 )
|
|
|
- if (( vendorId == 0x27C0)
|
|
|
- ||(vendorId == 0x222A)) //奕力的VID
|
|
|
+ if ((vendorId == 0x27C0)
|
|
|
+ ||(vendorId == 0x222A) //奕力的VID
|
|
|
+ ||(vendorId == 0x056A)) //8191主动笔和Wacom主动笔
|
|
|
{
|
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
|
|
|
@@ -506,6 +531,7 @@ public class NoiseAnalysis extends AppCompatActivity implements OpenDevicesRecei
|
|
|
mUsbInterface = usbInterface;
|
|
|
mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
|
|
|
if(null != mUsbEndpointIn){
|
|
|
+ iProductId = usbDevice.getProductId();
|
|
|
bIsconnected = true;
|
|
|
}
|
|
|
}
|