jairo
Dependencies: R1370 SerialMultiByte
Fork of R1370sample by
Revision 1:022a516e4765, committed 2018-10-02
- Comitter:
- skouki
- Date:
- Tue Oct 02 10:44:08 2018 +0000
- Parent:
- 0:f94834989686
- Commit message:
- jairo
Changed in this revision
--- a/R1370.lib Fri Aug 24 04:38:58 2018 +0000 +++ b/R1370.lib Tue Oct 02 10:44:08 2018 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/R1370/#243364135087 +https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/R1370/#08ff7c46665f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SerialMultiByte.lib Tue Oct 02 10:44:08 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/NHK-Robocon2016_Nagaoka_B_Team/code/SerialMultiByte/#4109001829fe
--- a/main.cpp Fri Aug 24 04:38:58 2018 +0000 +++ b/main.cpp Tue Oct 02 10:44:08 2018 +0000 @@ -1,17 +1,33 @@ -#include "mbed.h" -#include "R1370.h" - -R1370 r1370(PC_10, PC_11); -Serial pc(USBTX, USBRX, 230400); -DigitalOut led1(LED1); +#include"R1370.h" +#include"mbed.h" +#include"SerialMultiByte.h" +Serial pc(USBTX,USBRX,115200); +R1370 r1370(PC_10,PC_11); +SerialMultiByte mboard(PC_12,PD_2); +double angle; +uint8_t tx_data[10]; +int angle_original; +int main(){ + mboard.baud(115200); + mboard.setHeaders('H','Z'); + while(1){ + angle = r1370.getAngle(); + angle = angle * 100.000; + angle_original = angle; + angle = abs(angle); + int angle_ = angle; -// main() runs in its own thread in the OS -int main() { - while (true) { - led1 = !led1; - pc.printf("ANGLE:<%3.4fdegrees>", r1370.getAngle()); - pc.printf(" RATE:<%3.4fdegrees>", r1370.getRate()); - pc.printf(" ACC:<%4d, %4d, %4d>\r\n", r1370.getAcc('x'), r1370.getAcc('y'), r1370.getAcc('z')); - } -} + tx_data[0] = angle_ >> 8; + tx_data[1] = angle_ & 0xff; + if(angle_original < 0.0){ + tx_data[0] = tx_data[0] + 128; + } + mboard.sendData(tx_data,2); + int data = ((tx_data[0] << 8 )| tx_data[1]); + if(tx_data[0] >= 128) + data = ((data - 32768) * -1); + pc.printf("%d-%d-%d\n\r",data,tx_data[0],tx_data[1]); + + } +} \ No newline at end of file
--- a/mbed-os.lib Fri Aug 24 04:38:58 2018 +0000 +++ b/mbed-os.lib Tue Oct 02 10:44:08 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#f8b140f8d7cb226e41486c5df66ac4f3ce699219 +https://github.com/ARMmbed/mbed-os/#835fabe557aabc3f8ec5d3fc1163fec757fbbe48