New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

robotois-light-sensor

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robotois-light-sensor - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

docs/_sidebar.md

39

index.js

@@ -14,2 +14,3 @@ const LSensor = require('bindings')('LightSensor');

this.light = new LSensor(port, add);
this.prevValue = -1;

@@ -34,4 +35,3 @@ process.on('SIGINT', () => {

LightSensor.prototype.getBasicValue = function getBasicValue() { // Rounded
const value = Math.round(this.light.getValue() * 100) / 100;
return value;
return this.light.getBasicValue();
};

@@ -43,27 +43,21 @@

LightSensor.prototype.getBasicScaledValue = function getBasicScaledValue() {
return this.light.getBasicScaledValue();
LightSensor.prototype.publishNow = function publishNow() {
this.mqttClient.publish(this.myTopic, this.light.getScaledValue().toString());
};
LightSensor.prototype.enableEvents = function enableEvents() {
const self = this;
let scaledValue;
LightSensor.prototype.enableEvents = function enableEvents(mqttConfig) {
if (mqttConfig) {
this.mqttClient = mqttConfig.mqttClient;
this.myTopic = `sensors/light${mqttConfig.instance}`;
this.mqttClient.publish('registerTopic', this.myTopic);
}
if (!this.eventInterval) {
this.eventInterval = setInterval(() => {
scaledValue = this.light.getBasicScaledValue();
self.emit('medicion', scaledValue);
}, 500); // Tomar mediciones cada 500ms
}
};
LightSensor.prototype.when = function when(value, callback) {
if (!this.interval) {
this.interval = setInterval(() => {
/* eslint-disable no-console */
console.log(`Luz:${this.light.getBasicScaledValue()}`);
/* eslint-disable eqeqeq */
if (this.light.getBasicScaledValue() == value) {
callback();
const currentValue = this.light.getScaledValue();
this.emit('medicion', currentValue);
if (this.prevValue !== currentValue && this.mqttClient) {
this.mqttClient.publish(this.myTopic, currentValue.toString());
this.prevValue = currentValue;
}
}, 500); // Tomar mediciones cada 500ms
}, 250);
}

@@ -73,3 +67,2 @@ };

LightSensor.prototype.release = function release() {
clearInterval(this.interval);
clearInterval(this.eventInterval);

@@ -76,0 +69,0 @@ this.light.release();

{
"name": "robotois-light-sensor",
"version": "1.0.2",
"version": "1.0.3",
"description": "Node library for the light sensor module",

@@ -23,2 +23,7 @@ "main": "index.js",

],
"homepage": "https://github.com/Robotois/robotois-light-sensor",
"repository": {
"type": "git",
"url": "git+https://github.com/Robotois/robotois-light-sensor.git"
},
"license": "ISC",

@@ -25,0 +30,0 @@ "dependencies": {

@@ -5,10 +5,9 @@ const LightSensor = require('../index');

setInterval(() => { // Proceso en estado ocioso
/* eslint-disable no-console */
console.log(`Luz: ${light.getValue()}`);
// console.log(`Luz: ${light.getValue().toFixed(2)}`);
console.log(`BasicValue: ${light.getBasicValue()}`);
/* eslint-disable no-console */
console.log(`BasicScaledValue: ${light.getBasicScaledValue()}`);
// console.log(`BasicValue: ${light.getBasicValue().toFixed(2)}`);
console.log(`ScaledValue: ${light.getScaledValue()}\n`);
}, 1000);
setInterval(() => {}, 10000);
process.on('SIGTERM', () => {

@@ -15,0 +14,0 @@ process.exit();

@@ -9,3 +9,2 @@ const LightSensor = require('../index');

});
setInterval(() => {}, 10000);

@@ -12,0 +11,0 @@ process.on('SIGTERM', () => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc