FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
vl53l0x_types.h
Go to the documentation of this file.
1// Copyright 2016-2023 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
32#ifndef VL53L0X_TYPES_H
33#define VL53L0X_TYPES_H
34
35#include "../bits.h"
36#include "../flash.h"
37#include "../ios.h"
38#include "../utilities.h"
39#include "vl53l0x_registers.h"
40
41namespace devices::vl53l0x
42{
51 {
52 public:
60 static constexpr bool is_valid(float value)
61 {
62 return ((value >= 0.0) && (value < float(1 << INTEGRAL_BITS)));
63 }
64
73 static constexpr uint16_t convert(float value)
74 {
75 return is_valid(value) ? uint16_t(value * (1 << DECIMAL_BITS)) : 0U;
76 }
77
83 static constexpr float convert(uint16_t value)
84 {
85 return value / float(1 << DECIMAL_BITS);
86 }
87
88 private:
89 static constexpr uint16_t INTEGRAL_BITS = 9;
90 static constexpr uint16_t DECIMAL_BITS = 7;
91 };
92
94 class TimeoutUtilities
95 {
96 private:
97 static constexpr uint32_t PLL_PERIOD_PS = 1655UL;
98 static constexpr uint32_t MACRO_PERIOD_VCLKS = 2304UL;
99
100 public:
101 // timeout in macro periods must be encoded on 16 bits, as (LSB.2^MSB)+1
102 static constexpr uint16_t encode_timeout(uint32_t timeout_macro_clks)
103 {
104 constexpr uint32_t MSB24_MASK = 0xFF'FF'FF'00UL;
105 constexpr uint32_t LSB8_MASK = 0xFFUL;
106
107 if (timeout_macro_clks == 0UL) return 0U;
108 uint32_t lsb = timeout_macro_clks - 1UL;
109 uint16_t msb = 0;
110 while (lsb & MSB24_MASK)
111 {
112 lsb >>= 1;
113 ++msb;
114 }
115 return utils::as_uint16_t(uint8_t(msb), uint8_t(lsb & LSB8_MASK));
116 }
117
118 // timeout in macro periods is encoded on 16 bits, as (LSB.2^MSB)+1
119 static constexpr uint32_t decode_timeout(uint16_t encoded_timeout)
120 {
121 const uint32_t lsb = utils::low_byte(encoded_timeout);
122 const uint32_t msb = utils::high_byte(encoded_timeout);
123 return (lsb << msb) + 1UL;
124 }
125
126 static constexpr uint32_t calculate_macro_period_ps(uint8_t vcsel_period_pclks)
127 {
128 constexpr uint32_t PS_TO_NS_DIVIDER = 1000UL;
129 constexpr uint32_t PS_TO_NS_ROUNDING_ADDITION = 500UL;
130 return ((PLL_PERIOD_PS * MACRO_PERIOD_VCLKS * vcsel_period_pclks) + PS_TO_NS_ROUNDING_ADDITION)
131 / PS_TO_NS_DIVIDER;
132 }
133 static constexpr uint32_t calculate_timeout_us(uint16_t timeout_period_mclks, uint8_t vcsel_period_pclks)
134 {
135 constexpr uint32_t NS_TO_US_DIVIDER = 1000UL;
136 constexpr uint32_t NS_TO_US_ROUNDING_ADDITION = 500UL;
137 const uint32_t macro_period_ns = calculate_macro_period_ps(vcsel_period_pclks);
138 return ((timeout_period_mclks * macro_period_ns) + NS_TO_US_ROUNDING_ADDITION) / NS_TO_US_DIVIDER;
139 }
140 static constexpr uint32_t calculate_timeout_mclks(uint16_t timeout_period_us, uint8_t vcsel_period_pclks)
141 {
142 constexpr uint32_t US_TO_NS_MULTIPLIER = 1000UL;
143 const uint32_t macro_period_ns = calculate_macro_period_ps(vcsel_period_pclks);
144 return ((timeout_period_us * US_TO_NS_MULTIPLIER) + (macro_period_ns / 2)) / macro_period_ns;
145 }
146 };
148
155 enum class DeviceError : uint8_t
156 {
158 NONE = 0,
159 VCSEL_CONTINUITY_TEST_FAILURE = 1,
160 VCSEL_WATCHDOG_TEST_FAILURE = 2,
161 NO_VHV_VALUE_FOUND = 3,
162 MSRC_NO_TARGET = 4,
163 SNR_CHECK = 5,
164 RANGE_PHASE_CHECK = 6,
165 SIGMA_THRESHOLD_CHECK = 7,
166 TCC = 8,
167 PHASE_CONSISTENCY = 9,
168 MIN_CLIP = 10,
170 RANGE_COMPLETE = 11,
171 ALGO_UNDERFLOW = 12,
172 ALGO_OVERFLOW = 13,
173 RANGE_IGNORE_THRESHOLD = 14,
175 UNKNOWN = 15
176 };
177
179 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, DeviceError error)
180 {
181 auto convert = [](DeviceError e)
182 {
183 switch (e)
184 {
186 return F("NONE");
187
188 case DeviceError::VCSEL_CONTINUITY_TEST_FAILURE:
189 return F("VCSEL_CONTINUITY_TEST_FAILURE");
190
191 case DeviceError::VCSEL_WATCHDOG_TEST_FAILURE:
192 return F("VCSEL_WATCHDOG_TEST_FAILURE");
193
194 case DeviceError::NO_VHV_VALUE_FOUND:
195 return F("NO_VHV_VALUE_FOUND");
196
197 case DeviceError::MSRC_NO_TARGET:
198 return F("MSRC_NO_TARGET");
199
200 case DeviceError::SNR_CHECK:
201 return F("SNR_CHECK");
202
203 case DeviceError::RANGE_PHASE_CHECK:
204 return F("RANGE_PHASE_CHECK");
205
206 case DeviceError::SIGMA_THRESHOLD_CHECK:
207 return F("SIGMA_THRESHOLD_CHECK");
208
209 case DeviceError::TCC:
210 return F("TCC");
211
212 case DeviceError::PHASE_CONSISTENCY:
213 return F("PHASE_CONSISTENCY");
214
215 case DeviceError::MIN_CLIP:
216 return F("MIN_CLIP");
217
219 return F("RANGE_COMPLETE");
220
221 case DeviceError::ALGO_UNDERFLOW:
222 return F("ALGO_UNDERFLOW");
223
224 case DeviceError::ALGO_OVERFLOW:
225 return F("ALGO_OVERFLOW");
226
227 case DeviceError::RANGE_IGNORE_THRESHOLD:
228 return F("RANGE_IGNORE_THRESHOLD");
229
231 return F("UNKNOWN");
232
233 default:
234 return F("");
235 }
236 };
237 return out << convert(error);
238 }
240
247 {
248 public:
250 DeviceStatus() = default;
252
257 {
258 return DeviceError((status_ >> ERROR_SHIFT) & ERROR_MASK);
259 }
260
265 bool data_ready() const
266 {
267 return status_ & DATA_READY_MASK;
268 }
269
270 private:
271 uint8_t status_ = 0;
272 static constexpr uint8_t DATA_READY_MASK = 0x01;
273 static constexpr uint8_t ERROR_SHIFT = 3;
274 static constexpr uint8_t ERROR_MASK = 0x0F;
275 };
276
278 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, DeviceStatus status)
279 {
280 return out << '(' << status.error() << ',' << status.data_ready() << ')';
281 }
283
288 enum class PowerMode : uint8_t
289 {
290 STANDBY = 0,
291 IDLE = 1
292 };
293
295 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, PowerMode mode)
296 {
297 auto convert = [](PowerMode m)
298 {
299 switch (m)
300 {
301 case PowerMode::IDLE:
302 return F("IDLE");
303
304 case PowerMode::STANDBY:
305 return F("STANDBY");
306
307 default:
308 return F("");
309 }
310 };
311 return out << convert(mode);
312 }
314
321 enum class GPIOFunction : uint8_t
322 {
324 DISABLED = 0x00,
326 LEVEL_LOW = 0x01,
328 LEVEL_HIGH = 0x02,
330 OUT_OF_WINDOW = 0x03,
332 SAMPLE_READY = 0x04
333 };
334
336 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, GPIOFunction function)
337 {
338 auto convert = [](GPIOFunction f)
339 {
340 switch (f)
341 {
343 return F("DISABLED");
344
346 return F("LEVEL_LOW");
347
349 return F("LEVEL_HIGH");
350
352 return F("OUT_OF_WINDOW");
353
355 return F("SAMPLE_READY");
356
357 default:
358 return F("");
359 }
360 };
361 return out << convert(function);
362 }
364
372 {
373 public:
375 constexpr GPIOSettings() = default;
377 uint16_t low_threshold = 0, uint16_t high_threshold = 0)
378 : function_{function}, high_polarity_{high_polarity},
379 low_threshold_{low_threshold}, high_threshold_{high_threshold} {}
381
387 static constexpr GPIOSettings sample_ready(bool high_polarity = false)
388 {
390 }
391
400 static constexpr GPIOSettings low_threshold(uint16_t threshold, bool high_polarity = false)
401 {
403 }
404
413 static constexpr GPIOSettings high_threshold(uint16_t threshold, bool high_polarity = false)
414 {
416 }
417
428 static constexpr GPIOSettings out_of_window(
429 uint16_t low_threshold, uint16_t high_threshold, bool high_polarity = false)
430 {
432 }
433
438 {
439 return function_;
440 }
444 bool high_polarity() const
445 {
446 return high_polarity_;
447 }
451 uint16_t low_threshold() const
452 {
453 return low_threshold_;
454 }
458 uint16_t high_threshold() const
459 {
460 return high_threshold_;
461 }
462
463 private:
465 bool high_polarity_ = false;
466 uint16_t low_threshold_ = 0;
467 uint16_t high_threshold_ = 0;
468 };
469
471 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, const GPIOSettings& settings)
472 {
473 out << F("(GPIO function=");
475 out << settings.function()
476 << F(", ") << (settings.high_polarity() ? F("HIGH") : F("LOW")) << F(" polarity")
477 << F(", low_threshold=");
479 out << settings.low_threshold()
480 << F(", high_threshold=");
482 out << settings.high_threshold() << ')';
483 return out;
484 }
486
488 class InterruptStatus
489 {
490 public:
491 InterruptStatus() = default;
492 //TODO maybe return more useful info (is each bit mapped to GPIOFunction?)
493 explicit operator uint8_t() const
494 {
495 return status_ & STATUS_MASK;
496 }
497
498 private:
499 uint8_t status_ = 0;
500 static constexpr uint8_t STATUS_MASK = 0x07;
501 };
503
514 {
515 public:
517 static constexpr uint8_t NUM_PADS_BYTES = 6;
518 SPADReference() = default;
519 explicit SPADReference(const uint8_t spad_refs[NUM_PADS_BYTES])
520 {
521 memcpy(spad_refs_, spad_refs, NUM_PADS_BYTES);
522 }
524
529 const uint8_t* spad_refs() const
530 {
531 return spad_refs_;
532 }
533
538 uint8_t* spad_refs()
539 {
540 return spad_refs_;
541 }
542
543 private:
544 uint8_t spad_refs_[NUM_PADS_BYTES];
545 };
546
557 enum class VcselPeriodType : uint8_t
558 {
559 PRE_RANGE = uint8_t(vl53l0x::Register::PRE_RANGE_CONFIG_VCSEL_PERIOD),
560 FINAL_RANGE = uint8_t(vl53l0x::Register::FINAL_RANGE_CONFIG_VCSEL_PERIOD)
561 };
562
584 {
585 private:
586 static constexpr uint8_t FORCED_BITS = bits::BV8(5);
587 // TCC Target Center Check
588 static constexpr uint8_t TCC = bits::BV8(4);
589 // DSS Dynamic Spad Selection
590 static constexpr uint8_t DSS = bits::BV8(3);
591 // MSRC Minimum Signal Rate Check
592 static constexpr uint8_t MSRC = bits::BV8(2);
593 // PRE_RANGE Pre-Range Check
594 static constexpr uint8_t PRE_RANGE = bits::BV8(6);
595 // FINAL_RANGE Final-Range Check
596 static constexpr uint8_t FINAL_RANGE = bits::BV8(7);
597
598 public:
602 static constexpr SequenceSteps create()
603 {
604 return SequenceSteps{};
605 }
615 static constexpr SequenceSteps all()
616 {
617 return SequenceSteps{TCC | DSS | MSRC | PRE_RANGE | FINAL_RANGE};
618 }
619
621 constexpr SequenceSteps() = default;
623
627 constexpr SequenceSteps tcc() const
628 {
629 return SequenceSteps{uint8_t(steps_ | TCC)};
630 }
631
635 constexpr SequenceSteps dss() const
636 {
637 return SequenceSteps{uint8_t(steps_ | DSS)};
638 }
639
643 constexpr SequenceSteps msrc() const
644 {
645 return SequenceSteps{uint8_t(steps_ | MSRC)};
646 }
647
651 constexpr SequenceSteps pre_range() const
652 {
653 return SequenceSteps{uint8_t(steps_ | PRE_RANGE)};
654 }
655
659 constexpr SequenceSteps final_range() const
660 {
661 return SequenceSteps{uint8_t(steps_ | FINAL_RANGE)};
662 }
663
667 constexpr SequenceSteps no_tcc() const
668 {
669 return SequenceSteps{uint8_t(steps_ & bits::COMPL(TCC))};
670 }
671
675 constexpr SequenceSteps no_dss() const
676 {
677 return SequenceSteps{uint8_t(steps_ & bits::COMPL(DSS))};
678 }
679
683 constexpr SequenceSteps no_msrc() const
684 {
685 return SequenceSteps{uint8_t(steps_ & bits::COMPL(MSRC))};
686 }
687
691 constexpr SequenceSteps no_pre_range() const
692 {
693 return SequenceSteps{uint8_t(steps_ & bits::COMPL(PRE_RANGE))};
694 }
695
700 {
701 return SequenceSteps{uint8_t(steps_ & bits::COMPL(FINAL_RANGE))};
702 }
703
707 uint8_t value() const
708 {
709 return steps_;
710 }
711
715 bool is_tcc() const
716 {
717 return steps_ & TCC;
718 }
719
723 bool is_dss() const
724 {
725 return steps_ & DSS;
726 }
727
731 bool is_msrc() const
732 {
733 return steps_ & MSRC;
734 }
735
739 bool is_pre_range() const
740 {
741 return steps_ & PRE_RANGE;
742 }
743
747 bool is_final_range() const
748 {
749 return steps_ & FINAL_RANGE;
750 }
751
752 private:
753 explicit constexpr SequenceSteps(uint8_t steps) : steps_{uint8_t(steps | FORCED_BITS)} {}
754
755 uint8_t steps_ = FORCED_BITS;
756
757 template<typename MANAGER> friend class VL53L0X;
758 };
759
761 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, SequenceSteps steps)
762 {
763 auto with_without = [](OSTREAM& o, bool with, const flash::FlashStorage* label)
764 {
765 if (!with)
766 o << F("no ");
767 o << label;
768 };
769 out << '(';
770 with_without(out, steps.is_tcc(), F("TCC"));
771 out << ',';
772 with_without(out, steps.is_dss(), F("DSS"));
773 out << ',';
774 with_without(out, steps.is_msrc(), F("MSRC"));
775 out << ',';
776 with_without(out, steps.is_pre_range(), F("PRE_RANGE"));
777 out << ',';
778 with_without(out, steps.is_final_range(), F("FINAL_RANGE"));
779 out << ')';
780 return out;
781 }
783
791 {
792 public:
794 SequenceStepsTimeout() = default;
796
801 {
802 return pre_range_vcsel_period_pclks_;
803 }
804
809 {
810 return final_range_vcsel_period_pclks_;
811 }
812
816 uint16_t msrc_dss_tcc_mclks() const
817 {
818 return msrc_dss_tcc_mclks_ + 1;
819 }
820
824 uint16_t pre_range_mclks() const
825 {
826 return TimeoutUtilities::decode_timeout(pre_range_mclks_);
827 }
828
835 uint16_t final_range_mclks(bool is_pre_range) const
836 {
837 uint16_t temp_final_range_mclks = TimeoutUtilities::decode_timeout(final_range_mclks_);
838 return (is_pre_range ? (temp_final_range_mclks - pre_range_mclks()) : temp_final_range_mclks);
839 }
840
841 // Following values are calculated from others
842
846 uint32_t msrc_dss_tcc_us() const
847 {
848 return TimeoutUtilities::calculate_timeout_us(msrc_dss_tcc_mclks(), pre_range_vcsel_period_pclks());
849 }
850
854 uint32_t pre_range_us() const
855 {
856 return TimeoutUtilities::calculate_timeout_us(pre_range_mclks(), pre_range_vcsel_period_pclks());
857 }
858
865 uint32_t final_range_us(bool is_pre_range) const
866 {
867 return TimeoutUtilities::calculate_timeout_us(
869 }
870
871 private:
873 uint8_t msrc_dss_tcc_mclks, uint16_t pre_range_mclks, uint16_t final_range_mclks)
874 : pre_range_vcsel_period_pclks_{pre_range_vcsel_period_pclks},
875 final_range_vcsel_period_pclks_{final_range_vcsel_period_pclks},
876 msrc_dss_tcc_mclks_{msrc_dss_tcc_mclks},
877 pre_range_mclks_{pre_range_mclks},
878 final_range_mclks_{final_range_mclks} {}
879
880 uint8_t pre_range_vcsel_period_pclks_ = 0;
881 uint8_t final_range_vcsel_period_pclks_ = 0;
882
883 uint8_t msrc_dss_tcc_mclks_ = 0;
884 uint16_t pre_range_mclks_ = 0;
885 uint16_t final_range_mclks_ = 0;
886
887 template<typename MANAGER> friend class VL53L0X;
888 };
889
891 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, const SequenceStepsTimeout& timeouts)
892 {
893 out << F("(pre_range_vcsel_period_pclks=");
895 out << timeouts.pre_range_vcsel_period_pclks()
896 << F(", final_range_vcsel_period_pclks=")
897 << timeouts.final_range_vcsel_period_pclks()
898 << F(", msrc_dss_tcc_mclks=")
899 << timeouts.msrc_dss_tcc_mclks()
900 << F(", pre_range_mclks=")
901 << timeouts.pre_range_mclks()
902 << F(", final_range_mclks(with pre-range)=")
903 << timeouts.final_range_mclks(true) << ')'
904 << F(", final_range_mclks(no pre-range)=")
905 << timeouts.final_range_mclks(false) << ')'
906 << F(", msrc_dss_tcc_us()=")
907 << timeouts.msrc_dss_tcc_us() << F("us,")
908 << F(", pre_range_us()=")
909 << timeouts.pre_range_us() << F("us,")
910 << F(", final_range_us(with pre-range)=")
911 << timeouts.final_range_us(true) << F("us,")
912 << F(", final_range_us(no pre-range)=")
913 << timeouts.final_range_us(false) << F("us)");
914 return out;
915 }
917
927 {
928 private:
929 static constexpr uint8_t APERTURE = bits::BV8(7);
930 static constexpr uint8_t COUNT = bits::CBV8(7);
931
932 public:
934 SPADInfo() = default;
935 explicit SPADInfo(uint8_t info) : info_{info} {}
937
942 bool is_aperture() const
943 {
944 return info_ & APERTURE;
945 }
946
950 uint8_t count() const
951 {
952 return info_ & COUNT;
953 }
954
955 private:
956 uint8_t info_ = 0;
957 };
958
960 template<typename OSTREAM> OSTREAM& operator<<(OSTREAM& out, SPADInfo info)
961 {
962 out << F("(aperture=") << info.is_aperture()
963 << F(", count=");
965 out << info.count() << ')';
966 return out;
967 }
969
975 enum class Profile : uint8_t
976 {
978 STANDARD = 0x00,
980 LONG_RANGE = 0x01,
982 STANDARD_ACCURATE = 0x02,
984 LONG_RANGE_ACCURATE = 0x03,
986 STANDARD_FAST = 0x04,
988 LONG_RANGE_FAST = 0x05,
989 };
990}
991
992#endif /* VL53L0X_TYPES_H */
Status of device as retrieved by VL53L0X::get_range_status().
bool data_ready() const
Indicate if data (range) is ready for reading.
DeviceError error() const
Device error.
Helper class to handle VL53L0X special fix-point 9.7 values.
Definition: vl53l0x_types.h:51
static constexpr bool is_valid(float value)
Check that a float value is valid for conversion to 9.7 fix-point.
Definition: vl53l0x_types.h:60
static constexpr uint16_t convert(float value)
Convert a float value into an 9.7 fix-point.
Definition: vl53l0x_types.h:73
static constexpr float convert(uint16_t value)
Convert an 9.7 fix-point value into a float.
Definition: vl53l0x_types.h:83
Settings for behavior of VL53L0X GPIO pin.
static constexpr GPIOSettings out_of_window(uint16_t low_threshold, uint16_t high_threshold, bool high_polarity=false)
Create GPIOSettings for interrupt triggered when range is outside a window between low_threshold and ...
uint16_t low_threshold() const
Return the current low threshold, in mm.
bool high_polarity() const
Return the current polarity level of GPIO interrupts.
uint16_t high_threshold() const
Return the current high threshold, in mm.
static constexpr GPIOSettings sample_ready(bool high_polarity=false)
Create GPIOSettings for interrupt triggered when range sample is ready.
static constexpr GPIOSettings low_threshold(uint16_t threshold, bool high_polarity=false)
Create GPIOSettings for interrupt triggered when range is under threshold.
static constexpr GPIOSettings high_threshold(uint16_t threshold, bool high_polarity=false)
Create GPIOSettings for interrupt triggered when range is above threshold.
GPIOFunction function() const
Return the current GPIO interrupt trigger source.
Hold SPAD information from VL53L0X device.
bool is_aperture() const
Indicate which is the first SPAD to enable, if false this is SPAD 0, else it is SPAD 12.
uint8_t count() const
Indicate the number of SPADs to enable.
Hold reference SPADs (Single Photon Avalanche Diode).
const uint8_t * spad_refs() const
Get a pointer to the 6-byte array stored in this SPADReference instance.
uint8_t * spad_refs()
Get a pointer to the 6-byte array stored in this SPADReference instance.
Hold VL53L0X sequence steps to use for ranging.
constexpr SequenceSteps no_msrc() const
Create a new SequenceSteps by removing MSRC from steps of this instance.
bool is_msrc() const
Indicate if this instance has MSRC (Minimum Signal Rate Check) step.
constexpr SequenceSteps no_final_range() const
Create a new SequenceSteps by removing FINAL-RANGE from steps of this instance.
bool is_final_range() const
Indicate if this instance has FINAL-RANGE step.
constexpr SequenceSteps dss() const
Create a new SequenceSteps by adding DSS to steps of this instance.
constexpr SequenceSteps tcc() const
Create a new SequenceSteps by adding TCC to steps of this instance.
constexpr SequenceSteps pre_range() const
Create a new SequenceSteps by adding PRE-RANGE to steps of this instance.
bool is_pre_range() const
Indicate if this instance has PRE-RANGE step.
uint8_t value() const
Get steps of this instance as a byte.
constexpr SequenceSteps no_dss() const
Create a new SequenceSteps by removing DSS from steps of this instance.
constexpr SequenceSteps no_tcc() const
Create a new SequenceSteps by removing TCC from steps of this instance.
static constexpr SequenceSteps all()
Create a full step sequence with all steps, with the possibility to remove steps you do not want:
constexpr SequenceSteps final_range() const
Create a new SequenceSteps by adding FINAL-RANGE to steps of this instance.
static constexpr SequenceSteps create()
Create an empty step sequence for further adding individual steps.
constexpr SequenceSteps msrc() const
Create a new SequenceSteps by adding MSRC to steps of this instance.
constexpr SequenceSteps no_pre_range() const
Create a new SequenceSteps by removing PRE-RANGE from steps of this instance.
bool is_dss() const
Indicate if this instance has DSS (Dynamic SPAD Selection) step.
bool is_tcc() const
Indicate if this instance has TCC (Target Center Check) step.
Hold VL53L0X sequence steps timeouts and other related settings used for ranging.
uint8_t final_range_vcsel_period_pclks() const
VCSEL PCLK value for final-range step.
uint32_t final_range_us(bool is_pre_range) const
Calculate the timing in us of FINAL-RANGE step.
uint16_t final_range_mclks(bool is_pre_range) const
MCLK for FINAL-RANGE step.
uint32_t msrc_dss_tcc_us() const
Calculate the timing in us of any of MSRC, DSS or TCC steps.
uint32_t pre_range_us() const
Calculate the timing in us of PRE-RANGE step.
uint16_t msrc_dss_tcc_mclks() const
MCLK for any of MSRC, DSS or TCC steps.
uint8_t pre_range_vcsel_period_pclks() const
VCSEL PCLK value for pre-range step.
uint16_t pre_range_mclks() const
MCLK for PRE-RANGE step.
static constexpr fmtflags basefield
Bitmask constant used with setf(fmtflags, fmtflags) when changing the output base format.
Definition: ios.h:227
static constexpr fmtflags dec
Read or write integral values using decimal (0..9) base format.
Definition: ios.h:212
static constexpr fmtflags hex
Read or write integral values using hexadecimal (0..9,A..F) base format.
Definition: ios.h:218
#define F(ptr)
Force string constant to be stored as flash storage.
Definition: flash.h:150
static constexpr uint8_t COMPL(uint8_t value)
Return the uint8_t 2-complement of a byte.
Definition: bits.h:253
static constexpr uint8_t CBV8(uint8_t bit)
Create a uint8_t inverted bitmask for the given bit number.
Definition: bits.h:137
static constexpr uint8_t BV8(uint8_t bit)
Create a uint8_t bitmask for the given bit number.
Definition: bits.h:41
Defines API for VL53L0X Time-of-Flight ranging sensor chip usage.
Definition: vl53l0x.h:60
VcselPeriodType
Type of pulse period configured for VL53L0X device VCSEL (Vertical Cavity Surface Emitting Laser).
PowerMode
Possible power modes of VL53L0X device as returned by VL53L0X::get_power_mode().
GPIOFunction
Possible triggers for VL53L0X GPIO pin.
@ DISABLED
No interrupt triggered on GPIO pin.
@ OUT_OF_WINDOW
Interrupt triggered when range is outside a window between low and high thresholds.
@ SAMPLE_READY
Interrupt triggered when a range is ready to read.
@ LEVEL_LOW
Interrupt triggered when range is under a low threshold.
@ LEVEL_HIGH
Interrupt triggered when range is above a high threshold.
DeviceError
Possible error codes returned by VL53L0X device.
@ RANGE_COMPLETE
Range completed, range value is available for reading.
Profile
Possible profiles of ranging for VL53L0X top-level API VL53L0X::begin().
@ LONG_RANGE_ACCURATE
Accurate long range profile: 200ms ranging time, high accuracy, 2.0m range.
@ STANDARD_ACCURATE
Accurate standard profile: 200ms ranging time, high accuracy, 1.2m range.
@ STANDARD_FAST
Standard fast profile: 20ms ranging time, low accuracy, 1.2m range.
@ STANDARD
Standard profile: 33ms ranging time, common accuracy, 1.2m range.
@ LONG_RANGE_FAST
Standard long range profile: 20ms ranging time, low accuracy, 2.0m range.
@ LONG_RANGE
Long range profile: 33ms ranging time, common accuracy, 2.0m range.
constexpr uint8_t high_byte(uint16_t word)
Extract the high order byte of a 16-bits word.
Definition: utilities.h:316
constexpr uint16_t as_uint16_t(uint8_t high, uint8_t low)
Convert 2 bytes into an unsigned int.
Definition: utilities.h:327
constexpr uint8_t low_byte(uint16_t word)
Extract the low order byte of a 16-bits word.
Definition: utilities.h:308