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.
Fork of 2015robot_main by
Diff: communicate.h
- Revision:
- 4:51d87d2b698c
- Parent:
- 2:cf8ca6742db9
- Child:
- 5:8d53b2b2fe91
- Child:
- 8:1638e8c8ca93
--- a/communicate.h Mon Aug 31 04:10:00 2015 +0000 +++ b/communicate.h Sat Sep 05 04:27:19 2015 +0000 @@ -1,11 +1,19 @@ /***RS485 Communication.***/ + Serial RS485(RS485_TX, RS485_RX); +inline void sendData(int address, int data5) { + unsigned int data; + if (data5 <= 31) { + data = ((address << 5) | data5); + RS485.putc(data); + } +} /***Get state ps3con.***/ Serial SBDBT(SBDBT_TX, SBDBT_RX); #define ps3_start 0x80 short square=0,triangle=0,circle=0,cross=0,up=0,down=0,right=0,left=0,l1=0,l2=0,r1=0,r2=0; -int analog_lx=0,analog_ly=0,analog_rx=0,analog_ry=0; +int analog_lx=64,analog_ly=64,analog_rx=64,analog_ry=64; int ps3_data[7]; int count=0; int sample=0; @@ -33,7 +41,17 @@ analog_ly=ps3_data[3]; analog_rx=ps3_data[4]; analog_ry=ps3_data[5]; - if(!circle) edge=1; + if(!circle) edge_circle=1; + if(!triangle) edge_triangle=1; + if(!r1) edge_r1=1; + if(!l1) edge_l1=1; + /*if(!(analog_ry<40)) edge_r_up=1; + if(!(analog_ry>90)) edge_r_down=1; + if(!(analog_ly<40)) edge_l_up=1; + if(!(analog_ly>90)) edge_l_down=1;*/ + if(!edge_right) edge_right=1; + if(!edge_left) edge_left=1; + if(!edge_up) edge_up=1; } ///interrupt SBDBT RX. inline void SBDBT_interrupt()