slower nrf data rate
This commit is contained in:
parent
e73c0bc69c
commit
719b0fa7c5
|
@ -95,7 +95,8 @@ void setup() {
|
|||
Serial.println("Initializing nrf24");
|
||||
|
||||
radio.begin();
|
||||
|
||||
|
||||
radio.setDataRate( RF24_250KBPS ); //set to slow data rate. default was 1MBPS
|
||||
|
||||
radio.setRetries(15,15); // optionally, increase the delay between retries & # of retries
|
||||
radio.setPayloadSize(8); // optionally, reduce the payload size. seems to improve reliability
|
||||
|
@ -166,13 +167,14 @@ void loop() {
|
|||
//y positive = forward
|
||||
//x positive = right
|
||||
|
||||
/*
|
||||
setYaw+=((int16_t)(lastnrfdata.steer)-NRFDATA_CENTER)*10/127;
|
||||
while (setYaw<0){
|
||||
setYaw+=360;
|
||||
}
|
||||
while (setYaw>=360){
|
||||
setYaw-=360;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
Serial.print("setYaw=");
|
||||
|
@ -190,9 +192,9 @@ void loop() {
|
|||
//out_speed=(int16_t)( (lastnrfdata.y-TRACKPOINT_CENTER)*1000/TRACKPOINT_MAX );
|
||||
//out_steer=(int16_t)( -(lastnrfdata.x-TRACKPOINT_CENTER)*1000/TRACKPOINT_MAX );
|
||||
out_speed=(int16_t)( ((int16_t)(lastnrfdata.speed)-NRFDATA_CENTER)*1000/127 ); //-1000 to 1000
|
||||
//out_steer=(int16_t)( ((int16_t)(lastnrfdata.steer)-NRFDATA_CENTER)*1000/127 );
|
||||
out_steer=(int16_t)( ((int16_t)(lastnrfdata.steer)-NRFDATA_CENTER)*1000/127 );
|
||||
//Test Mag
|
||||
double yawdiff=(setYaw-180)-(yaw-180); //following angle difference works only for angles [-180,180]. yaw here is [0,360]
|
||||
/*double yawdiff=(setYaw-180)-(yaw-180); //following angle difference works only for angles [-180,180]. yaw here is [0,360]
|
||||
yawdiff += (yawdiff>180) ? -360 : (yawdiff<-180) ? 360 : 0;
|
||||
//yawdiff/=2;
|
||||
int yawdiffsign=1;
|
||||
|
@ -204,6 +206,7 @@ void loop() {
|
|||
yawdiff*=yawdiffsign; //redo sign
|
||||
|
||||
out_steer=(int16_t)( yawdiff );
|
||||
*/
|
||||
/*
|
||||
Serial.print("Out steer=");
|
||||
Serial.println(out_steer);*/
|
||||
|
|
Loading…
Reference in New Issue