Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/javascript_programming/OPERATIONS_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,31 @@ const altitudePercent = mapOutput(mapInput(inav.flight.altitude, 5000), 100);

```javascript
// LOW state - RC value < 1333us
if (inav.rc[0].low) {
if (inav.rc[1].low) {
// Roll stick is in low position
inav.gvar[0] = 1;
}

// MID state - RC value between 1333-1666us
if (inav.rc[1].mid) {
if (inav.rc[2].mid) {
// Pitch stick is centered
inav.gvar[1] = 1;
}

// HIGH state - RC value > 1666us
if (inav.rc[2].high) {
if (inav.rc[3].high) {
// Throttle stick is in high position
inav.override.vtx.power = 4;
}

// Access raw RC value
if (inav.rc[3].value > 1700) {
if (inav.rc[4].value > 1700) {
// Custom threshold on yaw channel
inav.gvar[2] = 1;
}

// Combined with logical operations
if (inav.rc[0].low && inav.rc[1].mid && inav.rc[2].high) {
if (inav.rc[1].low && inav.rc[2].mid && inav.rc[3].high) {
// Specific stick combination detected
inav.override.armSafety = 1;
}
Expand All @@ -99,7 +99,7 @@ if (inav.rc[0].low && inav.rc[1].mid && inav.rc[2].high) {

## Notes

- RC channels: `rc[0]` through `rc[17]` (18 channels)
- RC channels: `rc[1]` through `rc[34]`. Channel numbers start at 1, as in the receiver tab.
- RC channel properties: `.value` (1000-2000us), `.low` (<1333us), `.mid` (1333-1666us), `.high` (>1666us)
- Trig functions: sin/cos/tan take degrees; acos/asin use ratios (-1..1) and atan2 returns a signed angle in (-180, 180] degrees from y/x inputs
- MODULUS operator bug fixed: `%` now correctly generates MODULUS operation
Expand Down
6 changes: 3 additions & 3 deletions docs/javascript_programming/TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ Expected: Error with suggestion for correct property
### 3. Edge Cases
```javascript
// Test boundary values
if (inav.rc[0].low) { // Channel 0 (first)
if (inav.rc[1].low) { // Channel 1 (first)
inav.gvar[0] = 1;
}

if (inav.rc[17].high) { // Channel 17 (last valid)
if (inav.rc[34].high) { // Channel 34 (last valid)
inav.gvar[1] = 1;
}

Expand All @@ -155,7 +155,7 @@ Expected: Valid generation for both
### 4. Complex Combinations
```javascript
// Test multiple operations together
if (xor(inav.rc[0].low, inav.flight.armed)) {
if (xor(inav.rc[1].low, inav.flight.armed)) {
inav.gvar[0] = Math.max(100, inav.flight.altitude);
}

Expand Down
4 changes: 2 additions & 2 deletions docs/javascript_programming/api_definitions_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Contains override operations:
### 3. ✅ **rc.js** - RC Receiver Channels (READ-ONLY)
**Source**: RC channel handling in firmware

18 RC channels (rc[0] through rc[17]), each with:
34 RC channels (rc[1] through rc[34]), each with:
- `value`: Raw channel value (1000-2000µs)
- `low`: Channel < 1333µs
- `mid`: Channel 1333-1666µs
Expand Down Expand Up @@ -98,7 +98,7 @@ Combines all definitions into single object.
|------|--------|-------|----------|-------|
| flight.js | ✅ Ready | ~250 | FLIGHT(0-44) | All flight parameters |
| override.js | ✅ Ready | ~150 | OPS(23-46) | All override operations |
| rc.js | ✅ Ready | ~80 | RC(0-17) | 18 RC channels |
| rc.js | ✅ Ready | ~80 | RC(1-34) | 34 RC channels |
| gvar.js | ✅ Ready | ~30 | GVAR(0-7) | 8 global variables |
| waypoint.js | ✅ Ready | ~80 | WAYPOINT(0-8) | Waypoint nav data |
| pid.js | ✅ Ready | ~70 | PID(0-3) | 4 PID controllers |
Expand Down
2 changes: 1 addition & 1 deletion docs/javascript_programming/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Instructions for:
- `var` variables: allocated to global variables
- Ternary operator: `condition ? value1 : value2`
- Arrow functions: `() => condition`
- Object property access: `inav.flight.altitude`, `inav.rc[0].value`
- Object property access: `inav.flight.altitude`, `inav.rc[1].value`
- Binary expressions: `+`, `-`, `*`, `/`, `%`
- Comparison operators: `>`, `<`, `===`
- Logical operators: `&&`, `||`, `!`
Expand Down
Loading