-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4ada2d
commit f31708f
Showing
12 changed files
with
372 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <TimersOneForAll.h> | ||
//上传前在7号和8号引脚连接LED灯 | ||
constexpr uint8_t LED1 = 7; | ||
constexpr uint8_t LED2 = 8; | ||
void setup() | ||
{ | ||
pinMode(LED1, OUTPUT); | ||
pinMode(LED2, OUTPUT); | ||
digitalWrite(LED1, HIGH); | ||
//在8号引脚的LED灯上生成方波,高低电平时长动态随机生成 | ||
randomSeed(analogRead(6)); | ||
TimersOneForAll::SquareWave<3, LED2>(random(5000), random(5000)); | ||
} | ||
void loop() | ||
{ | ||
static bool CurrentState = HIGH; | ||
//在7号引脚的LED灯上生成即时随机的闪烁,每次都重新随机 | ||
TimersOneForAll::Delay<1>(random(10000)); | ||
digitalWrite(LED1, CurrentState = CurrentState ? LOW : HIGH); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <Arduino.h> | ||
void SerialWrite(uint8_t Value) | ||
{ | ||
Serial.write(Value); | ||
} | ||
void SerialWrite(uint16_t Value) | ||
{ | ||
Serial.write((uint8_t *)&Value, 2); | ||
} | ||
void SerialWrite(uint32_t Value) | ||
{ | ||
Serial.write((uint8_t *)&Value, 4); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
#pragma once | ||
#include "Kernel.h" | ||
namespace TimersOneForAll | ||
{ | ||
{ | ||
//在指定毫秒数后执行任务 | ||
template <uint8_t TimerCode, uint16_t AfterMilliseconds, void (*DoTask)()> | ||
void DoAfter() | ||
{ | ||
constexpr Internal::TimerSetting TS = Internal::GetTimerSetting(TimerCode, AfterMilliseconds); | ||
Internal::SLRepeaterSet<TimerCode, TS.TCNT, TS.PrescalerBits, DoTask, 1>(); | ||
} | ||
//在指定毫秒数后执行任务 | ||
template <uint8_t TimerCode, void (*DoTask)()> | ||
void DoAfter(uint16_t AfterMilliseconds) | ||
{ | ||
Internal::TimerSetting TS = Internal::GetTimerSetting<TimerCode>(AfterMilliseconds); | ||
Internal::SLRepeaterSet<TimerCode, DoTask, 1>(TS.TCNT, TS.PrescalerBits); | ||
} | ||
} |
Oops, something went wrong.