-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix missing ACCGYRO custom alignment defines (used in config) #14092
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
Fix missing ACCGYRO custom alignment defines (used in config) #14092
Conversation
Do you want to test this code? You can flash it directly from Betaflight Configurator:
WARNING: It may be unstable. Use only for testing! |
src/main/common/sensor_alignment.h
Outdated
#define CUSTOM_ALIGN_CW90_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 90) | ||
#define CUSTOM_ALIGN_CW180_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 180) | ||
#define CUSTOM_ALIGN_CW270_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 270) | ||
#define CUSTOM_ALIGN_CW0_DEG SENSOR_ALIGNMENT( 0, 0, 0 ) |
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.
I'd keep only 8 basic alignments and use macro for rest:
#define CUSTOM_ALIGN_CW(deg) SENSOR_ALIGNMENT(0, 0, (deg));
#define CUSTOM_ALIGN_CW_FLIP(deg) SENSOR_ALIGNMENT(0, 180, (deg));
#define CUSTOM_ALIGN_CW0_DEG CUSTOM_ALIGN_CW(0)
#define CUSTOM_ALIGN_CW90_DEG_FLIP CUSTOM_ALIGN_CW_FLIP(90)
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.
This would be
// #define CUSTOM_ALIGN_CW0_DEG SENSOR_ALIGNMENT( 0, 0, 0 )
#define CUSTOM_ALIGN_CW90_DEG SENSOR_ALIGNMENT( 0, 0, 90 )
#define CUSTOM_ALIGN_CW180_DEG SENSOR_ALIGNMENT( 0, 0, 180 )
#define CUSTOM_ALIGN_CW270_DEG SENSOR_ALIGNMENT( 0, 0, 270 )
#define CUSTOM_ALIGN_CW0_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 0 )
#define CUSTOM_ALIGN_CW45_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 45 )
// #define CUSTOM_ALIGN_CW90_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 90 )
#define CUSTOM_ALIGN_CW180_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 180 )
#define CUSTOM_ALIGN_CW270_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 270 )
#define CUSTOM_ALIGN_CW(deg) SENSOR_ALIGNMENT( 0, 0, (deg) )
#define CUSTOM_ALIGN_CW_FLIP(deg) SENSOR_ALIGNMENT( 0, 180, (deg) )
#define CUSTOM_ALIGN_CW0_DEG CUSTOM_ALIGN_CW( 0 )
#define CUSTOM_ALIGN_CW90_DEG_FLIP CUSTOM_ALIGN_CW_FLIP( 90 )
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.
It is IMO better to cascade it. That way, it is easier to change CUSTOM_ALIGN internals
#define CUSTOM_ALIGN_CW90_DEG CUSTOM_ALIGN_CW(90)
....
src/main/common/sensor_alignment.h
Outdated
@@ -61,14 +61,22 @@ typedef union sensorAlignment_u { | |||
.yaw = DEGREES_TO_DECIDEGREES(YAW), \ |
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.
Above:
#define SENSOR_ALIGNMENT(ROLL, PITCH, YAW) ((const sensorAlignment_t){\
At least in some situations it generated considerably better code
|
(please don't force-push this PR now - I'm working on PR against your branch) (edited - original version had wrong interpretation) |
Another idea would be to use current defines for filling up SENSOR_ALIGNMENT define |
@haslinghuis : Look at haslinghuis#7 If GYRO_x_ALIGN is defined, it is used to fill both alignment and customAlignment. This should IMO handle intended use and allow easy transition from STD align in code |
@haslinghuis : The code is not tested . |
Agree. Custom defines in first message were not being used. Configuration repository needs update.
|
@ledvinap think best uniform way this should be used as (to simplify configuration):
|
@ledvinap to retain configuration defines in config repository how about #ifndef GYRO_1_ALIGN_ROLL
#define GYRO_1_ALIGN_ROLL 0
#endif
#ifndef GYRO_1_ALIGN_PITCH
#define GYRO_1_ALIGN_PITCH 0
#endif
#ifndef GYRO_1_ALIGN_YAW
#define GYRO_1_ALIGN_YAW 0
#endif
#ifndef GYRO_2_ALIGN_ROLL
#define GYRO_2_ALIGN_ROLL 0
#endif
#ifndef GYRO_2_ALIGN_PITCH
#define GYRO_2_ALIGN_PITCH 0
#endif
#ifndef GYRO_2_ALIGN_YAW
#define GYRO_2_ALIGN_YAW 0
#endif
#define GYRO_1_CUSTOM_ALIGN SENSOR_ALIGNMENT( GYRO_1_ALIGN_ROLL, GYRO_1_ALIGN_PITCH, GYRO_1_ALIGN_YAW )
#define GYRO_2_CUSTOM_ALIGN SENSOR_ALIGNMENT( GYRO_2_ALIGN_ROLL, GYRO_2_ALIGN_PITCH, GYRO_2_ALIGN_YAW )
|
|
|
|
src/main/common/sensor_alignment.h
Outdated
#define CUSTOM_ALIGN_CW90_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 90) | ||
#define CUSTOM_ALIGN_CW180_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 180) | ||
#define CUSTOM_ALIGN_CW270_DEG_FLIP SENSOR_ALIGNMENT( 0, 180, 270) | ||
#define CUSTOM_ALIGN_CW0_DEG SENSOR_ALIGNMENT( 0, 0, 0 ) |
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.
It is IMO better to cascade it. That way, it is easier to change CUSTOM_ALIGN internals
#define CUSTOM_ALIGN_CW90_DEG CUSTOM_ALIGN_CW(90)
....
there are some |
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 for workflow, not tested, only visually reviewed.
@blckmn please approve / review |
* Fix missing ACCGYRO custom alignment defines (used in config) (#14092) * Remove CLKIN pin not available in 4.5 * Update src/main/common/sensor_alignment_impl.h Co-authored-by: Petr Ledvina <ledvinap@gmail.com> --------- Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
but they are not being used
CUSTOM
setting with these settings or use the preset (GYRO_1_ALIGN)