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

pololu-maestro

v3.1.1

Published

Module to take control of Pololu Maestro servo controllers

Downloads

42

Readme

node-pololumaestro

Dependency Status devDependency Status

This module allows control of the Pololu Maestro range of servo controllers from Node.js allowing your project to interact with the world!

See the API documentation for more information.

Dependencies

This module requires node-serialport in order to communicate with the Maestro, this should be installed automatically.

It also uses Winston for logging.

Installation

Install this module with

npm install pololumaestro

Hacking

Run unit tests with:

npm test

A coverage report should then be available in coverage/lcov-report/index.html

Please submit tests along with new functionality

Usage

Here's a minimal example of how to use the module

var PololuMaestro = require("pololu-maestro");

//create new instance, specifying control com port and optionally the baud rate
var maestro = new PololuMaestro("COM17", 115200);

maestro.on("disconnected", function() {
	// yikes, someone pulled the plug
});

//wait until connection is ready
maestro.on("ready", function() {
	// set target of servo on channel 1 to 1500μs
	maestro.setTarget(1, 1500);

	// set a servo on channel 1 via mini-SSC protocol
	maestro.set8BitTarget(1, 128);

	// set speed of servo on channel 1
	maestro.setSpeed(1, 140);

	// set acceleration of servo on channel 1
	maestro.setAcceleration(1, 128);

	// get the last target value sent to the servo on channel 1
	maestro.getPosition(1, function(position) {
		// position is a number
	});

	// find out if a servo is moving on channel 1
	maestro.getMovingState(1, function(state) {
		// state is a boolean
	});

	// reset all servos to home position
	maestro.reset();

	// read an analog input on channel 1
	maestro.analogRead(1, function(value) {
		// value is a number
	});

	// read a digital input on channel 12
	maestro.digitalRead(12, function(value) {
		// value is a boolean
	});

	// write to a digital output on channel 1
	maestro.digitalWrite(1, true);

	// set PWM channel value
	maestro.setPWM(onTime, period);

	// stop the currently running script
	maestro.stopScript();

	// run subroutine 1
	maestro.restartScriptAtSubroutine(1);

	// run subroutine 1 and read the result
	maestro.restartScriptAtSubroutine(1, function(data) {
		// data is a Buffer - http://nodejs.org/api/buffer.html
	});

	// pass an argument to a subroutine
	maestro.restartScriptAtSubroutineWithParameter(1, 5);

	// pass an argument to a subroute and read the result
	maestro.restartScriptAtSubroutineWithParameter(1, 5, function(data) {
		// data is a Buffer - http://nodejs.org/api/buffer.html
	});

	// find out if any scripts are currently running
	maestro.getScriptStatus(function(status) {
		// status is a boolean
	});

	// close any serial ports the maestro has open
	maestro.close(function() {
		// invoked when serial port(s) are closed
	});
});

// alternatively, attempt to auto-detect:
PololuMaestro.find(PololuMaestro.SERIAL_MODES.USB_DUAL_PORT, function(error, maestro) {
	// ... do something
});

Version history

v3.0.0

  • Breaking change - the callback for PololuMaestro#find now takes arguments error, maestro to be more inline with node conventions
  • Not finding a Maestro no longer causes the process to exit, instead test for the error argument to PololuMaestro#find

v2.1.2

  • Small tweak for OS X Mavericks compatibility

v2.1.1

Updates (contributed by achingbrain):

  • Adds a find method to attempt to auto-detect a connected board

v2.1.0

Updates (contributed by achingbrain):

  • Adds support for USB Dual Port mode
  • Adds generated documentation

v2.0.0

Updates (contributed by achingbrain):

  • Refactored to implement full compact protocol
  • Added unit testing suite

v1.1.0

  • Removed serialport v1.06 dependency to be compatible with node v0.10.x (Thanks achingbrain!)
  • Added a "ready" event to prevent calls to setPWM being made before the serial port is open

Upgrading

N.b. v2.0.0 breaks compatibilty with v1.1.0. To fix up your code, change the setPWM method to setTarget.

So where you were previously setting the target of channel 0 like this:

maestro.setPWM(0, 1500);

You should now use:

maestro.setTarget(0, 1500);