From c24e1211b83655e3db7996c5f7c20d311a55d9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9F=83=E5=8D=9A=E6=8B=89=E9=85=B1?= Date: Thu, 22 Dec 2022 21:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 37 ++++++++++++++++++++----------------- keywords.txt | 4 +++- library.properties | 4 ++-- src/Internal/ShutDown.h | 2 +- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8bf3ddd..f3d410c 100644 --- a/README.md +++ b/README.md @@ -56,30 +56,25 @@ If you encounter an error similar to `undefined reference to TIMSK` when linking ```C++ //在指定的毫秒数后触发一个计时器中断,调用你的函数。 //Call your function with a timer interrupt after given milliseconds -template -void DoAfter(); +template +void DoAfter(void (*DoTask)()); //允许运行时动态设置毫秒数 //Specify milliseconds at runtime -template -void DoAfter(uint16_t AfterMilliseconds); +template +void DoAfter(uint16_t AfterMilliseconds, void (*DoTask)()); //每隔指定的毫秒数,无限重复调用你的函数。第一次调用也将在那个毫秒数之后发生。 //Repetitively and infinitely call your function with a timer interrupt for each IntervalMilliseconds. The first interrupt happens after IntervalMilliseconds, too. -template -void RepeatAfter(); -//仅重复有限次数,重复全部结束后触发DoneCallback回调 -//Repeat for only RepeatTimes. After all repeats done, DoneCallback is called. -template -void RepeatAfter(); +template +void RepeatAfter(void (*DoTask)()) //允许运行时动态设置毫秒数。重复次数不指定的话则为无限重复。重复全部结束后触发DoneCallback回调 //Specify milliseconds at runtime. After all repeats done, DoneCallback is called. -template -void RepeatAfter(uint16_t IntervalMilliseconds); -//每隔指定毫秒数重复执行任务。重复次数若为负数,或不指定重复次数,则默认无限重复 -template -void RepeatAfter(int32_t RepeatTimes); +template +void RepeatAfter(uint16_t IntervalMilliseconds, void (*DoTask)()) +//仅重复有限次数,重复全部结束后触发DoneCallback回调 +//Repeat for only RepeatTimes. After all repeats done, DoneCallback is called. +template +void RepeatAfter(int32_t RepeatTimes, void (*DoTask)()) //将当前时刻设为0,计量经过的毫秒数。读取MillisecondsElapsed变量来获得经过的毫秒数。可选设置MillisecondsPerTick,控制计时单位是多少毫秒 //Set the time now as 0 and start to record time elapsed. Read MillisecondsElapsed variable to get the time elapsed. @@ -137,4 +132,12 @@ void Delay(uint16_t DelayMilliseconds); //Abort all tasks assigned to TimerCode. Other timers won't be affected. template void ShutDown(); +//暂停指定计时器上的任务 +//Pause the task on the specified timer +template +void Pause(); +//继续指定计时器上的任务。如果继续一个未处于暂停状态的计时器,将产生未定义行为。 +//Continue the task on the specified timer. If you continue a timer that is not in a paused state, undefined behavior occurs. +template +void Continue(); ``` diff --git a/keywords.txt b/keywords.txt index d18bfee..82d7710 100644 --- a/keywords.txt +++ b/keywords.txt @@ -1,12 +1,14 @@ # Datatypes (KEYWORD1) # Functions (KEYWORD2) -DoAfter KEYWORD2 +DoAfter KEYWORD2 RepeatAfter KEYWORD2 StartTiming KEYWORD2 PlayTone KEYWORD2 SquareWave KEYWORD2 ShutDown KEYWORD2 +Pause KEYWORD2 +Continue KEYWORD2 # Structures (KEYWORD3) # Constants (LITERAL1) diff --git a/library.properties b/library.properties index 4653641..595b0ef 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=TimersOneForAll -version=1.5.1 +version=2.0.0 author=EbolaChan maintainer=EbolaChan sentence=Make full use of all your hardware timers on your Arduino board. 充分利用你开发板上所有的硬件计时器 -paragraph=*You must enable C++17 for your IDE. Open "%LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\1.8.3\platform.txt" and change the argument "-std=gnu++11" to -std=gnu++17.* Delayed task, repetitive delayed task, tones, square waves, timing by milliseconds. Hardware interrupt that can break into any running code accurately at the time you set. Specify which hardware timer to use, all with 1/16 microsecond accuracy. Allocate them to different tasks so that they run simultaneously without conflicts. Currently only support timing for less than 1 minute. *您必须为您的 IDE 启用 C++17。打开“%LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\1.8.3\platform.txt”并将参数“-std=gnu++11”更改为-std=gnu++17。* 延迟任务,重复任务,音调,方波,毫秒秒表,可以自由指定互不冲突的独立硬件计时器,硬件中断,事件驱动。 +paragraph=(Uno & Mega 2560) *You must enable C++17 for your IDE. Open "%LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\1.8.3\platform.txt" and change the argument "-std=gnu++11" to -std=gnu++17.* Delayed task, repetitive delayed task, tones, square waves, timing by milliseconds. Hardware interrupt that can break into any running code accurately at the time you set. Specify which hardware timer to use, all with 1/16 microsecond accuracy. Allocate them to different tasks so that they run simultaneously without conflicts. Currently only support timing for less than 1 minute. *您必须为您的 IDE 启用 C++17。打开“%LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\1.8.3\platform.txt”并将参数“-std=gnu++11”更改为-std=gnu++17。* 延迟任务,重复任务,音调,方波,毫秒秒表,可以自由指定互不冲突的独立硬件计时器,硬件中断,事件驱动。 category=Timing url=https://github.com/Silver-Fang/TimersOneForAll architectures=avr diff --git a/src/Internal/ShutDown.h b/src/Internal/ShutDown.h index 4d37fc5..687256c 100644 --- a/src/Internal/ShutDown.h +++ b/src/Internal/ShutDown.h @@ -23,7 +23,7 @@ namespace TimersOneForAll Internal::TIMSK = 0; Internal::PauseTCNT = Internal::GetTCNT(); } - //继续指定计时器上的任务。如果继续一个未处于暂停状态的计时器,将产生未知行为。 + //继续指定计时器上的任务。如果继续一个未处于暂停状态的计时器,将产生未定义行为。 template void Continue() {