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.
82 lines
2.2 KiB
82 lines
2.2 KiB
8 years ago
|
/* -*- mode: c++ -*-
|
||
8 years ago
|
* Kaleidoscope-LED-Wavepool
|
||
|
* Copyright (C) 2017 Selene Scriven
|
||
8 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, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* 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.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
6 years ago
|
#ifdef ARDUINO_AVR_MODEL01
|
||
|
|
||
5 years ago
|
#include "kaleidoscope/Runtime.h"
|
||
8 years ago
|
#include <Kaleidoscope-LEDControl.h>
|
||
|
|
||
8 years ago
|
#define WP_WID 14
|
||
|
#define WP_HGT 5
|
||
8 years ago
|
|
||
|
namespace kaleidoscope {
|
||
6 years ago
|
namespace plugin {
|
||
6 years ago
|
class WavepoolEffect : public Plugin,
|
||
|
public LEDModeInterface,
|
||
|
public AccessTransientLEDMode {
|
||
8 years ago
|
public:
|
||
6 years ago
|
WavepoolEffect(void) {}
|
||
6 years ago
|
|
||
6 years ago
|
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
|
||
8 years ago
|
|
||
7 years ago
|
// ms before idle animation starts after last keypress
|
||
|
static uint16_t idle_timeout;
|
||
6 years ago
|
static int16_t ripple_hue;
|
||
7 years ago
|
|
||
6 years ago
|
static constexpr int16_t rainbow_hue = INT16_MAX;
|
||
7 years ago
|
|
||
6 years ago
|
// This class' instance has dynamic lifetime
|
||
|
//
|
||
|
class TransientLEDMode : public LEDMode {
|
||
|
public:
|
||
8 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 WavepoolEffect *parent);
|
||
6 years ago
|
|
||
6 years ago
|
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
|
||
6 years ago
|
|
||
|
protected:
|
||
|
|
||
4 years ago
|
void update() final;
|
||
6 years ago
|
|
||
|
private:
|
||
|
|
||
|
uint8_t frames_since_event_;
|
||
|
int8_t surface_[2][WP_WID * WP_HGT];
|
||
|
uint8_t page_;
|
||
5 years ago
|
static PROGMEM const uint8_t rc2pos[Runtime.device().numKeys()];
|
||
6 years ago
|
|
||
|
void raindrop(uint8_t x, uint8_t y, int8_t *page);
|
||
|
uint8_t wp_rand();
|
||
|
|
||
|
friend class WavepoolEffect;
|
||
|
};
|
||
8 years ago
|
};
|
||
|
|
||
6 years ago
|
}
|
||
8 years ago
|
}
|
||
|
|
||
6 years ago
|
extern kaleidoscope::plugin::WavepoolEffect WavepoolEffect;
|
||
6 years ago
|
|
||
|
#endif
|