Set the direction of the pin (input or output)

@param int $pin The BCM pin number
@param string $direction The type/direction of the pin - Use GPIO::IN and GPIO::OUT
@param bool $invert Invert the logic so that high->low and low->high
@return bool
503339
public function setDirection(int $pin, string $direction, bool $invert = false): bool
    {
        $this->export($pin);
        system("echo {$direction} > /sys/class/gpio/gpio{$pin}/direction");

        if ($invert) {
            $inverted = intval($invert);
            system("echo {$inverted} > /sys/class/gpio/gpio{$pin}/active_low");
        }

        if (file_exists("/sys/class/gpio/gpio{$pin}/direction") && (file_get_contents("/sys/class/gpio/gpio{$pin}/direction") == $direction)) {
            return true;
        }

        return false;

    }
448575
public function flip($direction)
    {

        $new = imagecreatetruecolor($this->width, $this->height);
        imagealphablending($new, false);
        imagesavealpha($new, true);

        switch (strtolower($direction)) {

            case 'y':
                for ($y = 0; $y < $this->height; $y++) {
                    imagecopy($new, $this->image, 0, $y, 0, $this->height - $y - 1, $this->width, 1);
                }
                break;

            default:
                for ($x = 0; $x < $this->width; $x++) {
                    imagecopy($new, $this->image, $x, 0, $this->width - $x - 1, 0, 1, $this->height);
                }
                break;

        }

        $this->image = $new;

        return $this;

    }
9192
def direction(direction, allow_bi=False):
    
    valid = [Direction.CAUSE, Direction.EFFECT]
    if allow_bi:
        valid.append(Direction.BIDIRECTIONAL)

    if direction not in valid:
        raise ValueError('`direction` must be one of {}'.format(valid))

    return True
439733
protected function setOrderByDirection($direction)
    {
        $direction = strtolower($direction);

        if ($direction == 'desc' || $direction == 'asc') {
            $this->orderByDirection = $direction;
        }
    }
1286014
public function setOffset($offset)
    {
        if ($offset >= PHP_INT_MAX) {
            $offset = false;
        }

        $this->offset = $offset;
        return $this;
    }
583353
public function setDirection($direction)
    {
        if (!in_array($direction, self::$supportedFlipDirection)) {
            throw new \InvalidArgumentException(sprintf(
                    '"%s" Is Not Valid Flip Direction', (string) $direction
            ));
        }
        $this->flipDirection = $direction;

        return $this;
    }
1019592
def set_pin_mode pin, mode
			if ( @pin_modes >> ( pin - 1 )).odd?  && ( mode == :input  ) or
			   ( @pin_modes >> ( pin - 1 )).even? && ( mode == :output ) then

				mask = 0 + ( 1 << ( pin - 1 ))
				@pin_modes ^= mask
			end
		end
1367894
private static void isrCallback(int pin) {
        // dispatch callback to the subscribers for this pin
        List<GpioInterruptCallback> callbacks = isrCallbacks[pin];

        // ensure callbacks collection exists for this pins number
        if(callbacks != null && !callbacks.isEmpty()){
            // iterate over each callback delegate and invoke the callback if the pin and edge type match
            for(GpioInterruptCallback callback : callbacks){
                callback.callback(pin);
            }
        }
    }
1148957
def set_fan_direction(self, direction):
        
        desired_state = {"direction": direction}

        response = self.api_interface.set_device_state(self, {
            "desired_state": desired_state
        })

        self._update_state_from_response(response)
879551
public IBlockState invert(IBlockState state)
	{
		boolean value = !get(state);
		return set(state, value);
	}
1083343
public function sort($direction)
    {
        if (strtolower($direction) === self::DIRECTION_DESC) {
            $this->scanIndexForward = false;
        } else {
            $this->scanIndexForward = true;
        }
    }
1170455
public static INDArray pinvert(INDArray arr, boolean inPlace) {

        // TODO : do it natively instead of relying on commons-maths

        RealMatrix realMatrix = CheckUtil.convertToApacheMatrix(arr);
        QRDecomposition decomposition = new QRDecomposition(realMatrix, 0);
        DecompositionSolver solver = decomposition.getSolver();

        if (!solver.isNonSingular()) {
            throw new IllegalArgumentException("invalid array: must be singular matrix");
        }

        RealMatrix pinvRM = solver.getInverse();

        INDArray pseudoInverse = CheckUtil.convertFromApacheMatrix(pinvRM, arr.dataType());

        if (inPlace)
            arr.assign(pseudoInverse);
        return pseudoInverse;

    }
207124
public function orderBy($key, $direction = 'ASC')
    {
        if (Helpers\Validate::table($this->name)->field($key))
        {
            $directions                        = array(
                'ASC'  => SORT_ASC,
                'DESC' => SORT_DESC
            );
            $this->pending[__FUNCTION__][$key] = isset($directions[$direction]) ? $directions[$direction] : 'ASC';
        }

        return $this;
    }
923605
public void setPin(int pin, boolean active) {
        Buffer buffer = new Buffer();
        buffer.writeIntLe(pin);
        buffer.writeByte(active ? 1 : 0);
        sendMessage(BeanMessageID.BT_SET_PIN, buffer);
    }
74648
public function withDirection(Direction $direction)
    {
        return new static($direction, $this->forced, $this->dryRun, $this->exceptionOnSkip, $this->custom);
    }
62766
protected function getDirection($direction): int
    {
        if (\is_string($direction)) {
            $direction = \strtolower($direction);

            if ($direction === 'desc') {
                $direction = \SORT_DESC;
            } else {
                $direction = \SORT_ASC;
            }
        }

        if (
            $direction !== \SORT_DESC
            &&
            $direction !== \SORT_ASC
        ) {
            $direction = \SORT_ASC;
        }

        return $direction;
    }
1272752
public function readKeys($offset, $direction, $hints = Parser::HINT_NONE)
    {
        // If reading backwards, shift the offset left
        $shiftedOffset = $direction == self::DIRECTION_BACKWARD
                ? $offset - $this->getReadLength()
                : $offset;
        
        //TODO shift to a blocksize chunk
        
        // Don't shift too far
        if ($shiftedOffset < 0) {
            $shiftedOffset = 0;

        }
        
        // Read data
        \fseek($this->index->getFile()->getFilePointer(), $shiftedOffset);
        $data = \fread(
            $this->index->getFile()->getFilePointer(),
            $this->getReadLength()
        );
        if ($data === false) {
            if (\feof($this->index->getFile()->getFilePointer())) {
                return array();

            } else {
                throw new IOIndexException("Could not read file");

            }
        }
        
        // Parse the read data
        $keys = $this->index->getParser()->parseKeys($data, $shiftedOffset, $hints);
        
        // Read more data if no keys were found
        if (empty($keys)) {
            // Only increase if there exists more data
            if ($direction == self::DIRECTION_BACKWARD && $shiftedOffset == 0) {
                return array();
                
            } elseif ($direction == self::DIRECTION_FORWARD
                        && $shiftedOffset + $this->getReadLength()
                           >= $this->index->getFile()->getFileSize()
            ) {
                return array();
                
            }
            
            $this->increaseReadLength();
            return $this->readKeys($offset, $direction);
            
        }
        
        return $keys;
    }