ezeio2:scriptref:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
ezeio2:scriptref:start [2024-03-01 17:24] andrehezeio2: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 "float" variables to handle fractions     new Float:temp, Float:diff; // Declare "float" variables to handle fractions
 +    new sp = 0;                 // Use sp to find the resulting speed
          
     temp = GetFieldFloat(1);    // Fetch the current temperature from Field 1     temp = GetFieldFloat(1);    // Fetch the current temperature from Field 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) {            // Over setpoint?
         SetOutput(1, 100);      // ..yes, so enable low speed         SetOutput(1, 100);      // ..yes, so enable low speed
 +        sp++;                   // count up our speed result
 +    }
     else     else
         SetOutput(1, 0);        // ..no, so shut off         SetOutput(1, 0);        // ..no, so shut off
                  
-    if(diff > 2.0)              // 2 degrees or more over setpoint?+    if(diff > 2.0) {            // 2 degrees or more over setpoint?
         SetOutput(2, 100);      //..yes, so enable mid-speed         SetOutput(2, 100);      //..yes, so enable mid-speed
 +        sp++;                   // count up our speed result
 +    }
     else     else
         SetOutput(2, 0);         SetOutput(2, 0);
  
-    if(diff > 6.0)              // 6 degrees or more over setpoint?+    if(diff > 6.0) {            // 6 degrees or more over setpoint?
         SetOutput(3, 100);      //..yes, so run full speed         SetOutput(3, 100);      //..yes, so run full speed
 +        sp++;                   // count up our speed result
 +    }
     else     else
         SetOutput(3, 0);         SetOutput(3, 0);
 +        
 +    @Speed = sp;                // Make the speed available to expressions as "@Speed".
 } }
 </code> </code>
  • ezeio2/scriptref/start.txt
  • Last modified: 2026-01-23 21:51
  • by andreh