commit
219f28ba99
@ -0,0 +1,4 @@
|
||||
.#*
|
||||
*~
|
||||
/hardware/
|
||||
/output/
|
@ -0,0 +1,13 @@
|
||||
# This stub makefile for a Kaleidoscope plugin pulls in
|
||||
# all targets from the Kaleidoscope-Plugin library
|
||||
|
||||
MAKEFILE_PREFIX=keyboardio/avr/libraries/Kaleidoscope-Plugin/build
|
||||
UNAME_S := $(shell uname -s)
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
BOARD_HARDWARE_PATH ?= $(HOME)/Documents/Arduino/hardware
|
||||
else
|
||||
BOARD_HARDWARE_PATH ?= $(HOME)/Arduino/hardware
|
||||
endif
|
||||
|
||||
include $(BOARD_HARDWARE_PATH)/$(MAKEFILE_PREFIX)/rules.mk
|
@ -0,0 +1,62 @@
|
||||
# Kaleidoscope-CycleTimeReport
|
||||
|
||||
![status][st:experimental] [![Build Status][travis:image]][travis:status]
|
||||
|
||||
[travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-CycleTimeReport.svg?branch=master
|
||||
[travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-CycleTimeReport
|
||||
|
||||
[st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52
|
||||
[st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52
|
||||
[st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52
|
||||
|
||||
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 <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-CycleTimeReport.h>
|
||||
|
||||
void setup (void) {
|
||||
Serial.begin(9600);
|
||||
Kaleidoscope.use (&CycleTimeReport);
|
||||
|
||||
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
|
@ -0,0 +1,51 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-CycleTimeReport -- Scan cycle time reporting
|
||||
* Copyright (C) 2017 Gergely Nagy
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-CycleTimeReport.h>
|
||||
|
||||
const Key keymaps[][ROWS][COLS] PROGMEM = {
|
||||
[0] = KEYMAP_STACKED
|
||||
(
|
||||
Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
|
||||
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
|
||||
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
|
||||
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
|
||||
|
||||
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
|
||||
Key_skip,
|
||||
|
||||
Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip,
|
||||
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
|
||||
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
|
||||
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
|
||||
|
||||
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
|
||||
Key_skip),
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Kaleidoscope.use(&CycleTimeReport);
|
||||
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
name=Kaleidoscope-CycleTimeReport
|
||||
version=0.0.0
|
||||
author=Gergely Nagy
|
||||
maintainer=Gergely Nagy <kaleidoscope@gergo.csillger.hu>
|
||||
sentence=Scan cycle time reporter for Kaleidoscope.
|
||||
paragraph=Scan cycle time reporter for Kaleidoscope.
|
||||
category=Communication
|
||||
url=https://github.com/keyboardio/Kaleidoscope-CycleTimeReport
|
||||
architectures=avr
|
||||
dot_a_linkage=true
|
@ -0,0 +1,21 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-CycleTimeReport -- Scan cycle time reporting
|
||||
* Copyright (C) 2017 Gergely Nagy
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <kaleidoscope/CycleTimeReport.h>
|
@ -0,0 +1,61 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-CycleTimeReport -- Scan cycle time reporting
|
||||
* Copyright (C) 2017 Gergely Nagy
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope-CycleTimeReport.h>
|
||||
|
||||
namespace kaleidoscope {
|
||||
uint32_t CycleTimeReport::next_report_time_;
|
||||
uint32_t CycleTimeReport::loop_start_time_;
|
||||
uint32_t CycleTimeReport::average_loop_time;
|
||||
|
||||
void CycleTimeReport::begin (void) {
|
||||
Kaleidoscope.useLoopHook(loopHook);
|
||||
next_report_time_ = millis() + 1000;
|
||||
}
|
||||
|
||||
void CycleTimeReport::loopHook(bool post_clear) {
|
||||
if (!post_clear)
|
||||
return;
|
||||
|
||||
if (loop_start_time_) {
|
||||
uint32_t loop_time = micros() - loop_start_time_;
|
||||
|
||||
if (average_loop_time)
|
||||
average_loop_time = (average_loop_time + loop_time) / 2;
|
||||
else
|
||||
average_loop_time = loop_time;
|
||||
|
||||
if (millis() >= next_report_time_) {
|
||||
cycleTimeReport();
|
||||
|
||||
average_loop_time = 0;
|
||||
next_report_time_ = millis() + 1000;
|
||||
}
|
||||
loop_start_time_ = 0;
|
||||
} else {
|
||||
loop_start_time_ = micros();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((weak)) void cycleTimeReport(void) {
|
||||
Serial.print(F("# average loop time: "));
|
||||
Serial.println(CycleTimeReport.average_loop_time);
|
||||
}
|
||||
|
||||
kaleidoscope::CycleTimeReport CycleTimeReport;
|
@ -0,0 +1,41 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-CycleTimeReport -- Scan cycle time reporting
|
||||
* Copyright (C) 2017 Gergely Nagy
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
|
||||
namespace kaleidoscope {
|
||||
class CycleTimeReport : public KaleidoscopePlugin {
|
||||
public:
|
||||
CycleTimeReport() {}
|
||||
|
||||
void begin(void) final;
|
||||
|
||||
static uint32_t average_loop_time;
|
||||
private:
|
||||
static uint32_t next_report_time_;
|
||||
static uint32_t loop_start_time_;
|
||||
|
||||
static void loopHook(bool post_clear);
|
||||
};
|
||||
}
|
||||
|
||||
void cycleTimeReport(void);
|
||||
|
||||
extern kaleidoscope::CycleTimeReport CycleTimeReport;
|
Loading…
Reference in new issue