From e672d23fa3abff61e78f5b72b4a3b050084cba61 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Sun, 30 Nov 2025 02:13:30 -0600 Subject: [PATCH 1/4] Add GitHub Action to suggest maintenance branches for PRs targeting master --- .github/workflows/pr-branch-suggestion.yml | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/pr-branch-suggestion.yml diff --git a/.github/workflows/pr-branch-suggestion.yml b/.github/workflows/pr-branch-suggestion.yml new file mode 100644 index 00000000000..aea758f5a00 --- /dev/null +++ b/.github/workflows/pr-branch-suggestion.yml @@ -0,0 +1,37 @@ +name: PR Branch Suggestion + +on: + pull_request: + types: [opened] + branches: + - master + +jobs: + suggest-branch: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Suggest maintenance branch + uses: actions/github-script@v7 + with: + script: | + const comment = `### Branch Targeting Suggestion + + You've targeted the \`master\` branch with this PR. Please consider if a version branch might be more appropriate: + + - **\`maintenance-9.x\`** - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release. + + - **\`maintenance-10.x\`** - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x + + If \`master\` is the correct target for this change, no action is needed. + + --- + *This is an automated suggestion to help route contributions to the appropriate branch.*`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); From 15fc53ae6aeb68d543ccff4a23b7635434eba7ee Mon Sep 17 00:00:00 2001 From: Sensei Date: Sun, 30 Nov 2025 02:18:42 -0600 Subject: [PATCH 2/4] Update .github/workflows/pr-branch-suggestion.yml Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com> --- .github/workflows/pr-branch-suggestion.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-branch-suggestion.yml b/.github/workflows/pr-branch-suggestion.yml index aea758f5a00..ab233969451 100644 --- a/.github/workflows/pr-branch-suggestion.yml +++ b/.github/workflows/pr-branch-suggestion.yml @@ -29,9 +29,13 @@ jobs: --- *This is an automated suggestion to help route contributions to the appropriate branch.*`; - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: comment - }); + try { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); + } catch (err) { + core.setFailed(`Failed to post suggestion comment: ${err}`); + } From 82021b5e8358826775a71069ffb2885c1dc2a8ed Mon Sep 17 00:00:00 2001 From: Sensei Date: Sun, 30 Nov 2025 02:32:27 -0600 Subject: [PATCH 3/4] Github action change pull_request to pull_request_target event --- .github/workflows/pr-branch-suggestion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-branch-suggestion.yml b/.github/workflows/pr-branch-suggestion.yml index ab233969451..110deb98338 100644 --- a/.github/workflows/pr-branch-suggestion.yml +++ b/.github/workflows/pr-branch-suggestion.yml @@ -1,7 +1,7 @@ name: PR Branch Suggestion on: - pull_request: + pull_request_target: types: [opened] branches: - master From 711d1811f9bda661ed99d154d3b4475bac2f3b73 Mon Sep 17 00:00:00 2001 From: frogmane <7685285+xznhj8129@users.noreply.github.com> Date: Sun, 14 Dec 2025 15:25:30 -0500 Subject: [PATCH 4/4] add arc functions to ipf --- docs/Programming Framework.md | 3 +++ .../javascript_programming/OPERATIONS_REFERENCE.md | 4 ++-- .../api_definitions_summary.md | 2 +- docs/javascript_programming/index.md | 2 +- src/main/programming/logic_condition.c | 14 ++++++++++++++ src/main/programming/logic_condition.h | 3 +++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/Programming Framework.md b/docs/Programming Framework.md index 4233f78487d..e97287c7171 100644 --- a/docs/Programming Framework.md +++ b/docs/Programming Framework.md @@ -119,6 +119,9 @@ for complete documentation on using JavaScript to program your flight controller | 54 | Mag calibration | Trigger a magnetometer calibration. | | 55 | Set Gimbal Sensitivity | Scales `Operand A` from [`-16` : `15`] | 56 | Override Minimum Ground Speed | When active, sets the minimum ground speed to the value specified in `Operand A` [m/s]. Minimum allowed value is set in `nav_min_ground_speed`. Maximum value is `150` | +| 57 | Trigonometry: ACos | Computes ACOS of (`Operand A` / `Operand B`) using the fast approximation. If `Operand B` is `0`, `1000` is used. Input is clamped to [-1, 1] and the result is returned in degrees. | +| 58 | Trigonometry: ASin | Computes ASIN of (`Operand A` / `Operand B`) using the fast approximation. If `Operand B` is `0`, `1000` is used. Input is clamped to [-1, 1] and the result is returned in degrees. | +| 59 | Trigonometry: ATan2 | Computes ATAN2 using `Operand A` as Y and `Operand B` as X with the fast approximation. Returns the angle in degrees. | ### Operands diff --git a/docs/javascript_programming/OPERATIONS_REFERENCE.md b/docs/javascript_programming/OPERATIONS_REFERENCE.md index 3506abd2c56..948a7c7fe92 100644 --- a/docs/javascript_programming/OPERATIONS_REFERENCE.md +++ b/docs/javascript_programming/OPERATIONS_REFERENCE.md @@ -11,7 +11,7 @@ All INAV logic condition operations supported by the firmware are now fully impl ✅ **Arithmetic**: ADD, SUB, MUL, DIV, MODULUS (via +, -, *, /, %) ✅ **Comparisons**: EQUAL, GREATER_THAN, LOWER_THAN, APPROX_EQUAL (via ===, >, <, approxEqual()) ✅ **Logical**: AND, OR, NOT, XOR, NAND, NOR (via &&, ||, !, xor(), nand(), nor()) -✅ **Math**: MIN, MAX, SIN, COS, TAN, ABS (via Math.min/max/sin/cos/tan/abs) +✅ **Math**: MIN, MAX, SIN, COS, TAN, ACOS, ASIN, ATAN2, ABS (via Math.min/max/sin/cos/tan/acos/asin/atan2/abs) ✅ **Scaling**: MAP_INPUT, MAP_OUTPUT (via mapInput(), mapOutput()) ✅ **Flow control**: STICKY, EDGE, DELAY, TIMER, DELTA (via on.* and helper functions) ✅ **Variables**: GVAR_SET, GVAR_INC, GVAR_DEC (via assignments, ++, --) @@ -98,7 +98,7 @@ if (rc[0].low && rc[1].mid && rc[2].high) { - RC channels: `rc[0]` through `rc[17]` (18 channels) - RC channel properties: `.value` (1000-2000us), `.low` (<1333us), `.mid` (1333-1666us), `.high` (>1666us) -- All trig functions (sin/cos/tan) take degrees, not radians +- Trig functions: sin/cos/tan take degrees; acos/asin use ratios (-1..1) and atan2 returns degrees from y/x inputs - MODULUS operator bug fixed: `%` now correctly generates MODULUS operation - MAP_INPUT normalizes to [0:1000], MAP_OUTPUT scales from [0:1000] diff --git a/docs/javascript_programming/api_definitions_summary.md b/docs/javascript_programming/api_definitions_summary.md index 710af423808..2ce71e069d1 100644 --- a/docs/javascript_programming/api_definitions_summary.md +++ b/docs/javascript_programming/api_definitions_summary.md @@ -72,7 +72,7 @@ Waypoint mission data: Math functions: - **Basic**: min, max, abs -- **Trig**: sin, cos, tan (degrees) +- **Trig**: sin, cos, tan (degrees), acos/asin (ratio inputs), atan2 (y, x -> degrees) - **Mapping**: mapInput, mapOutput - **Arithmetic**: add, sub, mul, div, mod (operators) diff --git a/docs/javascript_programming/index.md b/docs/javascript_programming/index.md index 272d344eb7a..d6738d48a78 100644 --- a/docs/javascript_programming/index.md +++ b/docs/javascript_programming/index.md @@ -65,7 +65,7 @@ Comprehensive guide to all INAV logic condition operations: - ✅ Arithmetic: `+`, `-`, `*`, `/`, `%` - ✅ Comparisons: `===`, `>`, `<`, `approxEqual()` - ✅ Logical: `&&`, `||`, `!`, `xor()`, `nand()`, `nor()` -- ✅ Math: `Math.min()`, `Math.max()`, `Math.sin()`, `Math.cos()`, `Math.tan()`, `Math.abs()` +- ✅ Math: `Math.min()`, `Math.max()`, `Math.sin()`, `Math.cos()`, `Math.tan()`, `Math.acos()`, `Math.asin()`, `Math.atan2()`, `Math.abs()` - ✅ Scaling: `mapInput()`, `mapOutput()` - ✅ Flow control: `edge()`, `sticky()`, `delay()`, `timer()`, `whenChanged()` - ✅ Variables: `gvar[0-7]`, `let`, `var` diff --git a/src/main/programming/logic_condition.c b/src/main/programming/logic_condition.c index edba68b8e94..62b799a128d 100644 --- a/src/main/programming/logic_condition.c +++ b/src/main/programming/logic_condition.c @@ -404,6 +404,20 @@ static int logicConditionCompute( return tan_approx(DEGREES_TO_RADIANS(operandA)) * temporaryValue; break; + case LOGIC_CONDITION_ACOS: + temporaryValue = (operandB == 0) ? 1000 : operandB; + return RADIANS_TO_DEGREES(acos_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); + break; + + case LOGIC_CONDITION_ASIN: + temporaryValue = (operandB == 0) ? 1000 : operandB; + return RADIANS_TO_DEGREES(asin_approx(constrainf((float)operandA / (float)temporaryValue, -1.0f, 1.0f))); + break; + + case LOGIC_CONDITION_ATAN2: + return RADIANS_TO_DEGREES(atan2_approx((float)operandA, (float)operandB)); + break; + case LOGIC_CONDITION_MIN: return (operandA < operandB) ? operandA : operandB; break; diff --git a/src/main/programming/logic_condition.h b/src/main/programming/logic_condition.h index 74ea96c98ee..c73a0db4111 100644 --- a/src/main/programming/logic_condition.h +++ b/src/main/programming/logic_condition.h @@ -86,6 +86,9 @@ typedef enum { LOGIC_CONDITION_RESET_MAG_CALIBRATION = 54, LOGIC_CONDITION_SET_GIMBAL_SENSITIVITY = 55, LOGIC_CONDITION_OVERRIDE_MIN_GROUND_SPEED = 56, + LOGIC_CONDITION_ACOS = 57, + LOGIC_CONDITION_ASIN = 58, + LOGIC_CONDITION_ATAN2 = 59, LOGIC_CONDITION_LAST } logicOperation_e;