-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColormap-Defy.h
95 lines (81 loc) · 3.24 KB
/
Colormap-Defy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* -*- mode: c++ -*-
* Kaleidoscope-Colormap -- Per-layer colormap effect
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc
* Copyright (C) 2023, 2024 DygmaLabs, S. L.
*
* This program is free software: you can redistribute it and/or modify it under it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT 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 along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LED-Palette-Theme.h>
#include "LedModeSerializable-Layer.h"
#include "LedModeCommunication.h"
//#include "SPISlave.h"
using namespace Communications_protocol;
namespace kaleidoscope {
namespace plugin {
class ColormapEffectDefy : public Plugin,
public LEDModeInterface,
public LedModeCommunication,
public AccessTransientLEDMode {
public:
ColormapEffectDefy(void) = default;
EventHandlerResult onSetup();
void max_layers(uint8_t max_);
enum class LedBrightnessControlEffect {
NONE,
BATTERY_MANAGMENT,
FADE_EFFECT,
BATTERY_STATUS,
BT_LED_EFFECT,
};
LedBrightnessControlEffect no_led_effect = LedBrightnessControlEffect::NONE;
EventHandlerResult onLayerChange();
EventHandlerResult onFocusEvent(const char *command);
void updateColorIndexAtPosition(uint8_t layer, uint16_t position, uint8_t palette_index);
uint8_t getColorIndexAtPosition(uint8_t layer, uint16_t position);
LedModeSerializable_Layer &led_mode = ledModeSerializableLayer;
void getLayer(uint8_t layer, uint8_t output_buf[Runtime.device().led_count]);
void setFadein(bool fade_status);
static void updateBrigthness(LedBrightnessControlEffect led_effect_id = LedBrightnessControlEffect::NONE, bool take_brightness_handler = true, bool updateWiredBrightness = true);
// This class' instance has dynamic lifetime
//
class TransientLEDMode : public LEDMode {
public:
// 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.
//
explicit TransientLEDMode(ColormapEffectDefy *parent)
: parent_(parent) {}
protected:
friend class ColormapEffectDefy;
void onActivate(void) final;
void refreshAt(KeyAddr key_addr) final;
private:
ColormapEffectDefy *parent_;
};
private:
static uint8_t top_layer_;
public:
static uint8_t getMaxLayers();
static void setSideStatus(Communications_protocol::Devices side);
private:
static uint8_t max_layers_;
static uint16_t map_base_;
void updateKeyMapCommunications(Packet &packet);
void updateUnderGlowCommunications(Packet &packet);
};
} // namespace plugin
} // namespace kaleidoscope
extern kaleidoscope::plugin::ColormapEffectDefy ColormapEffectDefy;