@embedded/led
Advanced tools
Comparing version 0.0.4 to 0.0.5
72
led.js
@@ -0,1 +1,3 @@ | ||
import {normalizeParams} from "@embedded/fn"; | ||
/** | ||
@@ -11,2 +13,3 @@ * Led | ||
#io; | ||
#state = { | ||
@@ -23,11 +26,14 @@ isAnode: false, | ||
constructor(opts) { | ||
constructor(io, pin) { | ||
if (!opts.io) opts = { io: opts }; | ||
const {ioOpts, deviceOpts} = normalizeParams(io, pin); | ||
this.io = opts.io; | ||
this.#io = new ioOpts.io({ | ||
pin: ioOpts.pin, | ||
mode: ioOpts.io.Output | ||
}); | ||
this.LOW = 0; | ||
if (this.io.resolution) { | ||
this.HIGH = (1 << this.io.resolution()) -1; | ||
if (ioOpts.io.resolution) { | ||
this.HIGH = (1 << ioOpts.io.resolution()) -1; | ||
} else { | ||
@@ -72,28 +78,5 @@ this.HIGH = 1; | ||
on() { | ||
this.#state.value = 1; | ||
/*if (state.mode === this.io.MODES.PWM) { | ||
// Assume we need to simply turn this all the way on, when: | ||
// ...state.value is null | ||
if (state.value === null) { | ||
state.value = 255; | ||
} | ||
// ...there is no active interval | ||
if (!state.interval) { | ||
state.value = 255; | ||
} | ||
// ...the last value was 0 | ||
if (state.value === 0) { | ||
state.value = 255; | ||
} | ||
}*/ | ||
this.io.write(this.HIGH); | ||
this.#state.value = this.HIGH; | ||
this.#io.write(this.HIGH); | ||
return this; | ||
} | ||
@@ -105,4 +88,4 @@ | ||
off() { | ||
this.#state.value = 0; | ||
this.io.write(this.LOW); | ||
this.#state.value = this.LOW; | ||
this.#io.write(this.LOW); | ||
return this; | ||
@@ -119,4 +102,2 @@ } | ||
//strobe | ||
/** | ||
@@ -177,28 +158,5 @@ * blink | ||
}; | ||
/** | ||
* Add an animation segment to the animation queue | ||
* @param {Object} options Options: cuePoints, keyFrames, duration, | ||
* easing, loop, metronomic, progress, fps, onstart, onpause, | ||
* onstop, oncomplete, onloop | ||
*/ | ||
// enqueue(options = {}) { | ||
// /* istanbul ignore else */ | ||
// if (typeof options.target === "undefined") { | ||
// options.target = this.defaultTarget; | ||
// } | ||
// this.segments.push(options); | ||
// /* istanbul ignore if */ | ||
// if (!this.paused && !this.isRunning) { | ||
// this.next(); | ||
// } | ||
// return this; | ||
// } | ||
}; | ||
export default Led; |
{ | ||
"name": "@embedded/led", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "", | ||
@@ -11,3 +11,3 @@ "main": "led.js", | ||
"license": "MIT", | ||
"gitHead": "afc3b7c3e73e755a38812ccd66c9252c8e111641" | ||
"gitHead": "2863932c6467e880be30b9d415ca4755d7cf5f6f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6276
240