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
Diff: User.cpp
- Revision:
- 1:d15f6e5eda54
- Parent:
- 0:798b73e805d9
- Child:
- 2:817bcbc3431e
--- a/User.cpp Mon Feb 25 01:56:32 2019 +0000
+++ b/User.cpp Sat Mar 02 07:50:03 2019 +0000
@@ -32,8 +32,8 @@
char can_armdata[2]= {0};
int can_ashidata0_01,can_ashidata0_2,can_ashidata0_34,can_ashidata0_5,can_ashidata0_6;
-int can_armdata0_01,can_armdata0_23,can_armdata0_4,can_armdata0_5,can_armdata0_6,can_armdata0_7;
-int can_armdata1_0,can_armdata1_12;
+int can_armdata0_01=0,can_armdata0_23=0,can_armdata0_4=0,can_armdata0_5=0,can_armdata0_6=0,can_armdata0_7=0;
+int can_armdata1_0=0,can_armdata1_12=0,can_armdata1_34=0;
int old_select_state,now_select_state,old_start_state,now_start_state,state_count;
double alpha1,alpha2;
@@ -49,18 +49,24 @@
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};
+
void can_sendread() //割込み使ってない
{
if(can1.write(CANMessage(1,can_ashidata,3))) { //IDを1にして3バイト送信
- cansend_led = 1;
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);
+ ,can_ashidata0_01,can_ashidata0_2,can_ashidata0_34,can_ashidata0_5,can_ashidata0_6);
}
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);
+ ,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;
@@ -73,17 +79,37 @@
canread_led = 1;
if(msg.id == 7) { //from ashi
- checkled1 = (msg.data[0]>>7 | 00000001); //-1<now_angle<1 off/on(0 or 1)
- checkled2 = (msg.data[0]>>6 | 00000001); //350<now_angle off/on(0 or 1)
- checkled3 = (msg.data[0]>>5 | 00000001); //-1<now_x<1 off/on(0 or 1)
- checkled4 = (msg.data[0]>>4 | 00000001); //-1<now_y<1 off/on(0 or 1)
+ 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];
+ }
+
+ /*if(msg.id == 11){
+ t3 = msg.data[0];
+ }*/
+
+ else {
+ canread_led = 0;
+ }
+
+ if(t2 >= t3) {
+ final_t[0] = t2;
+ } else if(t2 < t3) {
+ final_t[0] = t3;
}
}
}
-
void UserLoopSetting()
{
-
in_right.mode(PullUp);
in_left.mode(PullUp);
@@ -147,16 +173,19 @@
fullcolor_r = 1;
fullcolor_b = 1;
can_ashidata0_01 = 2;
+ can_armdata1_34 = 2;
} else if(state_count<0) { //auto mode
fullcolor_g = 1; //green
fullcolor_r = 0;
fullcolor_b = 0;
can_ashidata0_01 = 1;
+ can_armdata1_34 = 1;
} else { //wait mode
fullcolor_g = 0.5; //orange
fullcolor_r = 1;
fullcolor_b = 0;
can_ashidata0_01 = 0;
+ can_armdata1_34 = 0;
}
//-----ジョイスティック&ボタン入力をCANで送る----------------------------------------------------------------------------------------------//
@@ -338,8 +367,8 @@
}
can_armdata[0] = (can_armdata0_01<<6 | can_armdata0_23<<4 | can_armdata0_4<<3 | can_armdata0_5<<2 | can_armdata0_6<<1 | can_armdata0_7);
- can_armdata[1] = (can_armdata1_0<<7 | can_armdata1_12<<5);
- //printf("%d,%d,%d",can_ashidata[0],can_armdata[0],can_armdata[1]);
+ can_armdata[1] = (can_armdata1_0<<7 | can_armdata1_12<<5 | can_armdata1_34<<3);
+ //printf("datasend %d,%d,%d",can_ashidata[0],can_armdata[0],can_armdata[1]);