Added new version of TeensyTimerTool.

dev
Holger Wirtz 2 years ago
parent fdf072be0d
commit b35ec52405
  1. 16
      third-party/TeensyTimerTool/examples/01_Basic/HelloPeriodic/HelloPeriodic.ino
  2. 25
      third-party/TeensyTimerTool/examples/01_Basic/MoreTimers/MoreTimers.ino
  3. 1
      third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations1/UsingChronoDurations1.ino
  4. 2
      third-party/TeensyTimerTool/examples/01_Basic/UsingChronoDurations2/UsingChronoDurations2.ino
  5. 6
      third-party/TeensyTimerTool/examples/02_Advanced/CallbackWithParams/CallbackWithParams.ino
  6. 4
      third-party/TeensyTimerTool/examples/02_Advanced/UsingLambdas/UsingLambdas.ino
  7. 14
      third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/DoubleExposure.ino
  8. 4
      third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/PulseGenerator.h
  9. 13
      third-party/TeensyTimerTool/examples/03_Applications/DoubleExposure/SystemController.h
  10. 2
      third-party/TeensyTimerTool/library.json
  11. 2
      third-party/TeensyTimerTool/library.properties
  12. 2
      third-party/TeensyTimerTool/src/API/baseTimer.h
  13. 6
      third-party/TeensyTimerTool/src/TimerModules/FTM/FTM.h
  14. 406
      third-party/TeensyTimerTool/src/frequency.h.deactivated
  15. 9
      third-party/TeensyTimerTool/src/helpers.h
  16. 17
      third-party/TeensyTimerTool/test/main.cpp

@ -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()
{
{
}

@ -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()
{
{
}

@ -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()

@ -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()

@ -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()

@ -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()

@ -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()

@ -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);

@ -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();
}

@ -14,7 +14,7 @@
"maintainer": true
},
"homepage": "https://github.com/luni64/TeensyTimerTool",
"version": "0.4.4",
"version": "1.0.0",
"frameworks": "arduino",
"platforms": "Teensy"
}

@ -1,5 +1,5 @@
name=TeensyTimerTool
version=0.4.4
version=1.0.0
author=luni64
maintainer=luni64
sentence=Generic Interface to Teensy Timers

@ -7,7 +7,7 @@
#include <type_traits>
#if defined(USE_TIME_LITERALS)
#include "frequency.h"
//#include "frequency.h"
#include <chrono>
#include <cmath>
using namespace std::chrono_literals;

@ -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<moduleNr>::baseAdr;
static constexpr unsigned maxChannel = FTM_Info<moduleNr>::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 <unsigned m>
bool FTM_t<m>::isInitialized = false;
template <unsigned m>
FTM_r_t* const FTM_t<m>::r = (FTM_r_t *)FTM_Info<m>::baseAdr;
} // namespace TeensyTimerTool

