Rename the library to HostPowerManagement

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 7 years ago committed by Gergely Nagy
parent d602988b95
commit 810a69cf33

@ -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 <Kaleidoscope.h>
#include <Kaleidoscope-MyOldFriend.h>
#include <Kaleidoscope-HostPowerManagement.h>
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

@ -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 <Kaleidoscope.h>
#include <Kaleidoscope-MyOldFriend.h>
#include <Kaleidoscope-HostPowerManagement.h>
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() {

@ -1,10 +1,10 @@
name=Kaleidoscope-MyOldFriend
name=Kaleidoscope-HostPowerManagement
version=0.0.0
author=Gergely Nagy
maintainer=Gergely Nagy <algernon@keyboard.io>
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

@ -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 <Kaleidoscope/MyOldFriend.h>
#include <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;

@ -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 <Kaleidoscope.h>
#include <Kaleidoscope-MyOldFriend.h>
#include <Kaleidoscope-HostPowerManagement.h>
#include <Kaleidoscope-LEDControl.h>
// 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;

@ -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;

@ -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

Loading…
Cancel
Save