-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4759 from tonhuisman/bugfix/P113-apply-fix-for-sh…
…ifted-i2c-address [P113] Fix for shifted I2C address in library, code improvements
- Loading branch information
Showing
21 changed files
with
579 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# LibraryBuild.yml | ||
# Github workflow script to test compile all examples of an Arduino library repository. | ||
# | ||
# Copyright (C) 2020 Armin Joachimsmeyer | ||
# https://github.com/ArminJo/Github-Actions | ||
# License: MIT | ||
# | ||
# Before being able to push to my .github\workflows directories, | ||
# I had to create a new personal token with workflow enabled at https://github.com/settings/tokens | ||
|
||
# This is the name of the workflow, visible on GitHub UI. | ||
name: LibraryBuild | ||
on: | ||
push: # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request | ||
paths: | ||
- '**.ino' | ||
- '**.cpp' | ||
- '**.h' | ||
- '**LibraryBuild.yml' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.arduino-boards-fqbn }} - test compiling examples | ||
|
||
runs-on: ubuntu-18.04 # I picked Ubuntu to use shell scripts. | ||
|
||
env: | ||
# Comma separated list without double quotes around the list. | ||
PLATFORM_DEFAULT_URL: https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json | ||
REQUIRED_LIBRARIES: EspSoftwareSerial | ||
|
||
strategy: | ||
matrix: | ||
# The matrix will produce one job for each configuration parameter of type `arduino-boards-fqbn` | ||
# In the Arduino IDE, the fqbn is printed in the first line of the verbose output for compilation as parameter -fqbn=... for the "arduino-builder -dump-prefs" command | ||
# | ||
# Examples: arduino:avr:uno, arduino:avr:leonardo, arduino:avr:nano, arduino:avr:mega | ||
# arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native" | ||
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro | ||
# STM32:stm32:GenF1:pnum=BLUEPILL_F103C8 | ||
# esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80 | ||
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace | ||
############################################################################################################# | ||
arduino-boards-fqbn: | ||
- arduino:avr:uno | ||
- arduino:avr:leonardo | ||
- arduino:avr:mega | ||
- arduino:sam:arduino_due_x | ||
- SparkFun:apollo3:artemis | ||
- SparkFun:apollo3:amap3redboard | ||
- SparkFun:apollo3:amap3nano | ||
- SparkFun:apollo3:amap3atp | ||
- SparkFun:apollo3:amap3thing | ||
- SparkFun:apollo3:edge | ||
- SparkFun:apollo3:edge2 | ||
- esp8266:esp8266:huzzah:eesz=4M3M,xtal=80 | ||
- esp32:esp32:featheresp32:FlashFreq=80 | ||
- STM32:stm32:GenF1:pnum=BLUEPILL_F103C8 | ||
|
||
# Choose the right platform for the boards we want to test. (maybe in the future Arduino will automatically do this for you). | ||
# This works like this: when the fqbn is "arduino:avr:uno" the variable `platform` is set to "arduino:avr". | ||
# Just take the first 2 token of the fqbn - this cannot be automatically done by GitHub workflow :-( | ||
# You may exclude specific examples for a board with examples-exclude: Use a space separated list. | ||
############################################################################################################# | ||
include: | ||
- arduino-boards-fqbn: arduino:sam:arduino_due_x | ||
examples-exclude: Example5_LCDDemo # No SoftwareSerial available. Space separated list of (unique substrings of) example names to exclude in build | ||
|
||
- arduino-boards-fqbn: esp8266:esp8266:huzzah:eesz=4M3M,xtal=80 | ||
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json | ||
|
||
- arduino-boards-fqbn: esp32:esp32:featheresp32:FlashFreq=80 | ||
platform-url: https://dl.espressif.com/dl/package_esp32_index.json | ||
|
||
- arduino-boards-fqbn: STM32:stm32:GenF1:pnum=BLUEPILL_F103C8 | ||
platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/dev/STM32/package_stm_index.json | ||
|
||
# Do not cancel all jobs / architectures if one job fails | ||
fail-fast: false | ||
|
||
# This is the list of steps this job will run. | ||
steps: | ||
|
||
# First of all, we clone the repo using the `checkout` action. | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Compile all examples | ||
uses: ArminJo/arduino-test-compile@v2 | ||
with: | ||
required-libraries: ${{ env.REQUIRED_LIBRARIES }} | ||
arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }} | ||
platform-default-url: ${{ env.PLATFORM_DEFAULT_URL }} | ||
platform-url: ${{ matrix.platform-url }} | ||
examples-exclude: ${{ matrix.examples-exclude }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
COPYRIGHT(c) 2018 STMicroelectronics | ||
Copyright © 2022 SparkFun Electronics | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of STMicroelectronics nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), | ||
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
lib/SparkFun_VL53L1X/examples/Example1_ReadDistance/Example1_ReadDistance.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
lib/SparkFun_VL53L1X/examples/Example7_Calibration/Example7_Calibration.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
...L53L1X/examples/Example8_SetGetDetectionThresholds/Example8_SetGetDetectionThresholds.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
Reading distance from the laser based VL53L1X | ||
By: Nathan Seidle | ||
Revised by: Andy England and Ricardo Ramos | ||
SparkFun Electronics | ||
Date: January 21st, 2022 | ||
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license). | ||
SparkFun labored with love to create this code. Feel like supporting open source hardware? | ||
Buy a board from SparkFun! https://www.sparkfun.com/products/14667 | ||
This example sets high and low thresholds for detection. | ||
Are you getting weird readings? Be sure the vacuum tape has been removed from the sensor. | ||
*/ | ||
|
||
#include <Wire.h> | ||
#include "SparkFun_VL53L1X.h" //Click here to get the library: http://librarymanager/All#SparkFun_VL53L1X | ||
|
||
//Optional interrupt and shutdown pins. | ||
#define SHUTDOWN_PIN 2 | ||
#define INTERRUPT_PIN 3 | ||
|
||
SFEVL53L1X distanceSensor; | ||
//Uncomment the following line to use the optional shutdown and interrupt pins. | ||
//SFEVL53L1X distanceSensor(Wire, SHUTDOWN_PIN, INTERRUPT_PIN); | ||
|
||
void setup(void) | ||
{ | ||
Wire.begin(); | ||
|
||
Serial.begin(115200); | ||
Serial.println("VL53L1X Qwiic Test"); | ||
|
||
if (distanceSensor.begin() != 0) //Begin returns 0 on a good init | ||
{ | ||
Serial.println("Sensor failed to begin. Please check wiring. Freezing..."); | ||
while (1) | ||
; | ||
} | ||
Serial.println("Sensor online!"); | ||
|
||
DetectionConfig dc; // struct instance which holds the detection configuration | ||
dc.IntOnNoTarget = 1; // No longer used - just use 1 per ST | ||
dc.distanceMode = DISTANCE_SHORT; // short distance mode | ||
dc.thresholdHigh = 300; // high threshold of 300 mm | ||
dc.thresholdLow = 70; // low threshold of 70 mm | ||
dc.windowMode = WINDOW_IN; // will measure and trigger interrrupt when measurement fall between 70 and 300 mm | ||
|
||
if(distanceSensor.setThresholdConfig(&dc) == true) | ||
{ | ||
Serial.println("Thresholds programmed. Reading configuration back..."); | ||
dc = {}; | ||
if(distanceSensor.getThresholdConfig(&dc) == true) | ||
{ | ||
Serial.print("IntOnNoTarget: "); | ||
Serial.println(dc.IntOnNoTarget); | ||
Serial.print("Distance Mode: "); | ||
|
||
if(dc.distanceMode == DISTANCE_SHORT) | ||
Serial.println("DISTANCE_SHORT (0)"); | ||
else | ||
Serial.println("DISTANCE_LONG (1)"); | ||
|
||
Serial.print("Threshold High: "); | ||
Serial.println(dc.thresholdHigh); | ||
Serial.print("Threshold Low: "); | ||
Serial.println(dc.thresholdLow); | ||
Serial.print("Window mode: "); | ||
switch (dc.windowMode) | ||
{ | ||
case WINDOW_BELOW: | ||
Serial.println("WINDOW_BELOW (0)"); | ||
break; | ||
|
||
case WINDOW_ABOVE: | ||
Serial.println("WINDOW_ABOVE (1)"); | ||
break; | ||
|
||
case WINDOW_OUT: | ||
Serial.println("WINDOW_OUT (2)"); | ||
break; | ||
|
||
case WINDOW_IN: | ||
Serial.println("WINDOW_IN (3)"); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
Serial.println("Could not set threshold configuration."); | ||
} | ||
Serial.println("Starting measurements in 2 seconds."); | ||
delay(2000); | ||
Serial.println("Measurements started!"); | ||
|
||
} | ||
|
||
void loop(void) | ||
{ | ||
distanceSensor.startRanging(); //Write configuration bytes to initiate measurement | ||
|
||
while (!distanceSensor.checkForDataReady()) | ||
{ | ||
delay(1); | ||
} | ||
int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor | ||
distanceSensor.clearInterrupt(); | ||
|
||
distanceSensor.stopRanging(); | ||
|
||
Serial.print("Distance(mm): "); | ||
Serial.print(distance); | ||
|
||
float distanceInches = distance * 0.0393701; | ||
float distanceFeet = distanceInches / 12.0; | ||
|
||
Serial.print("\tDistance(ft): "); | ||
Serial.print(distanceFeet, 2); | ||
|
||
Serial.println(); | ||
} |
Oops, something went wrong.