@ -0,0 +1,406 @@
// <chrono> -*- 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
// <http://www.gnu.org/licenses/>.
#pragma once
#include <chrono>
#include <limits>
#include <ratio>
#include <type_traits>
using std::common_type;
using std::enable_if;
using std::is_convertible;
using std::ratio;
using std::ratio_divide;
namespace TeensyTimerTool
{
template <typename _Rep, typename _Period = ratio<1>>
struct frequency;
template <typename _CT, typename _Period1, typename _Period2>
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<TeensyTimerTool::frequency<__cr, __r>> type;
};
template <typename _Period1, typename _Period2>
struct __frequency_common_type_wrapper<std::__failure_type, _Period1, _Period2>
{
typedef std::__failure_type type;
};
}
namespace std
{
template <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
struct common_type<TeensyTimerTool::frequency<_Rep1, _Period1>, TeensyTimerTool::frequency<_Rep2, _Period2>>
: public TeensyTimerTool::__frequency_common_type_wrapper<typename __member_type_wrapper<std::common_type<_Rep1, _Rep2>>::type, _Period1, _Period2>::type
{
};
}
namespace TeensyTimerTool
{
using namespace std::chrono;
// Primary template for frequency_cast impl.
template <typename _ToDur, typename _CF, typename _CR,
bool _NumIsOne = false, bool _DenIsOne = false>
struct __frequency_cast_impl
{
template <typename _Rep, typename _Period>
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 <typename _ToDur, typename _CF, typename _CR>
struct __frequency_cast_impl<_ToDur, _CF, _CR, true, true>
{
template <typename _Rep, typename _Period>
static constexpr _ToDur
__cast(const frequency<_Rep, _Period>& __d)
{
typedef typename _ToDur::rep __to_rep;
return _ToDur(static_cast<__to_rep>(__d.count()));
}
};
template <typename _ToDur, typename _CF, typename _CR>
struct __frequency_cast_impl<_ToDur, _CF, _CR, true, false>
{
template <typename _Rep, typename _Period>
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 <typename _ToDur, typename _CF, typename _CR>
struct __frequency_cast_impl<_ToDur, _CF, _CR, false, true>
{
template <typename _Rep, typename _Period>
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 <typename _Tp>
struct __is_frequency
: std::false_type
{
};
template <typename _Rep, typename _Period>
struct __is_frequency<frequency<_Rep, _Period>>
: std::true_type
{
};
/// duration_cast
template <typename _ToDur, typename _Rep, typename _Period>
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 <typename _Rep, typename _Period>
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 <typename _Rep2, typename = typename enable_if<is_convertible<_Rep2, rep>::value && (std::chrono::treat_as_floating_point<rep>::value || !std::chrono::treat_as_floating_point<_Rep2>::value)>::type>
constexpr explicit frequency(const _Rep2& __rep)
: __r(static_cast<rep>(__rep))
{
}
template <typename _Rep2, typename _Period2, typename = typename enable_if<treat_as_floating_point<rep>::value || (ratio_divide<_Period2, period>::den == 1 && !treat_as_floating_point<_Rep2>::value)>::type>
constexpr frequency(const frequency<_Rep2, _Period2>& __d)
: __r(duration_cast<frequency>(__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 _Rep2 = rep>
typename enable_if<!treat_as_floating_point<_Rep2>::value,
frequency&>::type
operator%=(const rep& __rhs)
{
__r %= __rhs;
return *this;
}
template <typename _Rep2 = rep>
typename enable_if<!treat_as_floating_point<_Rep2>::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<rep>::zero());
}
static constexpr frequency
min()
{
return frequency(duration_values<rep>::min());
}
static constexpr frequency
max()
{
return frequency(duration_values<rep>::max());
}
private:
rep __r;
};
template <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
constexpr typename common_type<frequency<_Rep1, _Period1>, 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 <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
constexpr typename common_type<frequency<_Rep1, _Period1>, 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 <typename _Rep1, typename _Period, typename _Rep2>
constexpr frequency<typename __common_rep_type<_Rep1, _Rep2>::type, _Period> operator*(const frequency<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef frequency<typename common_type<_Rep1, _Rep2>::type, _Period> __cd;
return __cd(__cd(__d).count() * __s);
}
template <typename _Rep1, typename _Rep2, typename _Period>
constexpr frequency<typename __common_rep_type<_Rep2, _Rep1>::type, _Period> operator*(const _Rep1& __s, const frequency<_Rep2, _Period>& __d)
{
return __d * __s;
}
template <typename _Rep1, typename _Period, typename _Rep2>
constexpr frequency<typename __common_rep_type<_Rep1, typename enable_if<!__is_frequency<_Rep2>::value, _Rep2>::type>::type, _Period> operator/(const frequency<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef frequency<typename common_type<_Rep1, _Rep2>::type, _Period> __cd;
return __cd(__cd(__d).count() / __s);
}
template <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
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 <typename _Rep1, typename _Period, typename _Rep2>
constexpr frequency<typename __common_rep_type<_Rep1, typename enable_if<!__is_frequency<_Rep2>::value, _Rep2>::type>::type, _Period> operator%(const frequency<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef frequency<typename common_type<_Rep1, _Rep2>::type, _Period> __cd;
return __cd(__cd(__d).count() % __s);
}
template <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
constexpr typename common_type<frequency<_Rep1, _Period1>, 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 <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
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 <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
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 <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
constexpr bool operator!=(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs)
{
return !(__lhs == __rhs);
}
template <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
constexpr bool operator<=(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs)
{
return !(__rhs < __lhs);
}
template <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
constexpr bool operator>(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs)
{
return __rhs < __lhs;
}
template <typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
constexpr bool operator>=(const frequency<_Rep1, _Period1>& __lhs, const frequency<_Rep2, _Period2>& __rhs)
{
return !(__lhs < __rhs);
}
using hertz = frequency<float>;
using kilohertz = frequency<float, std::kilo>;
using megahertz = frequency<float, std::mega>;
using gigahertz = frequency<float, std::giga>;
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}; }
}

@ -4,7 +4,6 @@
#include <type_traits>
#if defined(USE_TIME_LITERALS)
#include "frequency.h"
#include <chrono>
#endif
@ -27,15 +26,11 @@ namespace TeensyTimerTool
template <class period_t, std::enable_if_t<std::chrono::__is_duration<period_t>::value, int> * = nullptr>
float constexpr period2us(period_t v)
{
using namespace std::chrono;
return (duration_cast<duration<float, std::micro>>(v).count());
}
// Frequency types (Hz, MHz...)
template <class period_t, std::enable_if_t<TeensyTimerTool::__is_frequency<period_t>::value, int> * = nullptr>
float constexpr period2us(period_t v)
{
return 1'000'000 / duration_cast<hertz>(v).count();
}
#endif
} // namespace TeensyTimerTool

@ -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"
Loading…
Cancel
Save