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:
- 2:cf8ca6742db9
- Parent:
- 0:bd4719e15f7e
- Child:
- 3:5266af49834f
- Child:
- 4:51d87d2b698c
--- a/communicate.h Mon Aug 31 00:25:25 2015 +0000 +++ b/communicate.h Mon Aug 31 04:10:00 2015 +0000 @@ -9,10 +9,12 @@ int ps3_data[7]; int count=0; int sample=0; -inline void data_clear(){ - for(int i=0;i<7;i++) ps3_data[i]=0; +inline void data_clear() +{ + for(int i=0; i<7; i++) ps3_data[i]=0; } -inline void data_check(){ +inline void data_check() +{ square=0,triangle=0,circle=0,cross=0,up=0,down=0,right=0,left=0,l1=0,l2=0,r1=0,r2=0; analog_lx=0,analog_ly=0,analog_rx=0,analog_ry=0; if((ps3_data[0]==0x00)&&(ps3_data[1]==0x01)) up=1; @@ -34,18 +36,20 @@ if(!circle) edge=1; } ///interrupt SBDBT RX. -inline void SBDBT_interrupt(){ +inline void SBDBT_interrupt() +{ sample=SBDBT.getc(); if(count==7) data_clear(); if(sample==ps3_start) count=0; - else{ + else { ps3_data[count]=sample; count++; } if(count==6) data_check(); } -inline void initializeSBDBT(){ - for(int i=0;i<7;i++) ps3_data[i]=0; +inline void initializeSBDBT() +{ + for(int i=0; i<7; i++) ps3_data[i]=0; SBDBT.baud(2400); SBDBT.format(8, Serial::None, 1); SBDBT.attach(SBDBT_interrupt, Serial::RxIrq);