|
@@ -103,7 +103,7 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
|
|
|
|
private UsbEndpoint mUsbEndpointOut;
|
|
private UsbEndpoint mUsbEndpointOut;
|
|
private UsbEndpoint mUsbEndpointIn;
|
|
private UsbEndpoint mUsbEndpointIn;
|
|
- private boolean mToggle = true;
|
|
|
|
|
|
+ private boolean bIsconnected = false;
|
|
private Button mSendMessage;
|
|
private Button mSendMessage;
|
|
private Button mlog1;
|
|
private Button mlog1;
|
|
private Button mSendCfg;
|
|
private Button mSendCfg;
|
|
@@ -183,15 +183,18 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
byte currentFreqIndex ;
|
|
byte currentFreqIndex ;
|
|
int currentFreq;
|
|
int currentFreq;
|
|
int freqNum;
|
|
int freqNum;
|
|
- // StringBuilder stringBuilder1 = new StringBuilder("");
|
|
|
|
|
|
+ byte addressH;
|
|
|
|
+ byte addressL;
|
|
|
|
+
|
|
while(true) {
|
|
while(true) {
|
|
StringBuilder stringBuilder1 = new StringBuilder("");
|
|
StringBuilder stringBuilder1 = new StringBuilder("");
|
|
StringBuilder stringBuilder2 = new StringBuilder("");
|
|
StringBuilder stringBuilder2 = new StringBuilder("");
|
|
//获取噪声数据
|
|
//获取噪声数据
|
|
- if(mUsbEndpointIn != null && mUsbEndpointOut != null) {
|
|
|
|
- byte showAddressHigh = (byte) 0xc6;
|
|
|
|
- byte showAddressLow = (byte) 0xe6;
|
|
|
|
- if (!iicRead(showAddressHigh, showAddressLow, mRawdataBytes, 156)) { //读取ADC噪声
|
|
|
|
|
|
+ //if((mUsbEndpointIn != null) || (mUsbEndpointOut != null)) {
|
|
|
|
+ if (bIsconnected == true){
|
|
|
|
+ addressH = (byte) 0xc6;
|
|
|
|
+ addressL = (byte) 0xe6;
|
|
|
|
+ if (!iicRead(addressH, addressL, mRawdataBytes, 156)) { //读取ADC噪声
|
|
// mrawlog.setText("iicRead Noise failed");
|
|
// mrawlog.setText("iicRead Noise failed");
|
|
//return false;
|
|
//return false;
|
|
startFreq = 0;
|
|
startFreq = 0;
|
|
@@ -204,7 +207,7 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
freqNum = endFreq-startFreq ;
|
|
freqNum = endFreq-startFreq ;
|
|
bitFreq = ((mRawdataBytes[2] & 0xFF) << 8) + (mRawdataBytes[3] & 0xFF);
|
|
bitFreq = ((mRawdataBytes[2] & 0xFF) << 8) + (mRawdataBytes[3] & 0xFF);
|
|
currentFreqIndex = mRawdataBytes[5];
|
|
currentFreqIndex = mRawdataBytes[5];
|
|
- currentFreq= currentFreqIndex*bitFreq;
|
|
|
|
|
|
+ currentFreq = currentFreqIndex * bitFreq;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
@@ -223,7 +226,7 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
//设置x轴
|
|
//设置x轴
|
|
XAxis xAxis = mLineChart.getXAxis();
|
|
XAxis xAxis = mLineChart.getXAxis();
|
|
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//值:BOTTOM,BOTH_SIDED,BOTTOM_INSIDE,TOP,TOP_INSIDE
|
|
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//值:BOTTOM,BOTH_SIDED,BOTTOM_INSIDE,TOP,TOP_INSIDE
|
|
- // xAxis.setGranularity(1f); //比例间隔
|
|
|
|
|
|
+ //xAxis.setGranularity(1f); //比例间隔
|
|
if(startFreq != 0){
|
|
if(startFreq != 0){
|
|
xAxis.setLabelCount(freqNum, true);//刻度数量 此函数只能显示26个标签
|
|
xAxis.setLabelCount(freqNum, true);//刻度数量 此函数只能显示26个标签
|
|
xAxis.setAxisMinimum(startFreq*bitFreq);// x刻度最小值
|
|
xAxis.setAxisMinimum(startFreq*bitFreq);// x刻度最小值
|
|
@@ -234,6 +237,7 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
xAxis.setAxisMinimum(120f);// x刻度最小值
|
|
xAxis.setAxisMinimum(120f);// x刻度最小值
|
|
xAxis.setAxisMaximum(280f); //x刻度最大值
|
|
xAxis.setAxisMaximum(280f); //x刻度最大值
|
|
}
|
|
}
|
|
|
|
+ xAxis.setTextSize(12f);
|
|
xAxis.setGridColor(Color.GRAY);
|
|
xAxis.setGridColor(Color.GRAY);
|
|
mLineChart.setScaleXEnabled(false); //关闭缩放
|
|
mLineChart.setScaleXEnabled(false); //关闭缩放
|
|
|
|
|
|
@@ -244,19 +248,21 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
|
|
|
|
rightYAxis.setAxisMinimum(0f);
|
|
rightYAxis.setAxisMinimum(0f);
|
|
rightYAxis.setAxisMaximum(255f);
|
|
rightYAxis.setAxisMaximum(255f);
|
|
- // rightYAxis.setGranularity(1f);
|
|
|
|
|
|
+ //rightYAxis.setGranularity(1f);
|
|
rightYAxis.setLabelCount(16,true);
|
|
rightYAxis.setLabelCount(16,true);
|
|
rightYAxis.setTextColor(Color.BLACK); //文字颜色
|
|
rightYAxis.setTextColor(Color.BLACK); //文字颜色
|
|
|
|
+ rightYAxis.setTextSize(13f);
|
|
//rightYAxis.setGridColor(Color.GRAY); //网格线颜色
|
|
//rightYAxis.setGridColor(Color.GRAY); //网格线颜色
|
|
rightYAxis.setDrawGridLines(false); //屏蔽网格线
|
|
rightYAxis.setDrawGridLines(false); //屏蔽网格线
|
|
|
|
|
|
- YAxis leftYAxis = mLineChart.getAxisLeft();
|
|
|
|
|
|
+ YAxis leftYAxis = mLineChart.getAxisLeft();
|
|
|
|
|
|
- leftYAxis.setAxisMinimum(0f);
|
|
|
|
- leftYAxis.setAxisMaximum(255f);
|
|
|
|
- //leftYAxis.setGranularity(1f);
|
|
|
|
- leftYAxis.setLabelCount(16,true);
|
|
|
|
- leftYAxis.setTextColor(Color.BLACK); //文字颜色
|
|
|
|
|
|
+ leftYAxis.setAxisMinimum(0f);
|
|
|
|
+ leftYAxis.setAxisMaximum(255f);
|
|
|
|
+ //leftYAxis.setGranularity(1f);
|
|
|
|
+ leftYAxis.setLabelCount(16,true);
|
|
|
|
+ leftYAxis.setTextColor(Color.BLACK); //文字颜色
|
|
|
|
+ leftYAxis.setTextSize(13f);
|
|
// rightYAxis.setGridColor(Color.GRAY); //网格线颜色
|
|
// rightYAxis.setGridColor(Color.GRAY); //网格线颜色
|
|
leftYAxis.setDrawGridLines(false); //屏蔽网格线
|
|
leftYAxis.setDrawGridLines(false); //屏蔽网格线
|
|
|
|
|
|
@@ -289,24 +295,24 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (ArithmeticException e) {
|
|
} catch (ArithmeticException e) {
|
|
- // mShow.setText("ArithmeticException!");
|
|
|
|
- // mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } catch (ArrayIndexOutOfBoundsException e) {
|
|
|
|
- // mShow.setText("ArrayIndexOutOfBoundsException!");
|
|
|
|
- // mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
+ // mShow.setText("ArithmeticException!");
|
|
|
|
+ // mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } catch (ArrayIndexOutOfBoundsException e) {
|
|
|
|
+ // mShow.setText("ArrayIndexOutOfBoundsException!");
|
|
|
|
+ // mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
|
|
- //最高点线
|
|
|
|
- StringBuilder maxnoise = new StringBuilder("");
|
|
|
|
- maxnoise.append((String)getResources().getString(R.string.maximumnoise));
|
|
|
|
- LimitLine limitLine = new LimitLine(fl_max,maxnoise.toString()); //得到限制线
|
|
|
|
- limitLine.setLineWidth(1f); //宽度
|
|
|
|
- limitLine.setTextSize(8f);
|
|
|
|
- limitLine.setTextColor(Color.parseColor("#F15A4A")); //颜色
|
|
|
|
- limitLine.setLineColor(Color.parseColor("#5C5C5C"));
|
|
|
|
- rightYAxis.addLimitLine(limitLine); //
|
|
|
|
|
|
+ //最高点线
|
|
|
|
+ StringBuilder maxnoise = new StringBuilder("");
|
|
|
|
+ maxnoise.append((String)getResources().getString(R.string.maximumnoise));
|
|
|
|
+ LimitLine limitLine = new LimitLine(fl_max,maxnoise.toString()); //得到限制线
|
|
|
|
+ limitLine.setLineWidth(1f); //宽度
|
|
|
|
+ limitLine.setTextSize(12f);
|
|
|
|
+ limitLine.setTextColor(Color.parseColor("#F15A4A")); //颜色
|
|
|
|
+ limitLine.setLineColor(Color.parseColor("#5C5C5C"));
|
|
|
|
+ rightYAxis.addLimitLine(limitLine); //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -316,39 +322,40 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
String dv = Integer.toString(v);
|
|
String dv = Integer.toString(v);
|
|
stringBuilder1.append((String)getResources().getString(R.string.currentfrequency));
|
|
stringBuilder1.append((String)getResources().getString(R.string.currentfrequency));
|
|
stringBuilder1.append(dv);
|
|
stringBuilder1.append(dv);
|
|
- // stringBuilder1.append(",");
|
|
|
|
|
|
+ stringBuilder1.append("Hz");
|
|
|
|
|
|
LimitLine currentFreqLine = new LimitLine(currentFreq,stringBuilder1.toString()); //得到限制线
|
|
LimitLine currentFreqLine = new LimitLine(currentFreq,stringBuilder1.toString()); //得到限制线
|
|
//LimitLine currentFreqLine = new LimitLine(137,"当前频点"); //得到限制线
|
|
//LimitLine currentFreqLine = new LimitLine(137,"当前频点"); //得到限制线
|
|
- currentFreqLine.setLineWidth(2f); //宽度
|
|
|
|
- currentFreqLine.setTextSize(8f);
|
|
|
|
- currentFreqLine.setTextColor(Color.parseColor("#F15A4A")); //颜色
|
|
|
|
- currentFreqLine.setLineColor(Color.parseColor("#269592"));
|
|
|
|
|
|
+ currentFreqLine.setLineWidth(4f); //宽度
|
|
|
|
+ currentFreqLine.setTextSize(40f);
|
|
|
|
+ currentFreqLine.setTextColor(Color.parseColor("#e75049")); //颜色
|
|
|
|
+ currentFreqLine.setLineColor(Color.parseColor("#e75049"));
|
|
xAxis.addLimitLine(currentFreqLine); //X轴添加限制线
|
|
xAxis.addLimitLine(currentFreqLine); //X轴添加限制线
|
|
|
|
|
|
|
|
|
|
//设置描述内容
|
|
//设置描述内容
|
|
- v = bitFreq;
|
|
|
|
- dv = Integer.toString(v);
|
|
|
|
- stringBuilder2.append("[" + (String)getResources().getString(R.string.bitfrequency) + "= ");
|
|
|
|
|
|
+ v = bitFreq;
|
|
|
|
+ dv = Integer.toString(v);
|
|
|
|
+ stringBuilder2.append("[" + (String)getResources().getString(R.string.bitfrequency) + " = ");
|
|
stringBuilder2.append(dv);
|
|
stringBuilder2.append(dv);
|
|
- stringBuilder2.append(",");
|
|
|
|
- v = freqNum;
|
|
|
|
- dv = Integer.toString(v);
|
|
|
|
- stringBuilder2.append((String)getResources().getString(R.string.frequencyfactor) + "= ");
|
|
|
|
|
|
+ stringBuilder2.append("Hz, ");
|
|
|
|
+ v = freqNum;
|
|
|
|
+ dv = Integer.toString(v);
|
|
|
|
+ stringBuilder2.append((String)getResources().getString(R.string.frequencyfactor) + " = ");
|
|
stringBuilder2.append(dv);
|
|
stringBuilder2.append(dv);
|
|
stringBuilder2.append("]");
|
|
stringBuilder2.append("]");
|
|
|
|
|
|
Description description = new Description();
|
|
Description description = new Description();
|
|
description.setText(stringBuilder2.toString());
|
|
description.setText(stringBuilder2.toString());
|
|
- description.setTextColor(Color.parseColor("#269592"));
|
|
|
|
- // description.setTextAlign(Paint.Align.LEFT);
|
|
|
|
|
|
+ description.setTextColor(Color.parseColor("#FFC800"));
|
|
|
|
+ description.setTextSize(18f);
|
|
|
|
+ // description.setTextAlign(Paint.Align.LEFT);
|
|
//description.setTextAlign(Paint.Align.CENTER);
|
|
//description.setTextAlign(Paint.Align.CENTER);
|
|
//description.setPosition(1000,300);
|
|
//description.setPosition(1000,300);
|
|
mLineChart.setDescription(description);
|
|
mLineChart.setDescription(description);
|
|
|
|
|
|
|
|
|
|
- //一个LineDataSet就是一条线
|
|
|
|
|
|
+ //一个LineDataSet就是一条线
|
|
LineDataSet lineDataSet;
|
|
LineDataSet lineDataSet;
|
|
lineDataSet = new LineDataSet(entries, "频点噪声(X轴单位:hz,Y轴单位:0-255)");
|
|
lineDataSet = new LineDataSet(entries, "频点噪声(X轴单位:hz,Y轴单位:0-255)");
|
|
LineData data = new LineData(lineDataSet);
|
|
LineData data = new LineData(lineDataSet);
|
|
@@ -357,7 +364,7 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
//线宽度
|
|
//线宽度
|
|
lineDataSet.setLineWidth(2f);
|
|
lineDataSet.setLineWidth(2f);
|
|
//不显示圆点
|
|
//不显示圆点
|
|
- // lineDataSet.setDrawCircles(false);
|
|
|
|
|
|
+ // lineDataSet.setDrawCircles(false);
|
|
lineDataSet.setDrawCircleHole(true);
|
|
lineDataSet.setDrawCircleHole(true);
|
|
lineDataSet.setCircleColorHole(Color.parseColor("#F15A4A"));
|
|
lineDataSet.setCircleColorHole(Color.parseColor("#F15A4A"));
|
|
lineDataSet.setCircleColor(Color.parseColor("#F15A4A")); //淡红色
|
|
lineDataSet.setCircleColor(Color.parseColor("#F15A4A")); //淡红色
|
|
@@ -428,17 +435,11 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
|
|
HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
|
|
if (deviceList != null) {
|
|
if (deviceList != null) {
|
|
for (UsbDevice usbDevice : deviceList.values()) {
|
|
for (UsbDevice usbDevice : deviceList.values()) {
|
|
- int productId = usbDevice.getProductId();
|
|
|
|
|
|
+ //int productId = usbDevice.getProductId();
|
|
int vendorId = usbDevice.getVendorId();
|
|
int vendorId = usbDevice.getVendorId();
|
|
- // if (productId == 0xC52F && vendorId == 0x046D) {
|
|
|
|
- //if (productId == 0x55e0 && vendorId == 0x4348) {
|
|
|
|
- if ((productId == 0x0818 && vendorId == 0x27C0)
|
|
|
|
- ||(productId == 0x0001 && vendorId == 0x222A)) //奕力的PID和VID
|
|
|
|
|
|
+ if (( vendorId == 0x27C0)
|
|
|
|
+ ||(vendorId == 0x222A)) //奕力的VID
|
|
{
|
|
{
|
|
- //这里说明下,这里的377 , 7205是我这台机子上独有,因为我这上面有多台设备,所以我在这里
|
|
|
|
- //判断了下.只有一台设备的无需这一步.
|
|
|
|
- //mUsbManager.requestPermission(usbDevice, pendingIntent);
|
|
|
|
- //SystemClock.sleep(100);
|
|
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
//initAccessory(usbDevice);
|
|
//initAccessory(usbDevice);
|
|
//mSendMessage.setEnabled(true); // dennis_debug
|
|
//mSendMessage.setEnabled(true); // dennis_debug
|
|
@@ -470,12 +471,6 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
* 初始化设备(手机) , 当手机进入Accessory模式后 , 手机的PID会变为Google定义的2个常量值其中的一个 ,
|
|
* 初始化设备(手机) , 当手机进入Accessory模式后 , 手机的PID会变为Google定义的2个常量值其中的一个 ,
|
|
*/
|
|
*/
|
|
private void initDevice() {
|
|
private void initDevice() {
|
|
- // mThreadPool.execute(new Runnable() {
|
|
|
|
- //@Override
|
|
|
|
- // public void run() {
|
|
|
|
- // while (mToggle) {
|
|
|
|
- // SystemClock.sleep(1000);
|
|
|
|
-
|
|
|
|
HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
|
|
HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
|
|
Collection<UsbDevice> values = deviceList.values();
|
|
Collection<UsbDevice> values = deviceList.values();
|
|
if (!values.isEmpty()) {
|
|
if (!values.isEmpty()) {
|
|
@@ -484,10 +479,8 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
int vendorId = usbDevice.getVendorId();
|
|
int vendorId = usbDevice.getVendorId();
|
|
//if (productId == 0x0818 || productId == 0x0001 )
|
|
//if (productId == 0x0818 || productId == 0x0001 )
|
|
if (( vendorId == 0x27C0)
|
|
if (( vendorId == 0x27C0)
|
|
- ||(vendorId == 0x222A) //奕力的VID
|
|
|
|
- ||(vendorId == 0x056A)) //8191主动笔和Wacom主动笔
|
|
|
|
- { //0x0001是奕力的PID
|
|
|
|
-
|
|
|
|
|
|
+ ||(vendorId == 0x222A)) //奕力的VID
|
|
|
|
+ {
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
if (mUsbManager.hasPermission(usbDevice)) {
|
|
|
|
|
|
mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
|
|
mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
|
|
@@ -542,7 +535,7 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
|
|
|
|
//if(0x80 == mUsbEndpointIn)
|
|
//if(0x80 == mUsbEndpointIn)
|
|
//mlog1.setEnabled(true);
|
|
//mlog1.setEnabled(true);
|
|
- //mToggle = false;
|
|
|
|
|
|
+ bIsconnected = false;
|
|
//isDetached = true;
|
|
//isDetached = true;
|
|
isNeedFindDevice = false;
|
|
isNeedFindDevice = false;
|
|
// mSendMessage.setEnabled(true);
|
|
// mSendMessage.setEnabled(true);
|
|
@@ -550,7 +543,7 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
mUsbInterface = usbInterface;
|
|
mUsbInterface = usbInterface;
|
|
mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
|
|
mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
|
|
if(null != mUsbEndpointIn){
|
|
if(null != mUsbEndpointIn){
|
|
-
|
|
|
|
|
|
+ bIsconnected = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -766,14 +759,6 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- private boolean iicTest() {
|
|
|
|
-
|
|
|
|
- if(isReceiverMessage)
|
|
|
|
- return false;
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//发送命令,使得S818可以通过IIC向GT9的固定地址读取1byte数据
|
|
//发送命令,使得S818可以通过IIC向GT9的固定地址读取1byte数据
|
|
private byte iicByteRead(byte addressHigh,byte addressLow) {
|
|
private byte iicByteRead(byte addressHigh,byte addressLow) {
|
|
|
|
|
|
@@ -810,328 +795,6 @@ public class NoiseAnalysis extends AppCompatActivity
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
|
|
|
|
-/**
|
|
|
|
- private boolean changeToDebugMode() {
|
|
|
|
-
|
|
|
|
- byte maddressHigh = (byte)0x80;
|
|
|
|
- byte maddressLow = (byte)0x46;
|
|
|
|
- byte msubcommand =0x0f ; //
|
|
|
|
- byte mdata = (byte)0x01;
|
|
|
|
-
|
|
|
|
- //if(false) {
|
|
|
|
- maddressHigh = (byte) 0x80;
|
|
|
|
- maddressLow = (byte) 0x40;
|
|
|
|
- msubcommand = (byte) 0x06; //ENTRY_DEBUG_MODE
|
|
|
|
- mdata = (byte) 0x01;
|
|
|
|
-
|
|
|
|
- if (!iicByteWrite(maddressHigh, maddressLow, msubcommand, mdata)) {
|
|
|
|
- // mrawlog.setText("[changeDebug]0x8040 write failed");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private boolean changeToNormalMode() {
|
|
|
|
-
|
|
|
|
- byte maddressHigh = (byte)0x80;
|
|
|
|
- byte maddressLow = (byte)0x40;
|
|
|
|
- byte msubcommand =0x07 ; //QUIT_DEBUG_MODE
|
|
|
|
- byte mdata = (byte)0x00;
|
|
|
|
-
|
|
|
|
- if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
|
|
|
|
- // mrawlog.setText("[changeNormal]0x8040 write failed");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- mrawlog.setText("[changeNormal]0x8040 write success");
|
|
|
|
- }
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- byte showAddressHigh = (byte)0x8b;
|
|
|
|
- byte showAddressLow = (byte)0x98; //需要显示的 address
|
|
|
|
- private boolean getRawdata() {
|
|
|
|
-
|
|
|
|
- byte maddressHigh = (byte)0x80;
|
|
|
|
- byte maddressLow = (byte)0x40; //rawdata address
|
|
|
|
- byte msubcommand =0x0d ; // READ_SYNC
|
|
|
|
- byte mdata = (byte)0x01;
|
|
|
|
- if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
|
|
|
|
- // mrawlog.setText("READ_SYNC write failed");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if(!iicRead(showAddressHigh,showAddressLow,mRawdataBytes,42*30*2)) { //读取rawData
|
|
|
|
- // mrawlog.setText("iicRead rawdata failed");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- maddressHigh = (byte)0x81;
|
|
|
|
- maddressLow = (byte)0x4E; // SYNC address
|
|
|
|
- msubcommand =0x0f ; // READ_SYNC
|
|
|
|
- mdata = (byte)0x00;
|
|
|
|
-
|
|
|
|
- // MainActivity mMainAct = new MainActivity();
|
|
|
|
- if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
|
|
|
|
- // mrawlog.setText("0x814E_SYNC write failed");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-*/
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- private TextView mrawlog;
|
|
|
|
- private TextView mtextView;
|
|
|
|
- private TextView mt1;
|
|
|
|
- private TextView mt2;
|
|
|
|
- private TextView mt3;
|
|
|
|
- private TextView mt4;
|
|
|
|
- private Button mrd1;
|
|
|
|
- private Button mbk;
|
|
|
|
- private Button mmd;
|
|
|
|
- private Button md;
|
|
|
|
- private Button mr;
|
|
|
|
- private Button msumr;
|
|
|
|
- private Button mnd;
|
|
|
|
- */
|
|
|
|
- //public void initTextView() {
|
|
|
|
-
|
|
|
|
- // mrawlog = (TextView) findViewById(R.id.rawlog);
|
|
|
|
-
|
|
|
|
- // mtextView = (TextView) findViewById(R.id.textView);
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- mmd= (Button) findViewById(R.id.button2);
|
|
|
|
- md = (Button) findViewById(R.id.button3);
|
|
|
|
- mr = (Button) findViewById(R.id.button4);
|
|
|
|
- msumr = (Button) findViewById(R.id.button5);
|
|
|
|
- mnd = (Button) findViewById(R.id.button6);
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
- /**
|
|
|
|
- int count = 1000;
|
|
|
|
- private void showRawdata() {
|
|
|
|
-
|
|
|
|
- mThreadPool.execute(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- int watch_dog = 0;
|
|
|
|
- byte syncFlag = 1;
|
|
|
|
-
|
|
|
|
- //show出噪声曲线
|
|
|
|
- showNoiseView();
|
|
|
|
- //if (!changeToDebugMode())
|
|
|
|
- // return false;
|
|
|
|
- if(mUsbEndpointIn == null || mUsbEndpointOut == null)
|
|
|
|
- {
|
|
|
|
- SystemClock.sleep(500);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- changeToDebugMode();
|
|
|
|
-
|
|
|
|
- while (showFlag != 4) {
|
|
|
|
-
|
|
|
|
- if (count-- == 0) {
|
|
|
|
- count = 0;
|
|
|
|
- }
|
|
|
|
- // if ((syncFlag != 0) && (syncFlag != 0x77)) {
|
|
|
|
- //
|
|
|
|
- // return false;
|
|
|
|
-
|
|
|
|
- if (getRawdata() == true) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- switch (showFlag) {
|
|
|
|
- case 1:// rawdata
|
|
|
|
- mHandler.sendEmptyMessage(RAWDATA_MESSAGE);
|
|
|
|
- break;
|
|
|
|
- case 2://manual diff
|
|
|
|
- if (count == 999) //第一帧备份rawdata作为基准
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < 42 * 30 * 2; i++) {
|
|
|
|
- // int v = mRawdataBytes[i] & 0xFF;
|
|
|
|
- int j = i / 2;
|
|
|
|
- mManualRefInt[j] = ((mRawdataBytes[i] & 0xFF) << 8) + (mRawdataBytes[i + 1] & 0xFF);
|
|
|
|
- i++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mHandler.sendEmptyMessage(MANUALDIFF_MESSAGE);
|
|
|
|
- // mHandler.sendEmptyMessage(RAWDATA_MESSAGE);
|
|
|
|
- break;
|
|
|
|
- case 3://
|
|
|
|
- mHandler.sendEmptyMessage(DIFF_MESSAGE);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- mHandler.sendEmptyMessage(CLEAR_MESSAGE); //清空文本框
|
|
|
|
- //break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- while (true) {
|
|
|
|
- //轮询读取0x814E,如果非0,则读取rawdata
|
|
|
|
- byte maddressHigh = (byte) 0x81;
|
|
|
|
- byte maddressLow = (byte) 0x4E; //_rRW_MISCTL__SWRST_B0_
|
|
|
|
- syncFlag = iicByteRead(maddressHigh, maddressLow);
|
|
|
|
- watch_dog++;
|
|
|
|
- //while ((syncFlag == 0 )|| (syncFlag == 0x77)) {
|
|
|
|
- if (((syncFlag == 0) || (syncFlag == 0x77))) {
|
|
|
|
- SystemClock.sleep(1);
|
|
|
|
- mHandler.sendEmptyMessage(LOG1_MESSAG);
|
|
|
|
- } else {
|
|
|
|
- if (count == 0) {
|
|
|
|
- mHandler.sendEmptyMessage(LOG2_MESSAGE);
|
|
|
|
- } else {
|
|
|
|
- // mHandler.sendEmptyMessage(SEND_MESSAGE_SUCCESS); //清空文本框
|
|
|
|
- }
|
|
|
|
- for (int i = 0; i < mRawdataBytes.length; i++) {
|
|
|
|
- mRawdataBytes[i] = (byte) 0x00;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- SystemClock.sleep(500);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } //ThreadPool
|
|
|
|
- }); //ThreadPool
|
|
|
|
- // return true;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-*/
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- Handler mHandler = new Handler() {
|
|
|
|
- @Override
|
|
|
|
- public void handleMessage(Message msg) {
|
|
|
|
-
|
|
|
|
- StringBuilder stringBuilder1 = new StringBuilder("");
|
|
|
|
- StringBuffer resultSb = new StringBuffer();
|
|
|
|
- int checksum = 0 ;
|
|
|
|
- switch (msg.what) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- case DIFF_MESSAGE://
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < dataLength;i++ ) {
|
|
|
|
- int v = mRawdataBytes[i] & 0xFF;
|
|
|
|
- //int v = (mManualRef[i] & 0xFF); //看alias noise
|
|
|
|
- // String hv = Integer.toHexString(v);
|
|
|
|
- String dv = Integer.toString(v);
|
|
|
|
- stringBuilder1.append(dv);
|
|
|
|
- stringBuilder1.append(" ");
|
|
|
|
- //i++;
|
|
|
|
- }
|
|
|
|
- mtextView.setText(stringBuilder1.toString());
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-*/
|
|
|
|
- /**
|
|
|
|
-byte showFlag = 0;
|
|
|
|
- @Override
|
|
|
|
- public void onClick(final View v) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- dataLength = 42*30;
|
|
|
|
- switch (v.getId()) {
|
|
|
|
- case R.id.rd1: //raw data
|
|
|
|
- showFlag =1;
|
|
|
|
- // count = 1000;
|
|
|
|
- showAddressHigh = (byte)0x8b;
|
|
|
|
- showAddressLow = (byte)0x98;
|
|
|
|
- if(count == 1000)
|
|
|
|
- showRawdata();
|
|
|
|
- break;
|
|
|
|
- case R.id.bk: //back
|
|
|
|
- showFlag =4;
|
|
|
|
- count = 1000;
|
|
|
|
- changeToNormalMode();
|
|
|
|
- break;
|
|
|
|
- case R.id.button2: //manual diff
|
|
|
|
- showFlag =2;
|
|
|
|
- showAddressHigh = (byte)0x8b;
|
|
|
|
- showAddressLow = (byte)0x98;
|
|
|
|
- if(count == 1000) {
|
|
|
|
- showRawdata();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- count = 1000;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case R.id.button3: //diff
|
|
|
|
- showFlag =3;
|
|
|
|
- showAddressHigh = (byte)0xbb;
|
|
|
|
- showAddressLow = (byte)0x10;
|
|
|
|
- if(count == 1000)
|
|
|
|
- showRawdata();
|
|
|
|
- break;
|
|
|
|
- case R.id.button4: //ref
|
|
|
|
- showFlag =4;
|
|
|
|
- count = 1000;
|
|
|
|
- showAddressHigh = (byte)0x81;
|
|
|
|
- showAddressLow = (byte)0xc0;
|
|
|
|
- getRawdata();
|
|
|
|
- mHandler.sendEmptyMessage(RAWDATA_MESSAGE);
|
|
|
|
- // showRawdata();
|
|
|
|
- break;
|
|
|
|
- case R.id.button5: //set up manual ref
|
|
|
|
- showFlag =2;
|
|
|
|
- count = 1000;
|
|
|
|
- showAddressHigh = (byte)0x8b;
|
|
|
|
- showAddressLow = (byte)0x98;
|
|
|
|
- // showRawdata();
|
|
|
|
-
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case R.id.button6: //read Noise data
|
|
|
|
- showFlag =3;
|
|
|
|
- count = 1000;
|
|
|
|
- showAddressHigh = (byte)0xc6;
|
|
|
|
- showAddressLow = (byte)0xe6;
|
|
|
|
-
|
|
|
|
- //show出噪声曲线
|
|
|
|
- showNoiseView();
|
|
|
|
-
|
|
|
|
- //if(count == 1000)
|
|
|
|
- // showRawdata();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- default:
|
|
|
|
- // break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-*/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
protected void onDestroy() {
|
|
protected void onDestroy() {
|
|
|
|
|
|
@@ -1144,7 +807,7 @@ byte showFlag = 0;
|
|
}
|
|
}
|
|
mUsbEndpointIn = null;
|
|
mUsbEndpointIn = null;
|
|
mUsbEndpointOut = null;
|
|
mUsbEndpointOut = null;
|
|
- //mToggle = false;
|
|
|
|
|
|
+ bIsconnected = false;
|
|
isReceiverMessage = false;
|
|
isReceiverMessage = false;
|
|
isNeedFindDevice = false;
|
|
isNeedFindDevice = false;
|
|
mThreadPool.shutdownNow();
|
|
mThreadPool.shutdownNow();
|