本文整理汇总了C++中LSM303::heading方法的典型用法代码示例。如果您正苦于以下问题:C++ LSM303::heading方法的具体用法?C++ LSM303::heading怎么用?C++ LSM303::heading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LSM303
的用法示例。
在下文中一共展示了LSM303::heading方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: task_headingNdist
void task_headingNdist(void* p){
while(1){
//Serial.print("z");
compass.read();
//dprintf("%d mem",(int)freeRAM());
//Serial.print("a");
float heading = compass.heading();
//Serial.print("b");
//dprintf("%d mem2",(int)freeRAM());
//dprintf("%d",(int)compass.a.x);
float ZaVal,XaVal,YaVal,RZaVal;
//ZaVal = compass.a.z/16.0;
XaVal = compass.a.x/16.0;
YaVal = compass.a.y/16.0;
ZaVal = compass.a.z/16.0;
RZaVal = sqrt( ((XaVal*XaVal)+(YaVal*YaVal))/4.0 + (ZaVal*ZaVal));
//ZaVal = sqrt( ((compass.a.x*compass.a.x)+(compass.a.y*compass.a.y))/4.0 + (compass.a.z*compass.a.z));
//ZaVal = ZaVal/16.0;
// dprintf("%d", (int)compass.a.x);
//dprintf("%d", (int)((compass.a.x*compass.a.x)/*+(compass.a.y*compass.a.y)/4.0*/));
// dprintf("%d x %d y %d z", (int)compass.a.x, (int)compass.a.y,(int) compass.a.z);
// dprintf("%d z val",(int) ZaVal);
// dprintf("%d",(int) ZaVal);
//Serial.print("a");
//dprintf("%d",(int)heading);
//dprintf("%d",(int)compass.heading());
//compass.heading();
//Serial.print("b");
//data[ID_DATA_HEADING] = (int) compass.heading();
/* if(ZaVal<-965){
distFromStart+=33; //1 step is 33 cm
step++;
}*/
float currentTime = millis();
if(RZaVal>1000 && (currentTime - prevTime) >= 600){
distFromStart+=33; //1 step is 33 cm
step++;
dprintf("%d_RZaval",(int)RZaVal);
dprintf("%d ",(int)step);
prevTime = currentTime;
}
data[ID_DATA_DIST] = (int) distFromStart;
//dprintf("dist is %d",(int)data[ID_DATA_DIST]);
//dprintf("a");
//delay(100);*/
delay(100);
vTaskDelay(taskDelay);
}
}
示例2: task_poll_sensor
//.........这里部分代码省略.........
delayMicroseconds(10);
digitalWrite(TRIGGER_PIN, LOW);
pinMode(ECHO_PIN,INPUT);
duration = pulseIn(ECHO_PIN, HIGH,100000);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
*/
/*
pinMode(ECHO_PIN,INPUT);
digitalWrite(TRIGGER_PIN,HIGH);
delayMicroseconds(1000);
digitalWrite(TRIGGER_PIN,LOW);
duration = pulseIn(ECHO_PIN,HIGH);
distance = (duration/2)/29.1;*/
/* if(distance>10 && distance < 60){
digitalWrite(MOTOR, HIGH); // sets the LED on
// delay(100); // waits for a second
//digitalWrite(MOTOR, LOW); // sets the LED off
//delay(1000); // waits for a second
}else{
digitalWrite(MOTOR, LOW);
// delay(100);
}*/
// dprintf("%d",(int)distance);
/***********************************
** reading sensors
************************************/
compass.read();
dprintf("%d", int(compass.heading()));
//dprintf("%d z",(int)(compass.a.z/16.0));
/*if(compass.a.z/16.0<-1000){
distFromStart += 33;
step++;
dprintf("%d step",step);
}*/
/* float heading = compass.heading();
float XaVal, YaVal, ZaVal, fXa, fYa,fZa, pitch, roll,pitch_print, roll_print;
const float alpha = 0.15;
XaVal = compass.a.x/16.0; //Acceleration data registers contain a left-aligned 12-bit number, so values should be shifted right by 4 bits (divided by 16)
YaVal = compass.a.y/16.0; //unit is in cm/s2
ZaVal = compass.a.z/16.0;
/***********************************
** keypad
************************************/
char key = keypad.getKey();
//print out the key that is pressed
if (key != NO_KEY){
// Serial.print("You have pressed ");
Serial.println(key);
}
/***********************************
** altitude
************************************/
float pressure = ps.readPressureMillibars() + 248.5;
float altitude = ps.pressureToAltitudeMeters(pressure);
//dprintf("alt %d , pres %d",(int)altitude,(int)pressure);
// Serial.print("Pressure is ");
// Serial.print(pressure);
示例3: printdata
void printdata(void)
{
//Serial.print("!");
#if PRINT_EULER == 1
Serial.print("ANG:");
Serial.print(ToDeg(roll));
Serial.print(",");
Serial.print(ToDeg(pitch));
Serial.print(",");
Serial.print(ToDeg(yaw));
Serial.print(",");
//MAG_Heading = ToDeg(MAG_Heading);
//if(MAG_Heading<0) MAG_Heading= 360+MAG_Heading;
//Serial.print(ToDeg(MAG_Heading));
//Serial.print(",");
// compass.heading((LSM303::vector<int>){0, -1, 0});
Serial.print(compass.heading());
Serial.println();
#endif
#if PRINT_STEPS_DIST==1
calculate();
#endif
#if PRINT_ANALOGS==1
Serial.print(",AN:");
Serial.print(AN[0]); //(int)read_adc(0)
Serial.print(",");
Serial.print(AN[1]);
Serial.print(",");
Serial.print(AN[2]);
Serial.print(",");
Serial.print(AN[3]);
Serial.print (",");
Serial.print(AN[4]);
Serial.print (",");
Serial.print(AN[5]);
Serial.print(",");
Serial.print(c_magnetom_x);
Serial.print (",");
Serial.print(c_magnetom_y);
Serial.print (",");
Serial.print(c_magnetom_z);
#endif
/*#if PRINT_DCM == 1
Serial.print (",DCM:");
Serial.print(convert_to_dec(DCM_Matrix[0][0]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[0][1]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[0][2]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[1][0]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[1][1]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[1][2]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[2][0]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[2][1]));
Serial.print (",");
Serial.print(convert_to_dec(DCM_Matrix[2][2]));
#endif*/
// Serial.println();
}