From 810a69cf3311f0801c031c2bb3d8e0e5f4d16487 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 16 Dec 2017 08:13:06 +0100 Subject: [PATCH] Rename the library to HostPowerManagement Signed-off-by: Gergely Nagy --- README.md | 32 +++++++++---------- .../HostPowerManagement.ino} | 8 ++--- library.properties | 8 ++--- ...d.h => Kaleidoscope-HostPowerManagement.h} | 4 +-- .../{MyOldFriend.h => HostPowerManagement.h} | 10 +++--- src/Kaleidoscope/MyOldFriend.cpp | 26 +++++++-------- src/Kaleidoscope/WakeupKeyboard.cpp | 4 +-- src/Kaleidoscope/WakeupKeyboard.h | 2 +- 8 files changed, 46 insertions(+), 48 deletions(-) rename examples/{MyOldFriend/MyOldFriend.ino => HostPowerManagement/HostPowerManagement.ino} (88%) rename src/{Kaleidoscope-MyOldFriend.h => Kaleidoscope-HostPowerManagement.h} (85%) rename src/Kaleidoscope/{MyOldFriend.h => HostPowerManagement.h} (78%) diff --git a/README.md b/README.md index 21bebdf6..17b1610e 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,14 @@ -# Kaleidoscope-MyOldFriend +# Kaleidoscope-HostPowerManagement ![status][st:experimental] [![Build Status][travis:image]][travis:status] - [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-MyOldFriend.svg?branch=master - [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-MyOldFriend + [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-HostPowerManagement.svg?branch=master + [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-HostPowerManagement [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 -> Hello darkness, my old friend -> I've come to talk with you again - Support performing custom actions whenever the host suspends, resumes, or is sleeping. By default, the LEDs will be turned off on suspend, and the previous LED mode restored on resume. @@ -23,18 +20,19 @@ configuration is necessary, unless one wants to perform custom actions. ```c++ #include -#include +#include void setup () { Kaleidoscope.setup (); - Kaleidoscope.use(&MyOldFriend); + Kaleidoscope.use(&HostPowerManagement); + HostPowerManagement.enableWakeup(); } ``` ## Plugin methods -The plugin provides the `MyOldFriend` object, which has the following methods: +The plugin provides the `HostPowerManagement` object, which has the following methods: ### `.enableWakeup()` @@ -46,21 +44,21 @@ The plugin provides the `MyOldFriend` object, which has the following methods: ### `.toggleLEDs(event)` > Turns LEDs off on suspend, restores the previous LED mode on resume. This is -> called by `myOldFriendEventHandler()` by default. +> called by `hostPowerManagementEventHandler()` by default. ## Overrideable methods -### `myOldFriendEventHandler(event)` +### `hostPowerManagementEventHandler(event)` -> The `myOldFriendEventHandler` method is the brain of the plugin: this function +> The `hostPowerManagementEventHandler` method is the brain of the plugin: this function > tells it what action to perform in response to the various events. > -> Currently supported events are: `kaleidoscope::MyOldFriend::Suspend` is fired -> once when the host suspends; `kaleidoscope::MyOldFriend::Sleep` is fired every -> cycle while the host is suspended; `kaleidoscope::MyOldFriend::Resume` is +> Currently supported events are: `kaleidoscope::HostPowerManagement::Suspend` is fired +> once when the host suspends; `kaleidoscope::HostPowerManagement::Sleep` is fired every +> cycle while the host is suspended; `kaleidoscope::HostPowerManagement::Resume` is > fired once when the host wakes up. > -> The default implementation calls `MyOldFriend.toggleLEDs`. When overriding the +> The default implementation calls `HostPowerManagement.toggleLEDs`. When overriding the > function, the default is lost. ## Dependencies @@ -72,4 +70,4 @@ The plugin provides the `MyOldFriend` object, which has the following methods: Starting from the [example][plugin:example] is the recommended way of getting started with the plugin. - [plugin:example]: https://github.com/keyboardio/Kaleidoscope-MyOldFriend/blob/master/examples/MyOldFriend/MyOldFriend.ino + [plugin:example]: https://github.com/keyboardio/Kaleidoscope-HostPowerManagement/blob/master/examples/HostPowerManagement/HostPowerManagement.ino diff --git a/examples/MyOldFriend/MyOldFriend.ino b/examples/HostPowerManagement/HostPowerManagement.ino similarity index 88% rename from examples/MyOldFriend/MyOldFriend.ino rename to examples/HostPowerManagement/HostPowerManagement.ino index 93c0ebc4..be96b3ce 100644 --- a/examples/MyOldFriend/MyOldFriend.ino +++ b/examples/HostPowerManagement/HostPowerManagement.ino @@ -1,5 +1,5 @@ /* -*- mode: c++ -*- - * Kaleidoscope-MyOldFriend -- Host sleep support plugin. + * Kaleidoscope-HostPowerManagement -- Host power management support plugin. * Copyright (C) 2017 Gergely Nagy * * This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ */ #include -#include +#include const Key keymaps[][ROWS][COLS] PROGMEM = { [0] = KEYMAP_STACKED @@ -44,9 +44,9 @@ const Key keymaps[][ROWS][COLS] PROGMEM = { void setup() { Kaleidoscope.setup(); - Kaleidoscope.use(&MyOldFriend); + Kaleidoscope.use(&HostPowerManagement); - MyOldFriend.enableWakeup(); + HostPowerManagement.enableWakeup(); } void loop() { diff --git a/library.properties b/library.properties index 41953ba1..db622f9d 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ -name=Kaleidoscope-MyOldFriend +name=Kaleidoscope-HostPowerManagement version=0.0.0 author=Gergely Nagy maintainer=Gergely Nagy -sentence=Host sleep support library for Kaleidoscope. -paragraph=Turn LEDs off during host sleep, or do any other custom action. +sentence=Host power management support library for Kaleidoscope. +paragraph=Hooks to support host suspend & resume, and the ability to wake the host from the keyboard. category=Communication -url=https://github.com/keyboardio/Kaleidoscope-MyOldFriend +url=https://github.com/keyboardio/Kaleidoscope-HostPowerManagement architectures=avr dot_a_linkage=true diff --git a/src/Kaleidoscope-MyOldFriend.h b/src/Kaleidoscope-HostPowerManagement.h similarity index 85% rename from src/Kaleidoscope-MyOldFriend.h rename to src/Kaleidoscope-HostPowerManagement.h index e179d1d4..6b9a0251 100644 --- a/src/Kaleidoscope-MyOldFriend.h +++ b/src/Kaleidoscope-HostPowerManagement.h @@ -1,5 +1,5 @@ /* -*- mode: c++ -*- - * Kaleidoscope-MyOldFriend -- Host sleep support plugin. + * Kaleidoscope-HostPowerManagement -- Host power management support plugin. * Copyright (C) 2017 Gergely Nagy * * This program is free software: you can redistribute it and/or modify @@ -18,4 +18,4 @@ #pragma once -#include +#include diff --git a/src/Kaleidoscope/MyOldFriend.h b/src/Kaleidoscope/HostPowerManagement.h similarity index 78% rename from src/Kaleidoscope/MyOldFriend.h rename to src/Kaleidoscope/HostPowerManagement.h index 8d619e21..de3c827b 100644 --- a/src/Kaleidoscope/MyOldFriend.h +++ b/src/Kaleidoscope/HostPowerManagement.h @@ -1,5 +1,5 @@ /* -*- mode: c++ -*- - * Kaleidoscope-MyOldFriend -- Host sleep support plugin. + * Kaleidoscope-HostPowerManagement -- Host power management support plugin. * Copyright (C) 2017 Gergely Nagy * * This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ #include "WakeupKeyboard.h" namespace kaleidoscope { -class MyOldFriend : public KaleidoscopePlugin { +class HostPowerManagement : public KaleidoscopePlugin { public: typedef enum { Suspend, @@ -30,7 +30,7 @@ class MyOldFriend : public KaleidoscopePlugin { Resume, } Event; - MyOldFriend(void) {}; + HostPowerManagement(void) {}; void begin(void) final; void enableWakeup(void) { @@ -47,6 +47,6 @@ class MyOldFriend : public KaleidoscopePlugin { }; } -void myOldFriendEventHandler(kaleidoscope::MyOldFriend::Event event); +void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event event); -extern kaleidoscope::MyOldFriend MyOldFriend; +extern kaleidoscope::HostPowerManagement HostPowerManagement; diff --git a/src/Kaleidoscope/MyOldFriend.cpp b/src/Kaleidoscope/MyOldFriend.cpp index ab0ad397..2b4ee255 100644 --- a/src/Kaleidoscope/MyOldFriend.cpp +++ b/src/Kaleidoscope/MyOldFriend.cpp @@ -1,5 +1,5 @@ /* -*- mode: c++ -*- - * Kaleidoscope-MyOldFriend -- Host sleep support plugin. + * Kaleidoscope-HostPowerManagement -- Host power management support plugin. * Copyright (C) 2017 Gergely Nagy * * This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ */ #include -#include +#include #include // This is a terrible hack until Arduino#6964 gets implemented. @@ -26,14 +26,14 @@ extern u8 _usbSuspendState; namespace kaleidoscope { -bool MyOldFriend::was_suspended_ = false; -bool MyOldFriend::initial_suspend_ = true; +bool HostPowerManagement::was_suspended_ = false; +bool HostPowerManagement::initial_suspend_ = true; -void MyOldFriend::begin(void) { +void HostPowerManagement::begin(void) { Kaleidoscope.useLoopHook(loopHook); } -void MyOldFriend::toggleLEDs(MyOldFriend::Event event) { +void HostPowerManagement::toggleLEDs(HostPowerManagement::Event event) { switch (event) { case Suspend: ::LEDControl.paused = true; @@ -49,7 +49,7 @@ void MyOldFriend::toggleLEDs(MyOldFriend::Event event) { } } -void MyOldFriend::loopHook(bool post_clear) { +void HostPowerManagement::loopHook(bool post_clear) { if (post_clear) return; @@ -57,9 +57,9 @@ void MyOldFriend::loopHook(bool post_clear) { if (!initial_suspend_) { if (!was_suspended_) { was_suspended_ = true; - myOldFriendEventHandler(Suspend); + hostPowerManagementEventHandler(Suspend); } else { - myOldFriendEventHandler(Sleep); + hostPowerManagementEventHandler(Sleep); } } } else { @@ -67,15 +67,15 @@ void MyOldFriend::loopHook(bool post_clear) { initial_suspend_ = false; if (was_suspended_) { was_suspended_ = false; - myOldFriendEventHandler(Resume); + hostPowerManagementEventHandler(Resume); } } } } -__attribute__((weak)) void myOldFriendEventHandler(kaleidoscope::MyOldFriend::Event event) { - MyOldFriend.toggleLEDs(event); +__attribute__((weak)) void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event event) { + HostPowerManagement.toggleLEDs(event); } -kaleidoscope::MyOldFriend MyOldFriend; +kaleidoscope::HostPowerManagement HostPowerManagement; diff --git a/src/Kaleidoscope/WakeupKeyboard.cpp b/src/Kaleidoscope/WakeupKeyboard.cpp index f9beafde..f75ecd63 100644 --- a/src/Kaleidoscope/WakeupKeyboard.cpp +++ b/src/Kaleidoscope/WakeupKeyboard.cpp @@ -1,5 +1,5 @@ /* -*- mode: c++ -*- - * Kaleidoscope-MyOldFriend -- Host sleep support plugin. + * Kaleidoscope-MyOldFriend -- Host power management support plugin. * Copyright (C) 2017 Gergely Nagy * * This program is free software: you can redistribute it and/or modify @@ -85,7 +85,7 @@ bool WakeupKeyboard_::setup(USBSetup& setup) { return false; } -void WakeupKeyboard_::begin() { +void WakeupKeyboard_::begin () { } WakeupKeyboard_ WakeupKeyboard; diff --git a/src/Kaleidoscope/WakeupKeyboard.h b/src/Kaleidoscope/WakeupKeyboard.h index 6b127f9b..d1199ffa 100644 --- a/src/Kaleidoscope/WakeupKeyboard.h +++ b/src/Kaleidoscope/WakeupKeyboard.h @@ -1,5 +1,5 @@ /* -*- mode: c++ -*- - * Kaleidoscope-MyOldFriend -- Host sleep support plugin. + * Kaleidoscope-MyOldFriend -- Host power management support plugin. * Copyright (C) 2017 Gergely Nagy * * This program is free software: you can redistribute it and/or modify