-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clock] Add std::chrono compatible milli- and microsecond clocks
- Loading branch information
Showing
161 changed files
with
1,777 additions
and
1,706 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
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
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,58 @@ | ||
/* | ||
* Copyright (c) 2020, Niklas Hauser | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#include <modm/board.hpp> | ||
#include <modm/processing.hpp> | ||
|
||
int main() | ||
{ | ||
Board::initialize(); | ||
|
||
uint32_t counter(0); | ||
modm::PrecisePeriodicTimer ptmr(0.500990s); | ||
modm::PeriodicTimer tmr(0.500990s); | ||
|
||
for (int ii=0; ii<20; ii++) | ||
{ | ||
LedD13::toggle(); | ||
modm::delay(std::chrono::milliseconds(10*ii)); | ||
} | ||
|
||
uint32_t ms_counter{0}; | ||
uint32_t us_counter{0}; | ||
|
||
while (true) | ||
{ | ||
{ | ||
uint32_t ms = modm::Clock::now().time_since_epoch().count(); | ||
if (ms < ms_counter) { | ||
MODM_LOG_ERROR << ms << " < " << ms_counter << modm::endl; | ||
} | ||
ms_counter = ms; | ||
}{ | ||
uint32_t us = modm::PreciseClock::now().time_since_epoch().count(); | ||
if (us < us_counter) { | ||
MODM_LOG_ERROR << us << " < " << us_counter << modm::endl; | ||
} | ||
us_counter = us; | ||
} | ||
|
||
if (ptmr.execute()) | ||
{ | ||
LedD13::set(); | ||
MODM_LOG_INFO << "loop: " << counter++ << modm::endl; | ||
} | ||
if (tmr.execute()) | ||
{ | ||
LedD13::reset(); | ||
} | ||
} | ||
} |
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,12 @@ | ||
<library> | ||
<extends>modm:arduino-nano</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/avr/timer</option> | ||
</options> | ||
<modules> | ||
<module>modm:architecture:delay</module> | ||
<module>modm:processing:timer</module> | ||
<module>modm:build:scons</module> | ||
<module>modm:build:cmake</module> | ||
</modules> | ||
</library> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.