You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.0 KiB
74 lines
2.0 KiB
8 years ago
|
/* -*- mode: c++ -*-
|
||
8 years ago
|
* Kaleidoscope-Heatmap -- Heatmap LED effect for Kaleidoscope.
|
||
6 years ago
|
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc.
|
||
8 years ago
|
*
|
||
6 years ago
|
* 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, version 3.
|
||
8 years ago
|
*
|
||
6 years ago
|
* 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.
|
||
8 years ago
|
*
|
||
6 years ago
|
* You should have received a copy of the GNU General Public License along with
|
||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||
8 years ago
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
5 years ago
|
#include "kaleidoscope/Runtime.h"
|
||
8 years ago
|
#include <Kaleidoscope-LEDControl.h>
|
||
8 years ago
|
|
||
8 years ago
|
namespace kaleidoscope {
|
||
6 years ago
|
namespace plugin {
|
||
6 years ago
|
class Heatmap : public Plugin,
|
||
|
public LEDModeInterface,
|
||
|
public AccessTransientLEDMode {
|
||
8 years ago
|
public:
|
||
7 years ago
|
Heatmap(void) {}
|
||
8 years ago
|
|
||
8 years ago
|
static uint16_t update_delay;
|
||
7 years ago
|
static const cRGB *heat_colors;
|
||
|
static uint8_t heat_colors_length;
|
||
7 years ago
|
void resetMap(void);
|
||
8 years ago
|
|
||
6 years ago
|
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
|
||
7 years ago
|
EventHandlerResult beforeEachCycle();
|
||
|
|
||
6 years ago
|
// This class' instance has dynamic lifetime
|
||
|
//
|
||
|
class TransientLEDMode : public LEDMode {
|
||
|
public:
|
||
7 years ago
|
|
||
6 years ago
|
// Please note that storing the parent ptr is only required
|
||
|
// for those LED modes that require access to
|
||
|
// members of their parent class. Most LED modes can do without.
|
||
|
//
|
||
4 years ago
|
explicit TransientLEDMode(const Heatmap *parent);
|
||
8 years ago
|
|
||
6 years ago
|
void resetMap();
|
||
6 years ago
|
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
|
||
6 years ago
|
EventHandlerResult beforeEachCycle();
|
||
|
|
||
|
protected:
|
||
|
|
||
4 years ago
|
void update() final;
|
||
6 years ago
|
|
||
|
private:
|
||
|
|
||
5 years ago
|
uint16_t heatmap_[Runtime.device().numKeys()];
|
||
6 years ago
|
uint16_t highest_;
|
||
6 years ago
|
uint16_t last_heatmap_comp_time_;
|
||
6 years ago
|
|
||
|
void shiftStats(void);
|
||
|
cRGB computeColor(float v);
|
||
|
|
||
|
friend class Heatmap;
|
||
|
};
|
||
8 years ago
|
};
|
||
8 years ago
|
}
|
||
6 years ago
|
}
|
||
8 years ago
|
|
||
6 years ago
|
extern kaleidoscope::plugin::Heatmap HeatmapEffect;
|