npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vex4pi

v1.0.1

Published

A JavaScript library allowing the raspberry pi to control VEX motors via the Adafruit Servo/PWM HAT!

Downloads

16

Readme

vex4pi

NPM Version

A JavaScript library allowing the Raspberry Pi to control VEX motors via the Adafruit Servo/PWM HAT!

Disclaimer

  • This library is intended to work only for the Raspberry Pi, and has NOT been tested with other hardware platforms.
  • This library requires a Adafruit Servo/PWM HAT, and will NOT work on direct GPIO.
  • This library only supports VEX Motors at of this release, and has not been tested with other VEX hardware, such as the VEX Servos.

Features

  • Fail-safe error handling (will reset all pin speed values to 0 and close the connection to the PWM/Servo HAT before throwing an error)
  • Full access to all 16 pin outputs on the PWM/Servo HAT
  • Easy to use speed values compared to RobotC code (range from -100 to 100)

Code Example

Let's say we made a simple robot with two motors, one motor controlling the right side of the wheels, and one motor controlling the left side. This code would make the robot go foward at full speed for 5 seconds before stopping. In this example, pin 0 refers to the right motor and pin 1 to the left motor.

const { Vex4Pi } = require('vex4pi');
const { sleep } = require('sleep');

let robot = new Vex4Pi();

// initialize the pins on the robot
robot.init();

// make the robot go full speed ahead
robot.setSpeed(0, 100);
robot.setSpeed(1, -100);

// wait for 5 seconds
sleep(5);

// stop the robot
robot.setSpeed(0, 0);
robot.setSpeed(1, 0);

// free up the pins
robot.deinit();

API Reference

/*
 * Initializes the connection to the PWM/Servo HAT at address `0x40` at `/dev/i2c-1`, and
 * resets all of the pin speed values to 0.
 */
Vex4Pi.init();

/*
 * Resets all of the pin speed values to 0 before gracefully closing the connection with
 * the PWM/Servo HAT.
 */
Vex4Pi.deinit();

/*
 * Sets the `speed` of a motor at the designated `pin` value. Note that the accepted speed
 * values are between -100 and 100, and any value outside that range will be confined into
 * that range (ex. -150 => -100 or 420 => 100). If the init() function has not been called
 * before, or the pin value is not an integer/out of range, this module will throw an error.
 */
Vex4Pi.setSpeed(Integer pin, Integer speed);