Skip to content

Commit

Permalink
Merge pull request #4 from NoahRosa/master
Browse files Browse the repository at this point in the history
Fix warnings and add sam compatibility
  • Loading branch information
cparata authored Mar 4, 2019
2 parents 1d51f46 + 9e4ce56 commit b3f67d6
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,25 @@
#include <tof_gestures.h>
#include <tof_gestures_DIRSWIPE_1.h>

#ifdef ARDUINO_SAM_DUE
#define DEV_I2C Wire1
#elif defined(ARDUINO_ARCH_STM32)
#define DEV_I2C Wire
#else
#define DEV_I2C Wire
#endif
#define SerialPort Serial

//For SAM compatibility where D8 and D2 are undefined
#ifndef D8
#define D8 8
#endif


#ifndef D2
#define D2 2
#endif

// Components.
STMPE1600DigiOut *xshutdown_top;
STMPE1600DigiOut *xshutdown_left;
Expand Down Expand Up @@ -140,6 +156,26 @@ void setup() {
// Initialize serial for output.
SerialPort.begin(115200);

//NOTE: workaround in order to unblock the I2C bus on the Arduino Due
#ifdef ARDUINO_SAM_DUE
pinMode(71, OUTPUT);
pinMode(70, OUTPUT);

for (int i = 0; i<10; i++){
digitalWrite(70, LOW);
delay(3);
digitalWrite(71, HIGH);
delay(3);
digitalWrite(70, HIGH);
delay(3);
digitalWrite(71, LOW);
delay(3);
}
pinMode(70, INPUT);
pinMode(71, INPUT);
#endif
//End of workaround

// Initialize I2C bus.
DEV_I2C.begin();
DEV_I2C.setClock(400000);
Expand Down Expand Up @@ -190,7 +226,6 @@ void setup() {

void loop() {
int gesture_code;
int status;

sensor_vl53l0x_left->StartMeasurement();
sensor_vl53l0x_right->StartMeasurement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,25 @@
#include <tof_gestures.h>
#include <tof_gestures_SWIPE_1.h>

#ifdef ARDUINO_SAM_DUE
#define DEV_I2C Wire1
#elif defined(ARDUINO_ARCH_STM32)
#define DEV_I2C Wire
#else
#define DEV_I2C Wire
#endif
#define SerialPort Serial

//For SAM compatibility where D8 and D2 are undefined
#ifndef D8
#define D8 8
#endif


#ifndef D2
#define D2 2
#endif

// Components.
STMPE1600DigiOut *xshutdown_top;
STMPE1600DigiOut *xshutdown_left;
Expand Down Expand Up @@ -115,6 +131,26 @@ void setup() {
// Initialize serial for output.
SerialPort.begin(115200);

//NOTE: workaround in order to unblock the I2C bus on the Arduino Due
#ifdef ARDUINO_SAM_DUE
pinMode(71, OUTPUT);
pinMode(70, OUTPUT);

for (int i = 0; i<10; i++){
digitalWrite(70, LOW);
delay(3);
digitalWrite(71, HIGH);
delay(3);
digitalWrite(70, HIGH);
delay(3);
digitalWrite(71, LOW);
delay(3);
}
pinMode(70, INPUT);
pinMode(71, INPUT);
#endif
//End of workaround

// Initialize I2C bus.
DEV_I2C.begin();

Expand Down Expand Up @@ -157,7 +193,6 @@ void setup() {

void loop() {
int gesture_code;
int status;

sensor_vl53l0x_top->StartMeasurement();

Expand Down Expand Up @@ -214,5 +249,3 @@ void loop() {
break;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,25 @@
#include <tof_gestures.h>
#include <tof_gestures_TAP_1.h>

#ifdef ARDUINO_SAM_DUE
#define DEV_I2C Wire1
#elif defined(ARDUINO_ARCH_STM32)
#define DEV_I2C Wire
#else
#define DEV_I2C Wire
#endif
#define SerialPort Serial

//For SAM compatibility where D8 and D2 are undefined
#ifndef D8
#define D8 8
#endif


#ifndef D2
#define D2 2
#endif

// Components.
STMPE1600DigiOut *xshutdown_top;
STMPE1600DigiOut *xshutdown_left;
Expand Down Expand Up @@ -115,6 +131,26 @@ void setup() {
// Initialize serial for output.
SerialPort.begin(115200);

//NOTE: workaround in order to unblock the I2C bus on the Arduino Due
#ifdef ARDUINO_SAM_DUE
pinMode(71, OUTPUT);
pinMode(70, OUTPUT);

for (int i = 0; i<10; i++){
digitalWrite(70, LOW);
delay(3);
digitalWrite(71, HIGH);
delay(3);
digitalWrite(70, HIGH);
delay(3);
digitalWrite(71, LOW);
delay(3);
}
pinMode(70, INPUT);
pinMode(71, INPUT);
#endif
//End of workaround

// Initialize I2C bus.
DEV_I2C.begin();

Expand Down Expand Up @@ -157,7 +193,6 @@ void setup() {

void loop() {
int gesture_code;
int status;

sensor_vl53l0x_top->StartMeasurement();

Expand Down Expand Up @@ -214,4 +249,3 @@ void loop() {
break;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,25 @@
#include <stdint.h>
#include <assert.h>

#ifdef ARDUINO_SAM_DUE
#define DEV_I2C Wire1
#elif defined(ARDUINO_ARCH_STM32)
#define DEV_I2C Wire
#else
#define DEV_I2C Wire
#endif
#define SerialPort Serial

//For SAM compatibility where D8 and D2 are undefined
#ifndef D8
#define D8 8
#endif


#ifndef D2
#define D2 2
#endif

// Components.
STMPE1600DigiOut *xshutdown_top;
STMPE1600DigiOut *xshutdown_left;
Expand All @@ -71,6 +87,26 @@ void setup() {
// Initialize serial for output.
SerialPort.begin(115200);

//NOTE: workaround in order to unblock the I2C bus on the Arduino Due
#ifdef ARDUINO_SAM_DUE
pinMode(71, OUTPUT);
pinMode(70, OUTPUT);

for (int i = 0; i<10; i++){
digitalWrite(70, LOW);
delay(3);
digitalWrite(71, HIGH);
delay(3);
digitalWrite(70, HIGH);
delay(3);
digitalWrite(71, LOW);
delay(3);
}
pinMode(70, INPUT);
pinMode(71, INPUT);
#endif
//End of workaround

// Initialize I2C bus.
DEV_I2C.begin();

Expand Down Expand Up @@ -159,4 +195,3 @@ void loop() {
SerialPort.println(report);
}
}

4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=STM32duino X-NUCLEO-53L0A1
version=1.0.1
version=1.0.2
author=AST
maintainer=stm32duino
sentence=Allows controlling the VL53L0X sensors on board of X-NUCLEO-53L0A1
paragraph=This library provides simple measure distance in mm, single swipe gesture detection, directional (left/right) swipe gesture detection and single tap gesture detection.
category=Device Control
url=https://github.com/stm32duino/X-NUCLEO-53L0A1
architectures=stm32
architectures=stm32, sam
Loading

0 comments on commit b3f67d6

Please sign in to comment.