View difference between Paste ID: LVU6c6GX and UrvdtiWz
SHOW: | | - or go back to the newest paste.
1
component spooler;
2
3
pin in signed min_limit;
4
pin in signed max_limit;
5
pin in float vel_in;
6
pin in signed step_counts;
7
pin out float vel_out;
8
variable int direction;
9
10
function _;
11
license "GPLv2 or later";
12
;;
13
14
FUNCTION(_)
15
{
16-
  if(step_counts <= min_limit){vel_out = vel_in;}
16+
  if(step_counts <= min_limit){direction = 0;}
17-
  if(step_counts >= max_limit){vel_out = -vel_in;}
17+
  if(step_counts >= max_limit){direction = 1;}
18
19
  if(direction) {vel_out = vel_in;}
20
  else {vel_out = -vel_in;}
21
}