diff --git a/feature/motheure-simple/source/loop.php b/feature/motheure-simple/source/loop.php index acd6983..bfbd749 100644 --- a/feature/motheure-simple/source/loop.php +++ b/feature/motheure-simple/source/loop.php @@ -8,7 +8,7 @@ $FEATURE = basename(dirname(__DIR__)); - $MOTOR_PIN = 19; + $MOTOR_PIN = [19, 13]; $LOOP_FREQ = 100; // check frequency in ms $THRESHOLD = 4; // maximum number of reads to wait for motor to be active back @@ -26,18 +26,20 @@ /* (1) Motor pin */ global $MOTOR_PIN; - /* [2] Try to read motor state + /* [2] Try to read motor state (for each pin) =========================================================*/ - /* (1) Get its state */ - $STATE = syscall( SOURCE_DIR."/lib/gpio/in $MOTOR_PIN" ); + foreach($MOTOR_PIN as $PIN){ + + /* (1) Get its state */ + $STATE = syscall( SOURCE_DIR."/lib/gpio/in $MOTOR_PIN" ); + + /* (2) If at least one active return TRUE */ + if( $STATE === true ) + return true; - /* (3) If active, pass */ - if( $STATE === true ){ - return true; } - /* (4) Return FALSE means motor inactive */ - // slog('read: 0', 'motheure-simple:loop', 'motheure'); + /* (3) Return FALSE means every motor is inactive */ return false; } @@ -53,10 +55,7 @@ /* (1) Log history file descriptor */ global $f_data; - /* (2) Motor pin */ - global $MOTOR_PIN; - - /* (3) Loop data */ + /* (2) Loop data */ global $start_ts; global $LOOP_FREQ; global $THRESHOLD;