diff --git a/third-party/TeensyTimerTool/examples/01_Basic/HelloPeriodic/HelloPeriodic.ino b/third-party/TeensyTimerTool/examples/01_Basic/HelloPeriodic/HelloPeriodic.ino index 391db61..e4ecc97 100644 --- a/third-party/TeensyTimerTool/examples/01_Basic/HelloPeriodic/HelloPeriodic.ino +++ b/third-party/TeensyTimerTool/examples/01_Basic/HelloPeriodic/HelloPeriodic.ino @@ -1,10 +1,10 @@ /******************************************************** * Basic usage of the timer - * + * * Generates a timer from the timer pool and - * starts it with a period of 250ms. + * starts it with a period of 250ms. * The timer callback simply toggles the built in LED - * + * ********************************************************/ #include "TeensyTimerTool.h" @@ -13,17 +13,17 @@ using namespace TeensyTimerTool; void callback() { - digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN)); + digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN)); } -Timer t1; // generate a timer from the pool (Pool: 2xGPT, 16xTMR(QUAD), 20xTCK) +PeriodicTimer t1; // generate a timer from the pool (Pool: 2xGPT, 16xTMR(QUAD), 20xTCK) void setup() { - pinMode(LED_BUILTIN,OUTPUT); - t1.beginPeriodic(callback, 250'000); // 250ms + pinMode(LED_BUILTIN,OUTPUT); + t1.begin(callback, 250'000); // 250ms } void loop() -{ +{ } diff --git a/third-party/TeensyTimerTool/examples/01_Basic/MoreTimers/MoreTimers.ino b/third-party/TeensyTimerTool/examples/01_Basic/MoreTimers/MoreTimers.ino index 2506585..fba91cb 100644 --- a/third-party/TeensyTimerTool/examples/01_Basic/MoreTimers/MoreTimers.ino +++ b/third-party/TeensyTimerTool/examples/01_Basic/MoreTimers/MoreTimers.ino @@ -1,11 +1,15 @@ +//----------------------- +// REQUIRES T4.x +//----------------------- + #include "TeensyTimerTool.h" using namespace TeensyTimerTool; -Timer t1(TCK); // Tick-Timer does not use any hardware timer (20 32bit channels) -Timer t2(TMR1); // First channel on TMR1 aka QUAD timer module. (TMR1 - TMR4, four 16bit channels each) -Timer t3(GPT1); // GPT1 module (one 32bit channel per module) -Timer t4(TMR1); // Second channel on TMR1 +PeriodicTimer t1(TCK); // Tick-Timer does not use any hardware timer (20 32bit channels) +PeriodicTimer t2(TMR1); // First channel on TMR1 aka QUAD timer module. (TMR1 - TMR4, four 16bit channels each) +PeriodicTimer t3(GPT1); // GPT1 module (one 32bit channel per module) +OneShotTimer t4(TMR1); // Second channel on TMR1 // Callbacks =================================================================================== @@ -38,15 +42,14 @@ void LED_OFF() void setup() { - for(unsigned pin = 0; pin <=13; pin++) pinMode(pin,OUTPUT); + for (unsigned pin = 0; pin <= 13; pin++) pinMode(pin, OUTPUT); - t1.beginPeriodic(pulse200ns, 50'000); // 200ns pulse every 500 ms - t2.beginPeriodic(pulse400ns, 100); // 400ns pulse every 100 µs - t3.beginPeriodic(LED_ON, 1'000'000); // Switch LED on every second - t4.beginOneShot(LED_OFF); // One shot timer to switch LED Off + t1.begin(pulse200ns, 50'000); // 200ns pulse every 500 ms + t2.begin(pulse400ns, 100); // 400ns pulse every 100 µs + t3.begin(LED_ON, 1'000'000); // Switch LED on every second + t4.begin(LED_OFF); // One shot timer to switch LED Off } void loop() -{ +{ } - diff --git a/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations1/UsingChronoDurations1.ino b/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations1/UsingChronoDurations1.ino index 44173d2..fb33295 100644 --- a/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations1/UsingChronoDurations1.ino +++ b/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations1/UsingChronoDurations1.ino @@ -27,7 +27,6 @@ void setup() t1.begin(isr1, 5.02s); // instead of 5020000 (µs) t2.begin(isr2, 25ms); // instead of 25000 (µs) - t2.begin(isr3, 100_kHz); // instead of 10 (µs) } void loop() diff --git a/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations2/UsingChronoDurations2.ino b/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations2/UsingChronoDurations2.ino index db54e9b..401c0da 100644 --- a/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations2/UsingChronoDurations2.ino +++ b/third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations2/UsingChronoDurations2.ino @@ -25,7 +25,7 @@ void setup() timer[3].trigger(milliseconds(50) + microseconds(5000)); // 55ms t_0 = millis(); - pt1.begin([]{digitalToggleFast(LED_BUILTIN)}) + pt1.begin([] { digitalToggleFast(LED_BUILTIN); }, 0.5s); } void loop() diff --git a/third-party/TeensyTimerTool/examples/02_Advanced/CallbackWithParams/CallbackWithParams.ino b/third-party/TeensyTimerTool/examples/02_Advanced/CallbackWithParams/CallbackWithParams.ino index 4f1dc95..c359b35 100644 --- a/third-party/TeensyTimerTool/examples/02_Advanced/CallbackWithParams/CallbackWithParams.ino +++ b/third-party/TeensyTimerTool/examples/02_Advanced/CallbackWithParams/CallbackWithParams.ino @@ -4,7 +4,7 @@ using namespace TeensyTimerTool; void callback(int& someInt, int cnt) // this callback has context, i.e. parameter { - for (int i = 0; i < cnt; i++) // whenn called, print out someInt cnt times + for (int i = 0; i < cnt; i++) // when called, print out someInt cnt times { Serial.print(someInt); Serial.print(" | "); @@ -14,12 +14,12 @@ void callback(int& someInt, int cnt) // this callback has context, i.e. paramet //============================================================== -Timer t; +PeriodicTimer t; int number = 0; void setup() { - t.beginPeriodic([] { callback(number, 5); }, 50'000); + t.begin([] { callback(number, 5); }, 50ms); } void loop() diff --git a/third-party/TeensyTimerTool/examples/02_Advanced/UsingLambdas/UsingLambdas.ino b/third-party/TeensyTimerTool/examples/02_Advanced/UsingLambdas/UsingLambdas.ino index 62c71b7..94becfc 100644 --- a/third-party/TeensyTimerTool/examples/02_Advanced/UsingLambdas/UsingLambdas.ino +++ b/third-party/TeensyTimerTool/examples/02_Advanced/UsingLambdas/UsingLambdas.ino @@ -6,11 +6,11 @@ using namespace TeensyTimerTool; using namespace pins; pin<13> LED(OUTPUT); -Timer timer; +OneShotTimer timer; void setup() { - timer.beginOneShot([] { LED = LOW; }); + timer.begin([] { LED = LOW; }); } void loop() diff --git a/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/DoubleExposure.ino b/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/DoubleExposure.ino index f50866b..d3e3a48 100644 --- a/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/DoubleExposure.ino +++ b/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/DoubleExposure.ino @@ -1,12 +1,12 @@ -#include "ResponsiveAnalogRead.h" #include "SystemController.h" -constexpr unsigned potPin = A0; -ResponsiveAnalogRead pot(potPin, false); +// --> Uncomment if you have a control voltage on the pot pin <-- +// #include "ResponsiveAnalogRead.h" +// constexpr unsigned potPin = A0; +// ResponsiveAnalogRead pot(potPin, false); SystemController sysControl; - void setup() { sysControl.begin(); @@ -17,12 +17,12 @@ void setup() sysControl.setExposureDelay(500); // same with 500µs delay between exposures sysControl.shoot(); - sysControl.continousMode(true); // start continously shooting + sysControl.continuosMode(true); // start continuously shooting delay(1000); - sysControl.continousMode(false); // stop after one second + sysControl.continuosMode(false); // stop after one second delay(500); - sysControl.continousMode(true); // start again + sysControl.continuosMode(true); // start again } void loop() diff --git a/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/PulseGenerator.h b/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/PulseGenerator.h index db1f5ab..9a1ff34 100644 --- a/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/PulseGenerator.h +++ b/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/PulseGenerator.h @@ -7,7 +7,7 @@ class PulseGenerator { public: PulseGenerator(); // constructor, initializes non hardware related stuff - void begin(unsigned pin); // intializes hardware related stuff + void begin(unsigned pin); // initializes hardware related stuff void schedulePulse(float delay, float width); // schedules a 'width µs' wide pulse after a waiting time of 'delay µs'. Non blocking. protected: @@ -49,7 +49,7 @@ void PulseGenerator::callback() if (digitalReadFast(pin) == LOW) { digitalWriteFast(pin, HIGH); - pulseTimer.trigger(width); // retrigger + pulseTimer.trigger(width); // re-trigger } else { digitalWriteFast(pin, LOW); diff --git a/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/SystemController.h b/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/SystemController.h index efa2c19..c9091b2 100644 --- a/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/SystemController.h +++ b/third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/SystemController.h @@ -9,7 +9,7 @@ class SystemController inline void begin(); inline void shoot(); - inline void continousMode(bool on); + inline void continuosMode(bool on); inline void setExposureDelay(unsigned delay); protected: @@ -26,10 +26,10 @@ void SystemController::begin() constexpr unsigned repetitionRate = 15; // Hz constexpr unsigned preTrig1_pin = 1; - constexpr unsigned trig1_pin = 2; + constexpr unsigned trig1_pin = 2; constexpr unsigned preTrig2_pin = 3; - constexpr unsigned trig2_pin = 4; - constexpr unsigned cam_pin = 5; + constexpr unsigned trig2_pin = 4; + constexpr unsigned cam_pin = 5; lCtrl1.begin(preTrig1_pin, trig1_pin, cam_pin); lCtrl2.begin(preTrig2_pin, trig2_pin, cam_pin); @@ -45,13 +45,12 @@ void SystemController::shoot() lCtrl2.shoot(); } -void SystemController::continousMode(bool on) +void SystemController::continuosMode(bool on) { if (on) { mainTimer.start(); - } - else + } else { mainTimer.stop(); } diff --git a/third-party/TeensyTimerTool/library.json b/third-party/TeensyTimerTool/library.json index 6852714..5fc6f3a 100644 --- a/third-party/TeensyTimerTool/library.json +++ b/third-party/TeensyTimerTool/library.json @@ -14,7 +14,7 @@ "maintainer": true }, "homepage": "https://github.com/luni64/TeensyTimerTool", - "version": "0.4.4", + "version": "1.0.0", "frameworks": "arduino", "platforms": "Teensy" } diff --git a/third-party/TeensyTimerTool/library.properties b/third-party/TeensyTimerTool/library.properties index c910ef7..1931bb0 100644 --- a/third-party/TeensyTimerTool/library.properties +++ b/third-party/TeensyTimerTool/library.properties @@ -1,5 +1,5 @@ name=TeensyTimerTool -version=0.4.4 +version=1.0.0 author=luni64 maintainer=luni64 sentence=Generic Interface to Teensy Timers diff --git a/third-party/TeensyTimerTool/src/API/baseTimer.h b/third-party/TeensyTimerTool/src/API/baseTimer.h index f33caf7..45b8eaa 100644 --- a/third-party/TeensyTimerTool/src/API/baseTimer.h +++ b/third-party/TeensyTimerTool/src/API/baseTimer.h @@ -7,7 +7,7 @@ #include #if defined(USE_TIME_LITERALS) -#include "frequency.h" +//#include "frequency.h" #include #include using namespace std::chrono_literals; diff --git a/third-party/TeensyTimerTool/src/TimerModules/FTM/FTM.h b/third-party/TeensyTimerTool/src/TimerModules/FTM/FTM.h index 32dbe47..0d6b07d 100644 --- a/third-party/TeensyTimerTool/src/TimerModules/FTM/FTM.h +++ b/third-party/TeensyTimerTool/src/TimerModules/FTM/FTM.h @@ -15,9 +15,9 @@ namespace TeensyTimerTool static bool isInitialized; inline static void isr() FASTRUN; - static constexpr FTM_r_t *r = (FTM_r_t *)FTM_Info::baseAdr; static constexpr unsigned maxChannel = FTM_Info::nrOfChannels; static FTM_ChannelInfo channelInfo[maxChannel]; + static FTM_r_t * const r; static_assert(moduleNr < 4, "Module number < 4 required"); }; @@ -88,4 +88,8 @@ namespace TeensyTimerTool template bool FTM_t::isInitialized = false; + + template + FTM_r_t* const FTM_t::r = (FTM_r_t *)FTM_Info::baseAdr; } // namespace TeensyTimerTool + diff --git a/third-party/TeensyTimerTool/src/frequency.h.deactivated b/third-party/TeensyTimerTool/src/frequency.h.deactivated new file mode 100644 index 0000000..832056c --- /dev/null +++ b/third-party/TeensyTimerTool/src/frequency.h.deactivated @@ -0,0 +1,406 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +#pragma once + +#include +#include +#include +#include + +using std::common_type; +using std::enable_if; +using std::is_convertible; +using std::ratio; +using std::ratio_divide; + +namespace TeensyTimerTool +{ + template > + struct frequency; + + template + struct __frequency_common_type_wrapper + { + private: + typedef std::__static_gcd<_Period1::num, _Period2::num> __gcd_num; + typedef std::__static_gcd<_Period1::den, _Period2::den> __gcd_den; + typedef typename _CT::type __cr; + typedef ratio<__gcd_num::value, + (_Period1::den / __gcd_den::value) * _Period2::den> + __r; + + public: + typedef std::__success_type> type; + }; + + template + struct __frequency_common_type_wrapper + { + typedef std::__failure_type type; + }; +} + +namespace std +{ + template + struct common_type, TeensyTimerTool::frequency<_Rep2, _Period2>> + : public TeensyTimerTool::__frequency_common_type_wrapper>::type, _Period1, _Period2>::type + { + }; +} + +namespace TeensyTimerTool +{ + using namespace std::chrono; + + // Primary template for frequency_cast impl. + template + struct __frequency_cast_impl + { + template + static constexpr _ToDur + __cast(const frequency<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num) / static_cast<_CR>(_CF::den))); + } + }; + + template + struct __frequency_cast_impl<_ToDur, _CF, _CR, true, true> + { + template + static constexpr _ToDur + __cast(const frequency<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>(__d.count())); + } + }; + + template + struct __frequency_cast_impl<_ToDur, _CF, _CR, true, false> + { + template + static constexpr _ToDur + __cast(const frequency<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>( + static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den))); + } + }; + + template + struct __frequency_cast_impl<_ToDur, _CF, _CR, false, true> + { + template + static constexpr _ToDur + __cast(const frequency<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>( + static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num))); + } + }; + + template + struct __is_frequency + : std::false_type + { + }; + + template + struct __is_frequency> + : std::true_type + { + }; + + /// duration_cast + template + constexpr typename enable_if<__is_frequency<_ToDur>::value, _ToDur>::type duration_cast(const frequency<_Rep, _Period>& __d) + { + typedef typename _ToDur::period __to_period; + typedef typename _ToDur::rep __to_rep; + typedef ratio_divide<_Period, __to_period> __cf; + typedef typename common_type<__to_rep, _Rep, intmax_t>::type __cr; + typedef __frequency_cast_impl<_ToDur, __cf, __cr, __cf::num == 1, __cf::den == 1> __dc; + + return __dc::__cast(__d); + } + + /// frequency + template + struct frequency + { + typedef _Rep rep; + typedef _Period period; + + static_assert(!__is_frequency<_Rep>::value, "rep cannot be a frequency"); + static_assert(std::chrono::__is_ratio<_Period>::value, "period must be a specialization of ratio"); + static_assert(_Period::num > 0, "period must be positive"); + + // 20.11.5.1 construction / copy / destroy + constexpr frequency() = default; + + // NB: Make constexpr implicit. This cannot be explicitly + // constexpr, as any UDT that is not a literal type with a + // constexpr copy constructor will be ill-formed. + frequency(const frequency&) = default; + + template ::value && (std::chrono::treat_as_floating_point::value || !std::chrono::treat_as_floating_point<_Rep2>::value)>::type> + constexpr explicit frequency(const _Rep2& __rep) + : __r(static_cast(__rep)) + { + } + + template ::value || (ratio_divide<_Period2, period>::den == 1 && !treat_as_floating_point<_Rep2>::value)>::type> + constexpr frequency(const frequency<_Rep2, _Period2>& __d) + : __r(duration_cast(__d).count()) {} + + ~frequency() = default; + frequency& operator=(const frequency&) = default; + + // 20.11.5.2 observer + constexpr rep count() const { return __r; } + + constexpr frequency operator+() const { return *this; } + constexpr frequency operator-() const { return frequency(-__r); } + + frequency& operator++() + { + ++__r; + return *this; + } + + frequency operator++(int) + { + return frequency(__r++); + } + + frequency& operator--() + { + --__r; + return *this; + } + + frequency + operator--(int) + { + return frequency(__r--); + } + + frequency& + operator+=(const frequency& __d) + { + __r += __d.count(); + return *this; + } + + frequency& + operator-=(const frequency& __d) + { + __r -= __d.count(); + return *this; + } + + frequency& + operator*=(const rep& __rhs) + { + __r *= __rhs; + return *this; + } + + frequency& + operator/=(const rep& __rhs) + { + __r /= __rhs; + return *this; + } + + // DR 934. + template + typename enable_if::value, + frequency&>::type + operator%=(const rep& __rhs) + { + __r %= __rhs; + return *this; + } + + template + typename enable_if::value, + frequency&>::type + operator%=(const frequency& __d) + { + __r %= __d.count(); + return *this; + } + + // 20.11.5.4 special values + static constexpr frequency + zero() + { + return frequency(duration_values::zero()); + } + + static constexpr frequency + min() + { + return frequency(duration_values::min()); + } + + static constexpr frequency + max() + { + return frequency(duration_values::max()); + } + + private: + rep __r; + }; + + template + constexpr typename common_type, frequency<_Rep2, _Period2>>::type operator+(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + typedef frequency<_Rep1, _Period1> __dur1; + typedef frequency<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1, __dur2>::type __cd; + return __cd(__cd(__lhs).count() + __cd(__rhs).count()); + } + + template + constexpr typename common_type, frequency<_Rep2, _Period2>>::type operator-(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + typedef frequency<_Rep1, _Period1> __dur1; + typedef frequency<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1, __dur2>::type __cd; + return __cd(__cd(__lhs).count() - __cd(__rhs).count()); + } + + template + constexpr frequency::type, _Period> operator*(const frequency<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef frequency::type, _Period> __cd; + return __cd(__cd(__d).count() * __s); + } + + template + constexpr frequency::type, _Period> operator*(const _Rep1& __s, const frequency<_Rep2, _Period>& __d) + { + return __d * __s; + } + + template + constexpr frequency::value, _Rep2>::type>::type, _Period> operator/(const frequency<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef frequency::type, _Period> __cd; + return __cd(__cd(__d).count() / __s); + } + + template + constexpr typename common_type<_Rep1, _Rep2>::type operator/(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + typedef frequency<_Rep1, _Period1> __dur1; + typedef frequency<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1, __dur2>::type __cd; + return __cd(__lhs).count() / __cd(__rhs).count(); + } + + // DR 934. + template + constexpr frequency::value, _Rep2>::type>::type, _Period> operator%(const frequency<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef frequency::type, _Period> __cd; + return __cd(__cd(__d).count() % __s); + } + + template + constexpr typename common_type, frequency<_Rep2, _Period2>>::type operator%(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + typedef frequency<_Rep1, _Period1> __dur1; + typedef frequency<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1, __dur2>::type __cd; + return __cd(__cd(__lhs).count() % __cd(__rhs).count()); + } + + // comparisons + template + constexpr bool operator==(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + typedef frequency<_Rep1, _Period1> __dur1; + typedef frequency<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1, __dur2>::type __ct; + return __ct(__lhs).count() == __ct(__rhs).count(); + } + + template + constexpr bool operator<(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + typedef frequency<_Rep1, _Period1> __dur1; + typedef frequency<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1, __dur2>::type __ct; + return __ct(__lhs).count() < __ct(__rhs).count(); + } + + template + constexpr bool operator!=(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + return !(__lhs == __rhs); + } + + template + constexpr bool operator<=(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + return !(__rhs < __lhs); + } + + template + constexpr bool operator>(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + return __rhs < __lhs; + } + + template + constexpr bool operator>=(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs) + { + return !(__lhs < __rhs); + } + + using hertz = frequency; + using kilohertz = frequency; + using megahertz = frequency; + using gigahertz = frequency; + + constexpr hertz operator""_Hz(long double hz) { return hertz{hz}; } + constexpr hertz operator""_Hz(uint64_t hz) { return hertz{hz}; } + constexpr kilohertz operator""_kHz(long double kHz) { return kilohertz{kHz}; } + constexpr kilohertz operator""_kHz(uint64_t kHz) { return kilohertz{kHz}; } + constexpr megahertz operator""_MHz(long double MHz) { return megahertz{MHz}; } + constexpr megahertz operator""_MHz(uint64_t MHz) { return megahertz{MHz}; } + constexpr gigahertz operator""_GHz(long double GHz) { return gigahertz{GHz}; } + constexpr gigahertz operator""_GHz(uint64_t GHz) { return gigahertz{GHz}; } +} diff --git a/third-party/TeensyTimerTool/src/helpers.h b/third-party/TeensyTimerTool/src/helpers.h index cdedbad..1a8a90f 100644 --- a/third-party/TeensyTimerTool/src/helpers.h +++ b/third-party/TeensyTimerTool/src/helpers.h @@ -4,7 +4,6 @@ #include #if defined(USE_TIME_LITERALS) -#include "frequency.h" #include #endif @@ -27,15 +26,11 @@ namespace TeensyTimerTool template ::value, int> * = nullptr> float constexpr period2us(period_t v) { + using namespace std::chrono; return (duration_cast>(v).count()); } - // Frequency types (Hz, MHz...) - template ::value, int> * = nullptr> - float constexpr period2us(period_t v) - { - return 1'000'000 / duration_cast(v).count(); - } + #endif } // namespace TeensyTimerTool \ No newline at end of file diff --git a/third-party/TeensyTimerTool/test/main.cpp b/third-party/TeensyTimerTool/test/main.cpp new file mode 100644 index 0000000..1a145de --- /dev/null +++ b/third-party/TeensyTimerTool/test/main.cpp @@ -0,0 +1,17 @@ +#include "Arduino.h" + +// General ============================================================================================= +//#include "../lib/TeensyTimerTool/examples/01_Basic/HelloPeriodic/HelloPeriodic.ino" +//#include "../lib/TeensyTimerTool/examples/01_Basic/HelloOneShot/HelloOneShot.ino" +//#include "../lib/TeensyTimerTool/examples/01_Basic/UsingChronoDurations1/UsingChronoDurations1.ino" +//#include "../lib/TeensyTimerTool/examples/01_Basic/UsingChronoDurations2/UsingChronoDurations2.ino" +//#include "../lib/TeensyTimerTool/examples/02_Advanced/CallbackWithParams/CallbackWithParams.ino" +//#include "../lib/TeensyTimerTool/examples/02_Advanced/UsingLambdas/UsingLambdas.ino" + +//T3.x ================================================================================================ +//#include "../lib/TeensyTimerTool/examples/03_Applications/DoubleExposure/DoubleExposure.ino" + +//T4.x ================================================================================================ +//#include "../lib/TeensyTimerTool/examples/01_Basic/MoreTimers/MoreTimers.ino" +//#include "../lib/TeensyTimerTool/examples/01_Basic/RTC_Timer/RTC_Timer.ino" +//#include "../lib/TeensyTimerTool/examples/99_Misc/PinInformation/PinInformation.ino"