This https://github.com/manitou48/teensy4 is always a good starting point if you need to do some low level programming. It contains some examples for input capture using the GPT module
Sorry, didn't mention that the library lives on GitHub. https://github.com/luni64/TeensyTimerTool,
And here an instructiion on how to install if from there: https://roboticsbackend.com/install-arduino-library-from-github/
I'll update the...
Actually you can by using anonymous namespaces. Here an example:
test.h
#pragma once
namespace someNamespace
{
extern int getVar();
extern int publicVar;
}
test.cpp
namespace someNamespace
{
namespace // anonymous/private namespace...
@joepasquariello. Yes this is a lambda expression. Here some explanation about the origin of the name: https://www.baeldung.com/cs/lambda-functions .
Actually the c++ syntax for lambdas is quite simple and logical. Here the full (AFAIK) syntax...
Sorry, that was a bug. Can you try version 1.4.3?
The following code correctly generates 500kHz signals on pin 0 and 1 using the PIT and GPT1 modules. It works for 24Mhz and 150MHz clock frequency settings.
#include "TeensyTimerTool.h"
using...
... or, if you don't like std::function / std::bind you can simply use a lambda:
void timeit(void(*f)())
{
elapsedMillis time;
f();
printf("took %d\n", (unsigned)time);
}
void g1(){
delay(120);
}
void g2(int x){
delay(x);
}...
You can also use std::function and std::bind to achieve this without macros:
#include <functional>
void timeit(std::function<void()> f)
{
elapsedMillis time;
f();
printf("took %d\n", (unsigned)time);
}
void g1(){
delay(120);
}...
Changing the c-library would obviously require a lot of testing. And I still believe that Paul had a good reason for using newlib in the first place. So I don't think this will happen soon (if ever). IMOH, the workaround suggested by @jmarsh...
Hi @luni
I switched to newlib-nano and enabled _printf_float and _scanf_float. The difference is enormous
Before:
teensy_size: Memory Usage on Teensy 4.1:
teensy_size: FLASH: code:419516, data:281120, headers:8992 free for files:7416836...
There probably are good reasons to use newlib instead of newlib-nano by default. I'm just wondering because ARM developped it for use in embedded processors as opposed to newlib which is meant for linux. The missing float printf / scanf can be...
Seems to be the same issue as discussed here:
https://forum.pjrc.com/index.php?threads/compile-once-warning-s-compile-again-no-warnings.74822/post-341746
@shawn: the "smallest-code" option uses the nano version of newlib which is optimized for embedded systems. You can switch to it using the compiler switch --specs = nano.specs. Looks like newlib-nano doesn't have the exception stuff compied in...
Even though the c++ compiler is passed switches like "-fnoexceptions -fno-rtti -fno-threadsafe-statics", the copy of libstdc++ that gets linked by Teensyduino was still built with exceptions enabled and includes a bunch of cruft associated with...
Since you are doing a c# application you might be interested in TeensySharp.
https://github.com/luni64/TeensySharp
Getting a list of currently connected Teensies is a simple as this:
var Watcher = new TeensyWatcher();
foreach (var Teensy in...