更新摇杆功能

chenghonghao_branch
Marcus 2 years ago
parent f7f957a18c
commit 5796ca9a71

@ -61,7 +61,7 @@ public class MyVideo extends Activity {
BtnStop = findViewById(R.id.button_stop); BtnStop = findViewById(R.id.button_stop);
rockerView = new RockerView(this,socketWriter,this.getApplicationContext(),null); rockerView = new RockerView(this,socketWriter,this.getApplicationContext(),null);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(600,600); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1000,1000);
addContentView(rockerView,params); addContentView(rockerView,params);
Intent intent = getIntent(); Intent intent = getIntent();

@ -8,6 +8,7 @@ import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.RectF; import android.graphics.RectF;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -22,8 +23,8 @@ public class RockerView extends View{
Paint backPaint = new Paint(); // 背景画笔 Paint backPaint = new Paint(); // 背景画笔
Paint bubblePaint = new Paint(); // 气泡画笔 Paint bubblePaint = new Paint(); // 气泡画笔
Paint rectfPaint = new Paint(); Paint rectfPaint = new Paint();
float bubbleX = 250, bubbleY = 300; // 定义气泡的位置 float bubbleX = 300, bubbleY = 700; // 定义气泡的位置
float backX = 250, backY = 300; // 背景圆的位置 float backX = 300, backY = 700; // 背景圆的位置
int radiusBack = 200, radiusBubble = 100; // 定义背景圆以及气泡的半径 int radiusBack = 200, radiusBubble = 100; // 定义背景圆以及气泡的半径
RectF mRectF = new RectF(backX-radiusBack,backY-radiusBack,backX+radiusBack,backY+radiusBack); RectF mRectF = new RectF(backX-radiusBack,backY-radiusBack,backX+radiusBack,backY+radiusBack);
Context mContext; Context mContext;
@ -37,11 +38,12 @@ public class RockerView extends View{
this.mContext = context; this.mContext = context;
} }
private void initPaint() { private void initPaint() {
int grayColor = Color.argb(128, 128, 128, 128);
backPaint.setAntiAlias(true); backPaint.setAntiAlias(true);
backPaint.setColor(Color.parseColor("blue")); backPaint.setColor(grayColor);
bubblePaint.setAntiAlias(true); bubblePaint.setAntiAlias(true);
bubblePaint.setColor(Color.parseColor("red")); bubblePaint.setColor(grayColor);
rectfPaint.setAntiAlias(true); rectfPaint.setAntiAlias(true);
rectfPaint.setColor(Color.parseColor("red")); rectfPaint.setColor(Color.parseColor("red"));
@ -57,6 +59,7 @@ public class RockerView extends View{
case "GO": case "GO":
// TODO Auto-generated method stub // TODO Auto-generated method stub
try { try {
Log.d("wifirobot","moveup");
socketWriter.write(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xff}); socketWriter.write(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xff});
socketWriter.flush(); socketWriter.flush();
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save