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

opi-sunxi-pwm

v0.0.3

Published

Sunxi Orange Pi PWM0 access with Node.js

Downloads

6

Readme

opi-sunxi-pwm

Orange Pi has one PWM pin which is PA5. It is not part of the GPIO pins, but is middle pin of 'Debug TTL UART' interface. This project allows acccess to it with Node.js. Basically this is Node.js wrapper for project: https://github.com/iboguslavsky/pwm-sunxi-opi0.

Contents

Installation

Install pwm-sunxi-opi0 loadable Kernel module

First step is to install 'pwm-sunxi-opi0' loadable Kernel module:

git clone https://github.com/iboguslavsky/pwm-sunxi-opi0.git
cd pwm-sunxi-opi0
make
sudo insmod ./pwm-sunxi-opi0.ko

Once loaded, the following directory structure will be created:

Important Note: Above installation steps are simplified version of original ones as those worked for Orange Pi PC. Original installation includes FEX pin remapping. If current installation does not work, please follow the full installation guide: pwm-sunxi-opi0#Installation. Another side effect of simplified installation is on each restart loadable module is unloaded and has to be loaded with:

sudo insmod ./pwm-sunxi-opi0.ko

Install NPM package

Install NPM package with save to package.json

npm install opi-sunxi-pwm --save

API

enable()

Enables PWM for writing and writes value for entirecycles. Has to be called in order to be able to write values to PWM.

disable()

Disables PWM and cleans up values for entirecycles and activecycles. It is good to be called as clean up after code has finished.

write(percentValue)

Writes to PWM a percent value. It accept decimal values from 0 to 100, where 100 is full power. The bigger entirecycles value is and the more decimal places are given here the finer the control is.

set entireCycles(intValue)

Setter that sets custom value for entirecycles. This is the number of ticks in one PWM period. Accepted values are from 255 to 65355, default value is 1023. The bigger the vaSetter has to be called before enable() in order to take effect.

Usage

Assume that there's an LED on PA5 - middle pin of Debug TTL UART interface. Code bellow make the LED pulse. Every 10ms PWM write is done and write value is increased or decreased.

'use strict';

const pwm = require('../opi-sunxi-pwm.js');
let activeCycle = 0;
let offset = 1;

pwm.enable();

const timeout = setInterval(() => {
  pwm.write(activeCycle);

  activeCycle += offset;
  if (activeCycle >= 100) {
    offset = -1;
  }

  if (activeCycle <= 0) {
    offset = 1;
  }
}, 10);

process.on('SIGINT', () => {
  clearInterval(timeout);
  pwm.disable();
});

There is clean up code in the example which cancels setInterval and disables PWM.