-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Trim acc #457
Trim acc #457
Conversation
Add new Page: title = "Trim Accelerometer", script = "acc_calibrate.lua"
Add Page to Trim Accelerometer: MSP_ACC_TRIM MSP_SET_ACC_TRIM { "acc_trim_pitch", VAR_INT16 | MASTER_VALUE, .config.minmax = { -300, 300 }, PG_ACCELEROMETER_CONFIG, offsetof(accelerometerConfig_t, accelerometerTrims.values.pitch) }, { "acc_trim_roll", VAR_INT16 | MASTER_VALUE, .config.minmax = { -300, 300 }, PG_ACCELEROMETER_CONFIG, offsetof(accelerometerConfig_t, accelerometerTrims.values.roll) },
local labels = {} | ||
local fields = {} | ||
|
||
if apiVersion >= 1.041 then |
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.
if apiVersion >= 1.041 then | |
if apiVersion >= 1.16 then |
@@ -0,0 +1,30 @@ | |||
|
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.
Don't want this
local labels = {} | ||
local fields = {} | ||
|
||
if apiVersion >= 1.041 then |
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.
These values have been available through msp in betaflight since msp api version 1.16(we had msp over telemetry since then) so this conditional is not needed.
We only need conditionals like this in the page file itself if parameters are removed/added to the message along the way.
In this case the only conditional needed is the one in "pages.lua" that makes the whole page conditional to msp api version 1.16
What would happen here is that for api versions lower than 1.41 the page would still be accessible, but would be empty.
if apiVersion >= 1.041 then | ||
labels[#labels + 1] = { t = "Trim Accelerometer" , x = x, y = inc.y(lineSpacing) } | ||
fields[#fields + 1] = { t = "acc trim pitch", x = x, y = inc.y(lineSpacing), sp = x + sp, min = -300, max = 300, vals = { 1 } } | ||
fields[#fields + 1] = { t = "acc trim roll", x = x, y = inc.y(lineSpacing), sp = x + sp, min = -300, max = 300, vals = { 2 } } |
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.
Too much indent.
The field text could also be just "Pitch" and "Roll" since the "Trim Accelerometer" header explains it all. These should also be indented. "x = x + indent" for both of these. Look at the other pages to see how we usually do it.
This won't work as it should. both pitch and roll trim are 16 bit values so for pitch it should be "vals = { 1, 2 }" and for roll "vals = { 3, 4 }". Have a look at the MSP_ACC_TRIM" message in the BF source code. 🙂
src/SCRIPTS/BF/pages.lua
Outdated
@@ -56,4 +56,8 @@ if apiVersion >= 1.41 then | |||
PageFiles[#PageFiles + 1] = { title = "GPS PIDs", script = "gpspids.lua" } | |||
end | |||
|
|||
if apiVersion >= 1.16 then | |||
PageFiles[#PageFiles + 1] = { title = "Trim Accelerometer", script = "acc_calibrate.lua" } |
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.
maybe "acc_trim.lua" would be a more appropriate filename since we already have similarly named files to calibrate the accelerometer.
title = "ACC", | ||
reboot = true, | ||
eepromWrite = true, | ||
minBytes = 1, |
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.
For this message we need at least 4 bytes to be able to do anything.
read = 240, -- MSP_ACC_TRIM | ||
write = 239, -- MSP_SET_ACC_TRIM | ||
title = "ACC", | ||
reboot = true, |
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.
Is a reboot needed for the trim to take effect?
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 know if it's needed. How can I test this?
Thx for all the other informations it's my fist commit,didnt know all the thinks only test it and it works 😉.
What happens if I do Wirte only 1 instead of 1, 2 due to 16 bit?
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.
"reboot = false". Then try making some changes, save the page and see if it took effect 🙂
What happens is that the pitch field will modify the first byte of pitch trim and the roll field will modify the second byte of pitch trim. So the roll field will make unintended changes to pitch trim, and you won't be able to change roll trim at all
1.remove first line 2. remove: if apiVersion >= 1.041 then ... 3. fix indent 4. add: x = x + indent 5. change name acc_calibrate.lua --> acc_trim.lua 6. reboot = false, 7. minBytes = 4, 8. fix vals
remove due to name change
Fixed all points and tested it. Worked for me. |
Negative values doesn't display properly. We haven't had to deal with negative values in the bf lua scripts until now so everything is treated as unsigned. We'll have to look into that |
src/SCRIPTS/BF/PAGES/acc_trim.lua
Outdated
labels[#labels + 1] = { t = "Trim Accelerometer", x = x, y = inc.y(lineSpacing) } | ||
fields[#fields + 1] = { t = "Pitch", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = -300, max = 300, vals = { 1, 2 } } | ||
fields[#fields + 1] = { t = "Roll", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = -300, max = 300, vals = { 3, 4 } } |
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.
Looks like you're using tabs here. use spaces to align things.
Change Tab to Space
Ok yes I also so this this -1 ore <=-1, do you have an Idea where we have to change the code to get this working. Is there any way ob debuggin? |
Ok now the problem with negativ values is fixed. I do not exactly know there the limit is by switching to negativ calculation so I selected 65000 because this will never reached from -300 to 300 |
@druckgott I think it's better if we handle this in a more generic way. See #458 |
ok I removed it again and if your fix is done then it should be fine. |
Looks good to me. You just need to squash to one commit now 👍 |
How can I squash to one commit now? |
|
Mhh I cant get it working. I did all the things bevor online direct on github.com and not with git clone .... |
Just make a new PR |
Did a new one: |
Added A new Page fro Trim Accelerometer