-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Adds calibration offsets for tilt on DJT11LM sensor #6622
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4911,10 +4911,20 @@ const converters1 = { | |
// data[1][bit16..bit31]: y | ||
// data[0][bit0..bit15] : z | ||
// left shift first to preserve sign extension for 'x' | ||
const x = ((data['1'] << 16) >> 16); | ||
const y = (data['1'] >> 16); | ||
let x = ((data['1'] << 16) >> 16); | ||
let y = (data['1'] >> 16); | ||
// left shift first to preserve sign extension for 'z' | ||
const z = ((data['0'] << 16) >> 16); | ||
let z = ((data['0'] << 16) >> 16); | ||
|
||
// raw accelrometer values | ||
result.raw_x=x; | ||
result.raw_y=y; | ||
result.raw_z=z; | ||
|
||
// simple offset calibration | ||
x=calibrateAndPrecisionRoundOptions(x, options, 'raw_x'); | ||
y=calibrateAndPrecisionRoundOptions(y, options, 'raw_y'); | ||
z=calibrateAndPrecisionRoundOptions(z, options, 'raw_z'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to call the options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at other accelerometer based sensors I see we have a set of x,y,z_axis that are exposed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh sorry you were talking about the option name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. renamed the option |
||
|
||
// calculate angle | ||
result.angle_x = Math.round(Math.atan(x/Math.sqrt(y*y+z*z)) * 180 / Math.PI); | ||
|
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.
Why would you still want to have the
raw
values if you have the calibrated ones?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 the only way I found to get the raw values for doing the actual calibration
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.
But you already have the raw values before doing any calibration?
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.
We do have the raw values, but right now, they are not available to users, we use them as is to compute and expose angles.
In order to know what offset to set, we need a way for the user to get the values when the sensor is on a level surface to compensate the values
(eg sensor flat I get "raw_x":60,"raw_y":-13,"raw_z":-704, => I set in the options the offset for x to -60, y to 13
with the sensor on one side : I get "raw_x":-942,"raw_y":-11,"raw_z":225, => offset for z ~ -225 )
so to reiterate as a user in order to find the offsets I need the raw values one way or another
To do an automated calibration witout the raw values, we would have to ask the user to put the device on 2 perpendicular faces, and wait for the values to update between each change, then compute the offsets for each axis and push them in the config or somewhere else, but not sure how to approach this tbh
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.
in the latest iteration, renamed the
raw_x
tox_axis
to follow the other accelerometer sensors .and expose the calibrated values