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

ev3-client

v0.1.59

Published

Client for rtm-api

Downloads

65

Readme

ev3-client

Build status Git tag NPM version Code style

Client for rtm-api

Installation

npm install ev3-client

Usage

let {robot, move, read, sleep, motor} = require('ev3-client') //expose ev3-client methods
var run = robot('ip address of websocket server') // connect to robot

var steer = move('b', 'c') // set drive motors to ports b and c
var motor1 = motor('a') // set arm motor to port a

run(function * () {
  var devices = yield read() // read sensor data
  var dist = devices.sonic(1) // get distance reading from ultrasonic sensor in port 1

  if (dist < 10) {
    yield steer.rotations(-1, 40, 0) // move one rotation backward
  } else {
    yield steer.rotations(1, 40, 0) // move one rotation forward
  }
  yield sleep(1000) // wait for 1 second
  yield motor1.degrees(90, 40) // spin motor in port a 90 degrees
})

API

robot(str)

  • str - string containing the ip address of the ev3 server

Returns a runner for ev3 actions

move(leftPort, rightPort)

  • leftPort - port letter of the left motor. defaults to 'b'.
  • rightPort - port letter of the right motor. defaults to 'c'.

Returns: object of move functions

.forever(speed, turn)

Run both motors until they receive a stop command.

  • speed - number between 0 and 100 to control the speed at which to run the motors
  • turn - number between -100 and 100 to denote amount of turning. -100 is maximum left turn. 0 is straight. 100 is maximum right turn.

.degrees(degrees, speed, turn)

Run both motors for a number of degrees with the ability to turn.

  • degrees - number of degrees for the motor to spin
  • speed - number between 0 and 100 to control the speed at which to run the motors
  • turn - number between -100 and 100 to denote amount of turning. -100 is maximum left turn. 0 is straight. 100 is maximum right turn.

.rotations(rotations, speed, turn)

Run both motors with a number of degrees the ability to turn.

  • rotations - number of rotations for the motor to spin
  • speed - number between 0 and 100 to control the speed at which to run the motors
  • turn - number between -100 and 100 to denote amount of turning. -100 is maximum left turn. 0 is straight. 100 is maximum right turn.

.timed(time, speed, turn)

Run both motor for a specified amount of time.

  • time - time in milliseconds
  • speed - number between 0 and 100 to control the speed at which to run the motors
  • turn - number between -100 and 100 to denote amount of turning. -100 is maximum left turn. 0 is straight. 100 is maximum right turn.

.stop()

Stop both motors.

read()

Read the data from all devices connected to the robot

Returns Object to access sensor data

.touch(port)

Reads the state of the touch sensor

  • port - the port the touch sensor is plugged in to

Return Number

value | meaning ---|--- 0 | Not pressed 1 | Pressed

.sonic(port)

Reads the value of the ultrasonic sensor (defaults to inches)

  • port - the port the touch sensor is plugged in to

Returns Number

.color(port)

Reads the value of the color sensor (defaults to color)

  • port - the port the touch sensor is plugged in to

Returns Number

value | meaning ---|--- 0 | no color 1 | black 2 | blue 3 | green 4 | yellow 5 | red 6 | white 7 | brown

.ir(port)

Reads the value of the infrared sensor (defaults to seek mode)

  • port - the port the touch sensor is plugged in to

Returns Object

{
  heading1: heading towards beacon with channel 1,
  distance1: distance towards beacon with channel 1,
  heading2: heading towards beacon with channel 2,
  distance2: distance towards beacon with channel 2
}

.motor(port)

Read the state of the motor

  • port - the port the motor is plugged in to

motor(port)

  • port - port letter of the motor. defaults to 'a'.

Returns: object of move functions

These function are exactly the same as the motors function but without the turn parameter.

sleep(ms)

Pause execution for an amount of time

  • ms - Time to pause execution in milliseconds

license

MIT