-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GYRO_x_ALIGN_YAW #645
GYRO_x_ALIGN_YAW #645
Conversation
use strict; use warnings; my ($gyro_id, $angle); while (<>) { if (/^#define GYRO_([12])_ALIGN CW(90|180|270)_DEG$/) { $gyro_id = $1; $angle = $2; print; # Print the first line next; } if (defined($gyro_id) && /^#define GYRO_\Q$gyro_id\E_ALIGN_YAW \Q$angle\E0$/) { undef $gyro_id; # Skip the second line if it matches next; } undef $gyro_id; # Reset if no match print; }
This removes simple cases. 80 _FLIP still remaining, but that is manageable manually |
grep -r -Z -l 'GYRO_1_ALIGN ' . | xargs -0 sed -i '/GYRO_1_ALIGN_/d'
grep -r -Z -l 'GYRO_2_ALIGN ' . | xargs -0 sed -i '/GYRO_2_ALIGN_/d' |
BEGIN {undef $/;} s/(^\#define\s+GYRO_([12])_ALIGN\s+CW(90|180|270)_DEG)\n \#define\s+GYRO_\g2_ALIGN_YAW\s+\g3[0] /$1/mx; s/(^\#define\s+GYRO_([12])_ALIGN\s+CW(90|180|270)_DEG_FLIP)\n \#define\s+GYRO_\g2_ALIGN_PITCH\s+1800\n \#define\s+GYRO_\g2_ALIGN_YAW\s+\g3[0] /$1/mx;
fix.pl (ugly, but does the job):
then, in betaflight directory:
|
(better newline handling in perl script) BEGIN {undef $/;} s/(^\#define\s+GYRO_([12])_ALIGN\s+CW(90|180|270)_DEG\n) \#define\s+GYRO_\g2_ALIGN_YAW\s+\g3[0]\n /$1/mxg; s/(^\#define\s+GYRO_([12])_ALIGN\s+CW(90|180|270)_DEG_FLIP\n) \#define\s+GYRO_\g2_ALIGN_PITCH\s+1800\n \#define\s+GYRO_\g2_ALIGN_YAW\s+\g3[0]\n /$1/mxg; s/(^\#define\s+GYRO_([12])_ALIGN\s+CW0_DEG_FLIP\n) \#define\s+GYRO_\g2_ALIGN_PITCH\s+1800\n (?!\#define\s+GYRO_\g2_ALIGN_) /$1/mxg;
|
There are some files with DOS line endings (\r\n), it should be fixed eventually |
OK, I think all trivial case are handled. Rest should be handled individually, based on actual target. |
Roll axis (GYRO_1_ALIGN_ROLL) ??? as this define would make it custom
|
@haslinghuis : I don't see in in last version |
@haslinghuis : FLYFISHRCF405 gyro2 is wrong. With current implementation, CW90_DEG is used and ALIGN_PITCH 900 ignored. But someone should check it (and all other conflicting gyro definitions). I'd fix easy cases and enable ASSERT in accgyro. Affected targets will fail until someone fixes them |
GYRO_1_ALIGN ALIGN_CUSTOM
I think I fixed all trivial cases. Someone should check remaining ones.
|
IMO both should work fine, argument is normalized before use.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- approving, only skimmed over, saw some nice cleanups
use strict;
use warnings;
my ($gyro_id, $angle);
while (<>) {
if (/^#define GYRO_([12])_ALIGN CW(90|180|270)DEG$/) {
$gyro_id = $1;
$angle = $2;
print; # Print the first line
next;
}
if (defined($gyro_id) && /^#define GYRO\Q$gyro_id\E_ALIGN_YAW \Q$angle\E0$/) {
undef $gyro_id; # Skip the second line if it matches
next;
}
undef $gyro_id; # Reset if no match
print;
}