Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| ezeio2:scriptref:start [2024-03-01 17:24] – andreh | ezeio2:scriptref:start [2026-01-23 21:51] (current) – andreh | ||
|---|---|---|---|
| Line 108: | Line 108: | ||
| <code javascript> | <code javascript> | ||
| + | new @Speed; | ||
| + | |||
| main() | main() | ||
| { | { | ||
| Line 116: | Line 118: | ||
| { | { | ||
| new Float:temp, Float:diff; // Declare " | new Float:temp, Float:diff; // Declare " | ||
| + | new sp = 0; // Use sp to find the resulting speed | ||
| | | ||
| temp = GetFieldFloat(1); | temp = GetFieldFloat(1); | ||
| diff = temp - 20.5; // 20.5 is our setpoint. diff is the differece | diff = temp - 20.5; // 20.5 is our setpoint. diff is the differece | ||
| | | ||
| - | if(diff > 0.0) // Over setpoint? | + | if(diff > 0.0) { |
| SetOutput(1, | SetOutput(1, | ||
| + | sp++; // count up our speed result | ||
| + | } | ||
| else | else | ||
| SetOutput(1, | SetOutput(1, | ||
| | | ||
| - | if(diff > 2.0) // 2 degrees or more over setpoint? | + | if(diff > 2.0) { |
| SetOutput(2, | SetOutput(2, | ||
| + | sp++; // count up our speed result | ||
| + | } | ||
| else | else | ||
| SetOutput(2, | SetOutput(2, | ||
| - | if(diff > 6.0) // 6 degrees or more over setpoint? | + | if(diff > 6.0) { |
| SetOutput(3, | SetOutput(3, | ||
| + | sp++; // count up our speed result | ||
| + | } | ||
| else | else | ||
| SetOutput(3, | SetOutput(3, | ||
| + | | ||
| + | @Speed = sp; // Make the speed available to expressions as " | ||
| } | } | ||
| </ | </ | ||