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] ![status][st:experimental] [![Build Status][travis:image]][travis:status]
[travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-MyOldFriend.svg?branch=master [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-HostPowerManagement.svg?branch=master
[travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-MyOldFriend [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: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: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 [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 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 sleeping. By default, the LEDs will be turned off on suspend, and the previous
LED mode restored on resume. LED mode restored on resume.
@ -23,18 +20,19 @@ configuration is necessary, unless one wants to perform custom actions.
```c++ ```c++
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
#include <Kaleidoscope-MyOldFriend.h> #include <Kaleidoscope-HostPowerManagement.h>
void setup () { void setup () {
Kaleidoscope.setup (); Kaleidoscope.setup ();
Kaleidoscope.use(&MyOldFriend); Kaleidoscope.use(&HostPowerManagement);
HostPowerManagement.enableWakeup();
} }
``` ```
## Plugin methods ## 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()` ### `.enableWakeup()`
@ -46,21 +44,21 @@ The plugin provides the `MyOldFriend` object, which has the following methods:
### `.toggleLEDs(event)` ### `.toggleLEDs(event)`
> Turns LEDs off on suspend, restores the previous LED mode on resume. This is > 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 ## 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. > tells it what action to perform in response to the various events.
> >
> Currently supported events are: `kaleidoscope::MyOldFriend::Suspend` is fired > Currently supported events are: `kaleidoscope::HostPowerManagement::Suspend` is fired
> once when the host suspends; `kaleidoscope::MyOldFriend::Sleep` is fired every > once when the host suspends; `kaleidoscope::HostPowerManagement::Sleep` is fired every
> cycle while the host is suspended; `kaleidoscope::MyOldFriend::Resume` is > cycle while the host is suspended; `kaleidoscope::HostPowerManagement::Resume` is
> fired once when the host wakes up. > 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. > function, the default is lost.
## Dependencies ## 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 Starting from the [example][plugin:example] is the recommended way of getting
started with the plugin. 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++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host sleep support plugin. * Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy * Copyright (C) 2017 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -17,7 +17,7 @@
*/ */
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
#include <Kaleidoscope-MyOldFriend.h> #include <Kaleidoscope-HostPowerManagement.h>
const Key keymaps[][ROWS][COLS] PROGMEM = { const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED [0] = KEYMAP_STACKED
@ -44,9 +44,9 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
void setup() { void setup() {
Kaleidoscope.setup(); Kaleidoscope.setup();
Kaleidoscope.use(&MyOldFriend); Kaleidoscope.use(&HostPowerManagement);
MyOldFriend.enableWakeup(); HostPowerManagement.enableWakeup();
} }
void loop() { void loop() {

@ -1,10 +1,10 @@
name=Kaleidoscope-MyOldFriend name=Kaleidoscope-HostPowerManagement
version=0.0.0 version=0.0.0
author=Gergely Nagy author=Gergely Nagy
maintainer=Gergely Nagy <algernon@keyboard.io> maintainer=Gergely Nagy <algernon@keyboard.io>
sentence=Host sleep support library for Kaleidoscope. sentence=Host power management support library for Kaleidoscope.
paragraph=Turn LEDs off during host sleep, or do any other custom action. paragraph=Hooks to support host suspend & resume, and the ability to wake the host from the keyboard.
category=Communication category=Communication
url=https://github.com/keyboardio/Kaleidoscope-MyOldFriend url=https://github.com/keyboardio/Kaleidoscope-HostPowerManagement
architectures=avr architectures=avr
dot_a_linkage=true dot_a_linkage=true

@ -1,5 +1,5 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host sleep support plugin. * Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy * Copyright (C) 2017 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -18,4 +18,4 @@
#pragma once #pragma once
#include <Kaleidoscope/MyOldFriend.h> #include <Kaleidoscope/HostPowerManagement.h>

@ -1,5 +1,5 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host sleep support plugin. * Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy * Copyright (C) 2017 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -22,7 +22,7 @@
#include "WakeupKeyboard.h" #include "WakeupKeyboard.h"
namespace kaleidoscope { namespace kaleidoscope {
class MyOldFriend : public KaleidoscopePlugin { class HostPowerManagement : public KaleidoscopePlugin {
public: public:
typedef enum { typedef enum {
Suspend, Suspend,
@ -30,7 +30,7 @@ class MyOldFriend : public KaleidoscopePlugin {
Resume, Resume,
} Event; } Event;
MyOldFriend(void) {}; HostPowerManagement(void) {};
void begin(void) final; void begin(void) final;
void enableWakeup(void) { 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++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host sleep support plugin. * Kaleidoscope-HostPowerManagement -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy * Copyright (C) 2017 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -17,7 +17,7 @@
*/ */
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
#include <Kaleidoscope-MyOldFriend.h> #include <Kaleidoscope-HostPowerManagement.h>
#include <Kaleidoscope-LEDControl.h> #include <Kaleidoscope-LEDControl.h>
// This is a terrible hack until Arduino#6964 gets implemented. // This is a terrible hack until Arduino#6964 gets implemented.
@ -26,14 +26,14 @@ extern u8 _usbSuspendState;
namespace kaleidoscope { namespace kaleidoscope {
bool MyOldFriend::was_suspended_ = false; bool HostPowerManagement::was_suspended_ = false;
bool MyOldFriend::initial_suspend_ = true; bool HostPowerManagement::initial_suspend_ = true;
void MyOldFriend::begin(void) { void HostPowerManagement::begin(void) {
Kaleidoscope.useLoopHook(loopHook); Kaleidoscope.useLoopHook(loopHook);
} }
void MyOldFriend::toggleLEDs(MyOldFriend::Event event) { void HostPowerManagement::toggleLEDs(HostPowerManagement::Event event) {
switch (event) { switch (event) {
case Suspend: case Suspend:
::LEDControl.paused = true; ::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) if (post_clear)
return; return;
@ -57,9 +57,9 @@ void MyOldFriend::loopHook(bool post_clear) {
if (!initial_suspend_) { if (!initial_suspend_) {
if (!was_suspended_) { if (!was_suspended_) {
was_suspended_ = true; was_suspended_ = true;
myOldFriendEventHandler(Suspend); hostPowerManagementEventHandler(Suspend);
} else { } else {
myOldFriendEventHandler(Sleep); hostPowerManagementEventHandler(Sleep);
} }
} }
} else { } else {
@ -67,15 +67,15 @@ void MyOldFriend::loopHook(bool post_clear) {
initial_suspend_ = false; initial_suspend_ = false;
if (was_suspended_) { if (was_suspended_) {
was_suspended_ = false; was_suspended_ = false;
myOldFriendEventHandler(Resume); hostPowerManagementEventHandler(Resume);
} }
} }
} }
} }
__attribute__((weak)) void myOldFriendEventHandler(kaleidoscope::MyOldFriend::Event event) { __attribute__((weak)) void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event event) {
MyOldFriend.toggleLEDs(event); HostPowerManagement.toggleLEDs(event);
} }
kaleidoscope::MyOldFriend MyOldFriend; kaleidoscope::HostPowerManagement HostPowerManagement;

@ -1,5 +1,5 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host sleep support plugin. * Kaleidoscope-MyOldFriend -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy * Copyright (C) 2017 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -85,7 +85,7 @@ bool WakeupKeyboard_::setup(USBSetup& setup) {
return false; return false;
} }
void WakeupKeyboard_::begin() { void WakeupKeyboard_::begin () {
} }
WakeupKeyboard_ WakeupKeyboard; WakeupKeyboard_ WakeupKeyboard;

@ -1,5 +1,5 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MyOldFriend -- Host sleep support plugin. * Kaleidoscope-MyOldFriend -- Host power management support plugin.
* Copyright (C) 2017 Gergely Nagy * Copyright (C) 2017 Gergely Nagy
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

Loading…
Cancel
Save