T Nara / R1370

Dependents:   quadOmni_yanagi R1370 gyro_test wheel_test3 wheel_test3 ... more

Fork of R1307 by Wataru Nakata

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers R1370.cpp Source File

R1370.cpp

00001 #include "R1370.h"
00002 
00003 R1370::R1370(PinName Tx,PinName Rx):serial(Tx,Rx)
00004 {
00005     R1370::serial.baud(115200);
00006 }
00007 int R1370::update()
00008 {
00009     int i;
00010     if((data[0]=serial.getc())==0xAA){
00011         for(i = 1;i < 15;i++) {
00012             data[i] = serial.getc();
00013         }
00014         angle = ((data[3]&0xFF)|((data[4]<<8)&0xFF00));
00015         gyro = angle/100.0;
00016         return 0;
00017     }else{
00018         return 1;
00019     }
00020 }
00021 float R1370::getAngle()
00022 {
00023     return gyro;
00024 }