From f0b51dfb00933943ee3fdeb614d59b265c622668 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 13 Oct 2018 11:23:53 +0200 Subject: [PATCH] Rearrange the file layout in preparation of becoming a monorepo Move the documentation to `doc/plugin/CycleTimeReport.md`, sources under `src/kaleidoscope/plugin/` (appropriately namespaced). This is in preparation of merging plugins into a single monorepo. Signed-off-by: Gergely Nagy --- README.md | 52 +----------------- doc/plugin/CycleTimeReport.md | 53 +++++++++++++++++++ src/Kaleidoscope-CycleTimeReport.h | 2 +- .../{ => plugin}/CycleTimeReport.cpp | 4 +- .../{ => plugin}/CycleTimeReport.h | 4 +- 5 files changed, 61 insertions(+), 54 deletions(-) create mode 100644 doc/plugin/CycleTimeReport.md rename src/kaleidoscope/{ => plugin}/CycleTimeReport.cpp (95%) rename src/kaleidoscope/{ => plugin}/CycleTimeReport.h (93%) diff --git a/README.md b/README.md index 49694cb6..804f20e2 100644 --- a/README.md +++ b/README.md @@ -5,54 +5,4 @@ [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-CycleTimeReport.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-CycleTimeReport -A development and debugging aid, this plugin will measure average mainloop times -(in microseconds) and print it to `Serial` periodically. While not the most -reliable way to measure the speed of processing, it gives a reasonable -indication nevertheless. - -## Using the plugin - -The plugin comes with reasonable defaults (see below), and can be used out of -the box, without any further configuration: - -```c++ -#include -#include - -KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport); - -void setup (void) { - Serial.begin(9600); - Kaleidoscope.setup (); -} -``` - -## Plugin methods - -The plugin provides a single object, `CycleTimeReport`, with the following -property. All times are in milliseconds. - -### `.average_loop_time` - -> A read-only by contract value, the average time of main loop lengths between -> two reports. - -## Overrideable methods - -### `cycleTimeReport()` - -> Reports the average loop time. By default, it does so over `Serial`, every -> time when the report period is up. -> -> It can be overridden, to change how the report looks, or to make the report -> toggleable, among other things. -> -> It takes no arguments, and returns nothing, but has access to -> `CycleTimeReport.average_loop_time` above. - -## Further reading - -Starting from the [example][plugin:example] is the recommended way of getting -started with the plugin. - - [plugin:example]: https://github.com/keyboardio/Kaleidoscope-CycleTimeReport/blob/master/examples/CycleTimeReport/CycleTimeReport.ino +See [doc/plugin/CycleTimeReport.md](doc/plugin/CycleTimeReport.md) for documentation. diff --git a/doc/plugin/CycleTimeReport.md b/doc/plugin/CycleTimeReport.md new file mode 100644 index 00000000..084f07e3 --- /dev/null +++ b/doc/plugin/CycleTimeReport.md @@ -0,0 +1,53 @@ +# Kaleidoscope-CycleTimeReport + +A development and debugging aid, this plugin will measure average mainloop times +(in microseconds) and print it to `Serial` periodically. While not the most +reliable way to measure the speed of processing, it gives a reasonable +indication nevertheless. + +## Using the plugin + +The plugin comes with reasonable defaults (see below), and can be used out of +the box, without any further configuration: + +```c++ +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport); + +void setup (void) { + Serial.begin(9600); + Kaleidoscope.setup (); +} +``` + +## Plugin methods + +The plugin provides a single object, `CycleTimeReport`, with the following +property. All times are in milliseconds. + +### `.average_loop_time` + +> A read-only by contract value, the average time of main loop lengths between +> two reports. + +## Overrideable methods + +### `cycleTimeReport()` + +> Reports the average loop time. By default, it does so over `Serial`, every +> time when the report period is up. +> +> It can be overridden, to change how the report looks, or to make the report +> toggleable, among other things. +> +> It takes no arguments, and returns nothing, but has access to +> `CycleTimeReport.average_loop_time` above. + +## Further reading + +Starting from the [example][plugin:example] is the recommended way of getting +started with the plugin. + + [plugin:example]: https://github.com/keyboardio/Kaleidoscope-CycleTimeReport/blob/master/examples/CycleTimeReport/CycleTimeReport.ino diff --git a/src/Kaleidoscope-CycleTimeReport.h b/src/Kaleidoscope-CycleTimeReport.h index 173752db..2bd90c18 100644 --- a/src/Kaleidoscope-CycleTimeReport.h +++ b/src/Kaleidoscope-CycleTimeReport.h @@ -17,4 +17,4 @@ #pragma once -#include +#include diff --git a/src/kaleidoscope/CycleTimeReport.cpp b/src/kaleidoscope/plugin/CycleTimeReport.cpp similarity index 95% rename from src/kaleidoscope/CycleTimeReport.cpp rename to src/kaleidoscope/plugin/CycleTimeReport.cpp index 896c3572..7401789d 100644 --- a/src/kaleidoscope/CycleTimeReport.cpp +++ b/src/kaleidoscope/plugin/CycleTimeReport.cpp @@ -18,6 +18,7 @@ #include namespace kaleidoscope { +namespace plugin { uint32_t CycleTimeReport::next_report_time_; uint32_t CycleTimeReport::loop_start_time_; uint32_t CycleTimeReport::average_loop_time; @@ -50,6 +51,7 @@ EventHandlerResult CycleTimeReport::afterEachCycle() { return EventHandlerResult::OK; } +} } __attribute__((weak)) void cycleTimeReport(void) { @@ -57,4 +59,4 @@ __attribute__((weak)) void cycleTimeReport(void) { Serial.println(CycleTimeReport.average_loop_time); } -kaleidoscope::CycleTimeReport CycleTimeReport; +kaleidoscope::plugin::CycleTimeReport CycleTimeReport; diff --git a/src/kaleidoscope/CycleTimeReport.h b/src/kaleidoscope/plugin/CycleTimeReport.h similarity index 93% rename from src/kaleidoscope/CycleTimeReport.h rename to src/kaleidoscope/plugin/CycleTimeReport.h index 6d1e2d32..d643574b 100644 --- a/src/kaleidoscope/CycleTimeReport.h +++ b/src/kaleidoscope/plugin/CycleTimeReport.h @@ -20,6 +20,7 @@ #include namespace kaleidoscope { +namespace plugin { class CycleTimeReport : public kaleidoscope::Plugin { public: CycleTimeReport() {} @@ -35,7 +36,8 @@ class CycleTimeReport : public kaleidoscope::Plugin { static uint32_t loop_start_time_; }; } +} void cycleTimeReport(void); -extern kaleidoscope::CycleTimeReport CycleTimeReport; +extern kaleidoscope::plugin::CycleTimeReport CycleTimeReport;