-
Notifications
You must be signed in to change notification settings - Fork 701
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
CAT-1316 Sensor-type to GAMING; LIN.ACC.- and ROT.VECT. (inclin.,… #1325
Conversation
private float linearAcceleartionX = 0f; | ||
private float linearAcceleartionY = 0f; | ||
private float linearAcceleartionZ = 0f; | ||
private float[] accelerationXYZ = new float [3]; |
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.
Extraneous space between float
and [3]
.
Please run the formatter on your files, there's quite a few formatting errors. |
Everything works fine now on Moto G1. |
@aried3r: formatter run. Didn't think of it - but last time I ran the formatter @obusher had something against it:
I generally understand that - but it wouldn't be a problem when the formatter would be run automagically in every Android Studio on save - so the format wouldn't deteriorate in the first place. @martinbu: Thanks for your help finding my copy/paste error - now the values in the Compute-Dialog in the formula-editor are correctly updated 👍 |
edit: Dangle-it, @aried3r was faster! 😔 JFI: The comment you quoted is outdated |
@aried3r : that's cool thanks - haven't tried committing from Android Studio yet. |
Is there a way to have Jenkins run this and report back within a few minutes? If this isn't already the case. I don't want to comment every PR because of these things. It seems GitHub can list multiple test runs on PRs. See here for an example. |
There is already an experimental jenkins job waiting to replace the current Catroid-Build-SourceTests-StaticChecks job. The new one will abort the complete PR testrun if there are any pmd, checkstyle or lint warnings. So, if a jenkins testrun takes only a few minutes, which you can check even without a jenkins account, it highly indicates new static code analyzing warnings. I'll ping you if the new job has been activated.
Thanks for the tip! I like it and I'll write a (low priority) ticket for it. 😸 |
164e46b
to
3c0530e
Compare
|
||
case COMPASS_DIRECTION: | ||
float[] orientations = new float[3]; | ||
android.hardware.SensorManager.getRotationMatrixFromVector(instance.rotationMatrix, | ||
instance.rotationVector); | ||
if (!instance.useRotationVectorFallback) { |
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.
what happens here if useRotationVectorFallback is true? correct me if I'm wrong, but if there is no getRotationMatrixFromVector then the rotationMatrix is not initialised and hence you won't get any reasonable results anyway.
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.
Hi!
If the useRotatitonVectorFallback is true - then the rotatiton-matrix is NOT obtained from the RotationVectorSensor (because this does not exist in this phone) but determined by means of the getRotationMatrix(float[],float[],float[],float[]) with accelerometer data AND macgnetic field data in line 303 in the onSensorChanged(...) method - when the MagneticField Sensor is present.
If NEITHER rotation-matrix sensor NOR magnetic field sensor are present compass direction does not work on this phone.
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.
all right! got it! obviously I hadn't understood it properly before, thank you for clearing that up.
apart from the question regarding the compass direction the PR looks fine. any objections against merging it as soon as this has been cleared up? @robertpainsi @martinbu ? |
float rawInclinationX = RADIAN_TO_DEGREE_CONST * (float) (Math.acos(instance.accelerationXYZ[0])); | ||
float correctedInclinationX = 0; | ||
|
||
// X-inclination: turn right direction |
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 don't think the comments are necessary.
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.
true
removed the two comments |
retest this please |
correctedInclinationX = -(180 + (90 - rawInclinationX)); | ||
} | ||
} else | ||
if (rawInclinationX >= 0 && rawInclinationX < 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.
That's an interesting case of else-if coding style...
Do you read it as else { if (...
(because a else block doesn't require braces) or as else if (...
?
However, let's see what the android studio formatter does! 😉
Also removing comments, as suggested by @thmq, does not always end up by just removing them. Please take a look at Clean Code, "Don't use a comment when you can use a function or variable".
However, I prefer this example
// Bad:
// Check to see if the employee is eligible for full benefits
if ((employee.flags & HOURLY_FLAG) && (employee.age > 65))
// Good:
if (employee.isEligibleForFullBenefits())
@robertpainsi 's right about this. you should try to keep your code as well legible as possible. besides there seems to be a problem with the sensor test [1]. |
retest this please |
…ass-dir) sensor fallback
@thmq damn this test uses "reflection"! So this happens when correcting variable-names AFTER running the "final" tests which uses "reflection". 🙀 Shame on me that I didn't have a look at the test - so I would have known. |
I will merge this because the Release is urgent, but you will have to refactor Btw: I will cherry-pick this commit into master |
…compass-dir) sensor fallback