RNP
xxxxxxxxxx
1
alias event = (M:Event, string);
2
alias rudderTrimtabPos = (L:RudderTrimtabPos, number);
3
4
// Handle some events here.
5
if event == 'LeftSingle' {
6
(L:LastPos) = (M:X);
7
}
8
if event == 'WheelUp' {
9
(K:RUDDER_TRIM_RIGHT) = 0;
10
}
11
if event == 'WheelDown' {
12
(K:RUDDER_TRIM_LEFT) = 0;
13
}
14
if event == 'LeftDrag' {
15
if ((M:X, number) - (L:LastPos, number)) > 5 {
16
rudderTrimtabPos += 2;
17
(L:LastPos) = (M:X);
18
}
19
if ((M:X, number) - (L:LastPos, number)) < -5 {
20
rudderTrimtabPos -= 2;
21
(L:LastPos) = (M:X);
22
}
23
}
24
25
macro mapf($n, $inMin, $inMax, $outMin, $outMax) {
26
($n - $inMin) * ($outMax - $outMin) / ($inMax - $inMin) + $outMin
27
}
28
29
/*
30
* A long paragraph explaining in great detail the exact
31
* logic that is performed here. There are some edge cases
32
* that Dave found in the 7th edition of the maintenance
33
* manual that make this code way more complex. Thanks, Dave!
34
*/
35
let throttle = (A:GENERAL ENG THROTTLE LEVER POSITION:#ID#, percent);
36
(L:MY_THROTTLE) = if throttle > 0 {
37
mapf(throttle, 0, 100, 25, 100)
38
} else {
39
mapf(throttle, -20, 100, 0, 25)
40
};
41
42
(L:Hello) = 'hello, world'.toUpperCase();
43
44
if #ID, number# == 1 {
45
// #ID# is 1
46
}
47
48
#MORE_LOGIC#;
RPN
(M:Event, string) 'LeftSingle' scmp 0 == if{
(M:X) (>L:LastPos)
}
(M:Event, string) 'WheelUp' scmp 0 == if{
0 (>K:RUDDER_TRIM_RIGHT)
}
(M:Event, string) 'WheelDown' scmp 0 == if{
0 (>K:RUDDER_TRIM_LEFT)
}
(M:Event, string) 'LeftDrag' scmp 0 == if{
(M:X, number) (L:LastPos, number) - 5 > if{
(L:RudderTrimtabPos, number) 2 + (>L:RudderTrimtabPos, number)
(M:X) (>L:LastPos)
}
(M:X, number) (L:LastPos, number) - -5 < if{
(L:RudderTrimtabPos, number) 2 - (>L:RudderTrimtabPos, number)
(M:X) (>L:LastPos)
}
}
(A:GENERAL ENG THROTTLE LEVER POSITION:#ID#, percent) sp0
l0 0 > if{
l0 0 - 100 25 - * 100 0 - / 25 +
} els{
l0 -20 - 25 0 - * 100 -20 - / 0 +
} (>L:MY_THROTTLE)
'hello, world' uc (>L:Hello)
#ID# 1 == if{
}
#MORE_LOGIC#