Rearrange the file layout in preparation of becoming a monorepo

Move the documentation to `doc/plugin/TypingBreaks.md`, sources under
`src/kaleidoscope/plugin/` (appropriately namespaced). This is in preparation of
merging plugins into a single monorepo.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/389/head
Gergely Nagy 6 years ago
parent 4c3c8f4036
commit a9aee8c6e5
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -5,115 +5,4 @@
[travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-TypingBreaks.svg?branch=master [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-TypingBreaks.svg?branch=master
[travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-TypingBreaks [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-TypingBreaks
Typing on the keyboard for an extended period of time may lead to injuries, See [doc/plugin/TypingBreaks.md](doc/plugin/TypingBreaks.md) for documentation.
which is why it is highly recommended to take frequent breaks from the
keyboard - and from the computer as well. But sometimes - more often than one
would wish to admit - we tend to forget about this, and plow through, at the
cost of hand's health.
No more.
With the `TypingBreaks` plugin, we can instruct the keyboard to lock itself up
after some time, or after a number of key presses. It will stay locked for a few
minutes (or whatever amount we told it to), forcing us to take a break.
## 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-EEPROM-Settings.h>
#include <Kaleidoscope-TypingBreaks.h>
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, TypingBreaks);
void setup (void) {
Kaleidoscope.setup ();
TypingBreaks.settings.idle_time_limit = 60;
}
```
## Plugin methods
The plugin provides a single object, `TypingBreaks`, with the following
properties. All times are in seconds.
### `.settings.idle_time_limit`
> The amount of time that can pass between two pressed keys, before the plugin
> considers it a new session, and starts all timers and counters over.
>
> Defaults to 300 seconds (5 minutes).
### `.settings.lock_time_out`
> The length of the session, after which the keyboard will be locked.
>
> Defaults to 2700 seconds (45 minutes).
### `.settings.lock_length`
> The length until the keyboard lock is held. Any key pressed while the lock is
> active, will be discarded.
>
> Defaults to 300 seconds (5 minutes).
### `.settings.left_hand_max_keys`
> It is possible to lock the keyboard after a number of keys pressed, too. If
> this happens sooner than the timeout, the keyboard will still be locked.
>
> This property controls how many keys can be pressed on the left side.
>
> Defaults to 0 (off).
### `.settings.right_hand_max_keys`
> It is possible to lock the keyboard after a number of keys pressed, too. If
> this happens sooner than the timeout, the keyboard will still be locked.
>
> This property controls how many keys can be pressed on the right side.
>
> Defaults to 0 (off).
## Focus commands
### `typingbreaks.idleTimeLimit [limit]`
> Get or set the `.settings.idle_time_limit` property.
### `typingbreaks.lockTimeOut [time_out]`
> Get or set the `.settings.lock_time_out` property.
### `typingbreaks.lockLength [length]`
> Get or set the `.settings.lock_length` property.
### `typingbreaks.leftMaxKeys [max]`
> Get or set the `.settings.left_hand_max_keys` property.
### `typingbreaks.rightMaxKeys [max]`
> Get or set the `.settings.right_hand_max_keys` property.
## Dependencies
* [Kaleidoscope-EEPROM-Settings](https://github.com/keyboardio/Kaleidoscope-EEPROM-Settings)
## 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-TypingBreaks/blob/master/examples/TypingBreaks/TypingBreaks.ino
## Upgrading
Storing the settable settings in EEPROM was made mandatory in recent versions of
the plugin, and as such, it now depends on `Kaleidoscope-EEPROM-Settings`, which
should be initialized before this plugin is.

@ -1,11 +0,0 @@
Important changes in TypingBreaks
=================================
Older versions of the plugin used to provide EEPROM storage for the settings
only optionally, when it was explicitly enabled via the
`TypingBreaks.enableEEPROM()` method. Similarly, the Focus hooks were optional
too.
Both of them are unconditionally enabled now, because they add so much to the
plugin. This means that any calls to `TypingBreaks.enableEEPROM()` can be safely
removed, the method is a no-op by now.

@ -0,0 +1,123 @@
# Kaleidoscope-TypingBreaks
Typing on the keyboard for an extended period of time may lead to injuries,
which is why it is highly recommended to take frequent breaks from the
keyboard - and from the computer as well. But sometimes - more often than one
would wish to admit - we tend to forget about this, and plow through, at the
cost of hand's health.
No more.
With the `TypingBreaks` plugin, we can instruct the keyboard to lock itself up
after some time, or after a number of key presses. It will stay locked for a few
minutes (or whatever amount we told it to), forcing us to take a break.
## 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-EEPROM-Settings.h>
#include <Kaleidoscope-TypingBreaks.h>
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, TypingBreaks);
void setup (void) {
Kaleidoscope.setup ();
TypingBreaks.settings.idle_time_limit = 60;
}
```
## Plugin methods
The plugin provides a single object, `TypingBreaks`, with the following
properties. All times are in seconds.
### `.settings.idle_time_limit`
> The amount of time that can pass between two pressed keys, before the plugin
> considers it a new session, and starts all timers and counters over.
>
> Defaults to 300 seconds (5 minutes).
### `.settings.lock_time_out`
> The length of the session, after which the keyboard will be locked.
>
> Defaults to 2700 seconds (45 minutes).
### `.settings.lock_length`
> The length until the keyboard lock is held. Any key pressed while the lock is
> active, will be discarded.
>
> Defaults to 300 seconds (5 minutes).
### `.settings.left_hand_max_keys`
> It is possible to lock the keyboard after a number of keys pressed, too. If
> this happens sooner than the timeout, the keyboard will still be locked.
>
> This property controls how many keys can be pressed on the left side.
>
> Defaults to 0 (off).
### `.settings.right_hand_max_keys`
> It is possible to lock the keyboard after a number of keys pressed, too. If
> this happens sooner than the timeout, the keyboard will still be locked.
>
> This property controls how many keys can be pressed on the right side.
>
> Defaults to 0 (off).
## Focus commands
### `typingbreaks.idleTimeLimit [limit]`
> Get or set the `.settings.idle_time_limit` property.
### `typingbreaks.lockTimeOut [time_out]`
> Get or set the `.settings.lock_time_out` property.
### `typingbreaks.lockLength [length]`
> Get or set the `.settings.lock_length` property.
### `typingbreaks.leftMaxKeys [max]`
> Get or set the `.settings.left_hand_max_keys` property.
### `typingbreaks.rightMaxKeys [max]`
> Get or set the `.settings.right_hand_max_keys` property.
## Dependencies
* [Kaleidoscope-EEPROM-Settings](https://github.com/keyboardio/Kaleidoscope-EEPROM-Settings)
## 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-TypingBreaks/blob/master/examples/TypingBreaks/TypingBreaks.ino
## Upgrading
Older versions of the plugin used to provide EEPROM storage for the settings
only optionally, when it was explicitly enabled via the
`TypingBreaks.enableEEPROM()` method. Similarly, the Focus hooks were optional
too.
Both of them are unconditionally enabled now, because they add so much to the
plugin. This means that any calls to `TypingBreaks.enableEEPROM()` can be safely
removed, the method is a no-op by now.
Storing the settable settings in EEPROM makes it depend on
`Kaleidoscope-EEPROM-Settings`, which should be initialized before this plugin
is.

@ -17,4 +17,4 @@
#pragma once #pragma once
#include <Kaleidoscope/TypingBreaks.h> #include <kaleidoscope/plugin/TypingBreaks.h>

@ -20,6 +20,7 @@
#include <Kaleidoscope-FocusSerial.h> #include <Kaleidoscope-FocusSerial.h>
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin {
TypingBreaks::settings_t TypingBreaks::settings = { TypingBreaks::settings_t TypingBreaks::settings = {
.idle_time_limit = 300, // 5m .idle_time_limit = 300, // 5m
@ -204,9 +205,10 @@ EventHandlerResult TypingBreaks::onFocusEvent(const char *command) {
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }
}
} }
kaleidoscope::TypingBreaks TypingBreaks; kaleidoscope::plugin::TypingBreaks TypingBreaks;
__attribute__((weak)) void TypingBreak(bool isLocked) { __attribute__((weak)) void TypingBreak(bool isLocked) {
} }

@ -24,6 +24,7 @@
"method is therefore obsolete. You can safely remove it." "method is therefore obsolete. You can safely remove it."
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin {
class TypingBreaks : public kaleidoscope::Plugin { class TypingBreaks : public kaleidoscope::Plugin {
public: public:
@ -54,9 +55,9 @@ class TypingBreaks : public kaleidoscope::Plugin {
static uint16_t settings_base_; static uint16_t settings_base_;
}; };
}
} }
extern kaleidoscope::TypingBreaks TypingBreaks; extern kaleidoscope::plugin::TypingBreaks TypingBreaks;
void TypingBreak(bool is_locked); void TypingBreak(bool is_locked);
Loading…
Cancel
Save