Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.0.4 #1

Merged
merged 5 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions examples/APDS-9960_Multi-VL53L0X/APDS-9960_Multi-VL53L0X.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
#define SENSOR_CNT 5
#define XSHUT_START_PIN 4 //we start with pin 4 because 2 and 3 are interrupt pins (on the nano)
#define SENSORS_START_ADDRESS 45 //0x35 next sensor has 0x36, ...
#define DISTANCE_THRESHOLD 75 //if object is closer than this millimeters an hit will be signaled
#define DISTANCE_MAX_THRESHOLD 75 //if object is closer than this millimeters an hit will be signaled
#define DISTANCE_MIN_THRESHOLD 10
#define TIMING_BUDGET 50000
#define TIMING_CONTINOUES 50
#define TIMEOUT 100
#define VL53L0X_DEBOUNCE 1500 //after a hit distance is messarued after this time of milliseconds again
#define VL53L0X_DEBOUNCE 500 //after a hit distance is messarued after this time of milliseconds again
VL53L0X sensors[SENSOR_CNT];
unsigned long sensorsLastHit[SENSOR_CNT];

Expand All @@ -41,7 +42,7 @@ unsigned long sensorsLastHit[SENSOR_CNT];
// prevent gesture sensor interrupt when just standing in front of mirror, this will
// reduce infrared LED power:
// if you use a third party sensor (not SPARKFUN) make sure to set the GGAIN value to GGAIN_1X
// #define DEFAULT_GGAIN GGAIN_2X // was: GGAIN_4X
// #define DEFAULT_GGAIN GGAIN_1X // was: GGAIN_4X
// #define DEFAULT_GLDRIVE LED_DRIVE_50MA // was: LED_DRIVE_100MA


Expand Down Expand Up @@ -80,7 +81,7 @@ void setup() {
}

// Initalisiert I2C
delay(500);
delay(200);
Wire.begin();
Wire.beginTransmission(0x29);

Expand All @@ -89,12 +90,12 @@ void setup() {
for (int i = 0; i < SENSOR_CNT; i++)
{
digitalWrite(XSHUT_START_PIN + i,HIGH);
delay(500);
delay(50);
sensors[i].init();
Serial.print("VL53L0X");
Serial.print(i);
Serial.println(" - SetAdress");
delay(500);
delay(150);
sensors[i].setAddress(SENSORS_START_ADDRESS+i);
Serial.print("VL53L0X");
Serial.print(i);
Expand Down Expand Up @@ -166,19 +167,20 @@ void loop() {
{
if ((curTime - sensorsLastHit[i]) > VL53L0X_DEBOUNCE){
uint16_t curValue = sensors[i].readRangeContinuousMillimeters();
if (curValue <= DISTANCE_THRESHOLD){
if ((curValue > DISTANCE_MIN_THRESHOLD)&&(curValue <= DISTANCE_MAX_THRESHOLD)){
Serial.print("VL53L0X");
Serial.print(i);
if (sensors[i].timeoutOccurred()) {
Serial.print(": TIMEOUT");
} else {
Serial.print(": HIT");
Serial.print(": HIT -> ");
Serial.print(curValue);
sensorsLastHit[i] = curTime;
}
Serial.println();
}

delay(200);
delay(100);
}
}

Expand Down
15 changes: 8 additions & 7 deletions examples/APDS-9960_Multi-VL53L1X/APDS-9960_Multi-VL53L1X.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#define SENSOR_CNT 3
#define XSHUT_START_PIN 4 //we start with pin 4 because 2 and 3 are interrupt pins (on the nano)
#define SENSORS_START_ADDRESS 53 //0x35 next sensor has 0x36, ...
#define DISTANCE_THRESHOLD 75 //if object is closer than this millimeters an hit will be signaled
#define DISTANCE_MAX_THRESHOLD 100 //if object is closer than this millimeters an hit will be signaled
#define DISTANCE_MIN_THRESHOLD 10
#define DISTANCE_MODE VL53L1X::Long //the sensor supports Short, Mid, Long mode
#define TIMING_BUDGET 50000
#define TIMING_CONTINOUES 50
Expand Down Expand Up @@ -42,7 +43,7 @@ unsigned long sensorsLastHit[SENSOR_CNT];
// prevent gesture sensor interrupt when just standing in front of mirror, this will
// reduce infrared LED power:
// if you use a third party sensor (not SPARKFUN) make sure to set the GGAIN value to GGAIN_1X
// #define DEFAULT_GGAIN GGAIN_2X // was: GGAIN_4X
// #define DEFAULT_GGAIN GGAIN_1X // was: GGAIN_4X
// #define DEFAULT_GLDRIVE LED_DRIVE_50MA // was: LED_DRIVE_100MA


Expand Down Expand Up @@ -81,7 +82,7 @@ void setup() {
}

// Initalisiert I2C
delay(500);
delay(200);
Wire.begin();
Wire.beginTransmission(0x29);

Expand All @@ -90,12 +91,12 @@ void setup() {
for (int i = 0; i < SENSOR_CNT; i++)
{
digitalWrite(XSHUT_START_PIN + i,HIGH);
delay(500);
delay(50);
sensors[i].init();
Serial.print("VL53L1X");
Serial.print(i);
Serial.println(" - SetAdress");
delay(500);
delay(150);
sensors[i].setAddress(SENSORS_START_ADDRESS+i);
Serial.print("VL53L1X");
Serial.print(i);
Expand Down Expand Up @@ -168,7 +169,7 @@ void loop() {
{
if ((curTime - sensorsLastHit[i]) > VL53L1X_DEBOUNCE){
int curValue = sensors[i].read(true);
if (curValue <= DISTANCE_THRESHOLD){
if ((curValue > DISTANCE_MIN_THRESHOLD)&&(curValue <= DISTANCE_MAX_THRESHOLD)){
Serial.print("VL53L1X");
Serial.print(i);
if (sensors[i].timeoutOccurred()) {
Expand All @@ -180,7 +181,7 @@ void loop() {
Serial.println();
}

delay(200);
delay(100);
}
}

Expand Down
2 changes: 1 addition & 1 deletion node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = NodeHelper.create({
for(var curExptMessage in self.config.devices[curDev].messages){
if(curData.indexOf(curExptMessage) == 0){
for(var curNotification in self.config.devices[curDev].messages[curExptMessage]){
console.log(self.currentProfilePattern.toString())
// console.log(self.currentProfilePattern.toString())
if(typeof self.config.devices[curDev].messages[curExptMessage][curNotification].profiles === 'undefined' ||
self.currentProfilePattern.test(self.config.devices[curDev].messages[curExptMessage][curNotification].profiles)){
if(typeof self.config.devices[curDev].messages[curExptMessage][curNotification].notification !== 'undefined'){
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "MMM-Serial-Notifications",
"version": "0.0.3",
"version": "0.0.4",
"description": "",
"main": "MMM-Serial-Notifications.js",
"devDependencies": {},
"scripts": {
"postinstall": "node_modules/.bin/electron-rebuild -e ../../node_modules/electron"
"postinstall": "node_modules/.bin/MagicMirror-rebuild"
},
"dependencies": {
"serialport": "latest",
"electron-rebuild": "^1.2.1"
"electron-rebuild": "latest",
"magicmirror-rebuild": "latest"
},
"repository": {
"type": "git",
Expand Down