Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 2:817bcbc3431e, committed 2019-03-07
- Comitter:
- la00noix
- Date:
- Thu Mar 07 03:01:12 2019 +0000
- Parent:
- 1:d15f6e5eda54
- Commit message:
- a
Changed in this revision
| User.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/User.cpp Sat Mar 02 07:50:03 2019 +0000
+++ b/User.cpp Thu Mar 07 03:01:12 2019 +0000
@@ -28,7 +28,7 @@
DigitalIn in_left(p18);
//Ticker can_ticker; //タイマー割り込み
-char can_ashidata[3]= {0}; //CAN送信用の配列
+char can_ashidata[4]= {0}; //CAN送信用の配列
char can_armdata[2]= {0};
int can_ashidata0_01,can_ashidata0_2,can_ashidata0_34,can_ashidata0_5,can_ashidata0_6;
@@ -49,24 +49,19 @@
int old_button8,now_button8;
int flag1,flag2,flag3,flag4,flag5,flag6,flag7,flag8;
-int t1 = 0, t2 = 0, t3 = 0;
-char final_t[1] = {0};
+int t1=0,t2=0,t3=0;
void can_sendread() //割込み使ってない
{
- if(can1.write(CANMessage(1,can_ashidata,3))) { //IDを1にして3バイト送信
- printf("ashi[0],start&select=%d R1=%d RS=%d LS=%d TOGGLE=%d\n\r"
- ,can_ashidata0_01,can_ashidata0_2,can_ashidata0_34,can_ashidata0_5,can_ashidata0_6);
+ if(can1.write(CANMessage(1,can_ashidata,4))) { //IDを1にして3バイト送信
+ printf("ashi[0],start&select=%d R1=%d RS=%d LS=%d TOGGLE=%d can_ashidata[3]=%d\n\r"
+ ,can_ashidata0_01,can_ashidata0_2,can_ashidata0_34,can_ashidata0_5,can_ashidata0_6,can_ashidata[3]);
}
if(can1.write(CANMessage(2,can_armdata,2))) { //IDを2にして2バイト送信
cansend_led = 1;
printf("arm,CIRCLE=%d CROSS=%d SQUARE=%d TRIANGEL=%d RIGHT=%d DOWN=%d UP=%d LEFT=%d\n\r"
,can_armdata0_01,can_armdata0_23,can_armdata0_4,can_armdata0_5,can_armdata0_6,can_armdata0_7,can_armdata1_0,can_armdata1_12);
- }
-
- if(can1.write(CANMessage(8,final_t,1))) { //IDを8にして1バイト送信
- cansend_led = 1;
} else {
cansend_led = 0;
@@ -76,38 +71,35 @@
CANMessage msg;
if(can1.read(msg)) {
- canread_led = 1;
- if(msg.id == 7) { //from ashi
+ if(msg.id == 4) { //from ashi
checkled1 = (msg.data[0]>>7)%2; //-1<now_angle<1 off/on(0 or 1)
checkled2 = (msg.data[0]>>6)%2; //350<now_angle off/on(0 or 1)
checkled3 = (msg.data[0]>>5)%2; //-1<now_x<1 off/on(0 or 1)
checkled4 = (msg.data[0]>>4)%2; //-1<now_y<1 off/on(0 or 1)
- }
-
- if(msg.id == 9) {
- t1 = msg.data[0];
- }
-
- if(msg.id == 10) {
- t2 = msg.data[0];
+ t1 = msg.data[1]; //value of t
+ printf("[0]=%d t1=%d\n\r",msg.data[0],t1);
}
- /*if(msg.id == 11){
- t3 = msg.data[0];
- }*/
-
- else {
- canread_led = 0;
+ if(msg.id == 5) { //from arm
+ t2 = msg.data[0];
+ canread_led = 1;
+ printf("t2 = %d\n\r",t2);
}
+
+ } else {
+ canread_led = 0;
+ printf("not read\n\r");
+ }
- if(t2 >= t3) {
- final_t[0] = t2;
- } else if(t2 < t3) {
- final_t[0] = t3;
- }
+ if(t1 >= t2) {
+ can_ashidata[3] = t1; //from ashi
+ } else if(t1 < t2) {
+ can_ashidata[3] = t2; //from arm
}
+
}
+
void UserLoopSetting()
{
in_right.mode(PullUp);
@@ -270,10 +262,10 @@
}
if(old_button3==0 &&now_button3==1 &&flag3==0) {
- can_armdata0_4 = 0;
+ can_armdata0_4 = 1;
flag3 = 1;
} else if(old_button3==0 &&now_button3==1 &&flag3==1) {
- can_armdata0_4 = 1;
+ can_armdata0_4 = 0;
flag3 = 0;
}
@@ -286,10 +278,10 @@
}
if(old_button4==0 &&now_button4==1 &&flag4==0) {
- can_armdata0_5 = 0;
+ can_armdata0_5 = 1;
flag4 = 1;
} else if(old_button4==0 &&now_button4==1 &&flag4==1) {
- can_armdata0_5 = 1;
+ can_armdata0_5 = 0;
flag4 = 0;
}
@@ -302,10 +294,10 @@
}
if(old_button5==0 &&now_button5==1 &&flag5==0) {
- can_armdata0_6 = 0;
+ can_armdata0_6 = 1;
flag5 = 1;
} else if(old_button5==0 &&now_button5==1 &&flag5==1) {
- can_armdata0_6 = 1;
+ can_armdata0_6 = 0;
flag5 = 0;
}
@@ -318,10 +310,10 @@
}
if(old_button6==0 &&now_button6==1 &&flag6==0) {
- can_armdata0_7 = 0;
+ can_armdata0_7 = 1;
flag6 = 1;
} else if(old_button6==0 &&now_button6==1 &&flag6==1) {
- can_armdata0_7 = 1;
+ can_armdata0_7 = 0;
flag6 = 0;
}
@@ -334,10 +326,10 @@
}
if(old_button7==0 &&now_button7==1 &&flag7==0) {
- can_armdata1_0 = 0;
+ can_armdata1_0 = 1;
flag7 = 1;
} else if(old_button7==0 &&now_button7==1 &&flag7==1) {
- can_armdata1_0 = 1;
+ can_armdata1_0 = 0;
flag7 = 0;
}