Compare commits
116 Commits
f/driver/k
...
main
Author | SHA1 | Date |
---|---|---|
Alpha Chen | 0bb3928aea | 2 years ago |
Alpha Chen | 7954cc8f25 | 2 years ago |
Alpha Chen | 9fb691f44a | 2 years ago |
Gergely Nagy | ff19f144f8 | 2 years ago |
Michael Richters | a0045f4d9e | 2 years ago |
Michael Richters | 51125f215b | 2 years ago |
Michael Richters | c84aa58470 | 2 years ago |
Michael Richters | 789cc218c6 | 2 years ago |
Michael Richters | adaa3b7a01 | 2 years ago |
Alpha Chen | a43b89ce51 | 2 years ago |
Alpha Chen | 02157d30c7 | 2 years ago |
Gergely Nagy | 2f1c96ab4e | 2 years ago |
Gergely Nagy | 49a691e0f9 | 2 years ago |
Norwin | 3655f9a517 | 2 years ago |
Norwin | e22773ab5b | 2 years ago |
Jesse Vincent | fefc6699ba | 2 years ago |
Taylor Yu | e233e96be7 | 2 years ago |
Jesse Vincent | 18d0292d64 | 2 years ago |
Taylor Yu | af69f6a72b | 2 years ago |
Taylor Yu | 0ac320baeb | 2 years ago |
Jesse Vincent | 95ea4e3175 | 2 years ago |
Gergely Nagy | d0f1a812b0 | 2 years ago |
Gergely Nagy | 6a12467b84 | 2 years ago |
Jesse Vincent | b949ca89b1 | 2 years ago |
Jesse Vincent | cf798497e2 | 2 years ago |
Gergely Nagy | ca9b4cb50c | 2 years ago |
Taylor Yu | 04d608c9f6 | 2 years ago |
Jesse Vincent | 9bf6eba010 | 2 years ago |
Gergely Nagy | f21dda9a51 | 2 years ago |
Gergely Nagy | 28d6d66e98 | 2 years ago |
Jesse Vincent | ae9e561028 | 2 years ago |
Jesse Vincent | f181d55124 | 2 years ago |
Jesse Vincent | be28b367ce | 2 years ago |
Taylor Yu | 45bd9d1a3d | 2 years ago |
Gergely Nagy | 75b911b27d | 2 years ago |
Gergely Nagy | a5afaf1eb4 | 2 years ago |
Gergely Nagy | 26340b7edb | 2 years ago |
Gergely Nagy | 8ac4d9f5c1 | 2 years ago |
Gergely Nagy | a9f4f16e31 | 2 years ago |
Jesse Vincent | 7b66d8dfb5 | 2 years ago |
Jesse Vincent | 8196adab6c | 2 years ago |
Gergely Nagy | 96fbfb0628 | 2 years ago |
Gergely Nagy | a4b84057b0 | 2 years ago |
Jesse Vincent | 62a0fae04d | 2 years ago |
Gergely Nagy | cd82afd50a | 2 years ago |
Gergely Nagy | 7f4090f126 | 2 years ago |
Jesse Vincent | 63bcf212f3 | 2 years ago |
Gergely Nagy | db7b0af730 | 2 years ago |
Jesse Vincent | f3fe7c9023 | 2 years ago |
Taylor Yu | 1301bebc09 | 2 years ago |
Taylor Yu | d16f2c93b8 | 2 years ago |
Jesse Vincent | becf816dbe | 2 years ago |
Taylor Yu | af3dc61710 | 2 years ago |
Jesse Vincent | 35aa03b63d | 2 years ago |
Taylor Yu | 4a030ae7e8 | 2 years ago |
Taylor Yu | cf66803288 | 2 years ago |
Jesse Vincent | 8f3fab579b | 2 years ago |
Gergely Nagy | b114110645 | 2 years ago |
Gergely Nagy | e52cf5c821 | 2 years ago |
Jesse Vincent | f5639dd5ba | 2 years ago |
Gergely Nagy | 9d0dddb79a | 2 years ago |
Jesse Vincent | 51b272e598 | 2 years ago |
Tatsuhiko Miyagawa | 1e36ab17a6 | 2 years ago |
Jesse Vincent | 9d374292ba | 2 years ago |
Gergely Nagy | 9b9911bdb5 | 2 years ago |
Gergely Nagy | dde7caeee9 | 2 years ago |
Gergely Polonkai | d794035f6c | 2 years ago |
Jesse Vincent | 4087f43534 | 2 years ago |
Gergely Nagy | 6fd2fa153b | 2 years ago |
Jesse Vincent | bc0466aa22 | 2 years ago |
Gergely Nagy | 2a902e9b74 | 2 years ago |
Jesse Vincent | d12515105f | 3 years ago |
Gergely Nagy | b243b0c1c5 | 3 years ago |
Gergely Nagy | da024d6bf9 | 3 years ago |
Gergely Nagy | b5f0fc5ec9 | 3 years ago |
Jesse Vincent | 65621738d2 | 3 years ago |
Gergely Nagy | 0e07331cbc | 3 years ago |
Gergely Nagy | e59a09e19e | 3 years ago |
Gergely Nagy | 0c6f608704 | 3 years ago |
Jesse Vincent | a61c211dee | 3 years ago |
Jesse Vincent | feca06d0c0 | 3 years ago |
Jesse Vincent | 633da94896 | 3 years ago |
Jesse Vincent | 727fd47b1f | 3 years ago |
Gergely Nagy | fc2670b99d | 3 years ago |
Michael Richters | b60ef9f0ab | 3 years ago |
Gergely Nagy | e02d446803 | 3 years ago |
Jesse Vincent | f10d5833f3 | 3 years ago |
Gergely Nagy | 5666e55d0a | 3 years ago |
Gergely Nagy | 657d33450c | 3 years ago |
Michael Richters | 0f27253f90 | 3 years ago |
Michael Richters | 7373882c88 | 3 years ago |
Michael Richters | 054dc9beb3 | 3 years ago |
Michael Richters | 3976e3dd5b | 3 years ago |
Jesse Vincent | cb9ad9f753 | 3 years ago |
Michael Richters | 274ff5eb76 | 3 years ago |
Michael Richters | 396b4220f2 | 3 years ago |
Michael Richters | d34f63e4eb | 3 years ago |
Michael Richters | 1f965da243 | 3 years ago |
Michael Richters | 2df20b1a5a | 3 years ago |
Michael Richters | 920be03cad | 3 years ago |
Michael Richters | bce72c4ddc | 3 years ago |
Michael Richters | 403ea4a8ec | 3 years ago |
Jesse Vincent | 4bcf4b85d6 | 3 years ago |
Michael Richters | 9c5df517ae | 3 years ago |
Michael Richters | f28a847329 | 3 years ago |
Michael Richters | 45c33c04f0 | 3 years ago |
Michael Richters | 041543a0b3 | 3 years ago |
Gergely Nagy | d476508e26 | 3 years ago |
Gergely Polonkai | 2923996650 | 3 years ago |
iliana etaoin | 3da0ad457a | 3 years ago |
iliana etaoin | 06aebb42b9 | 3 years ago |
iliana etaoin | a960f5a0cb | 3 years ago |
Jesse Vincent | 854f621703 | 3 years ago |
Gergely Nagy | 07dcf1dc9b | 3 years ago |
iliana etaoin | 0810321272 | 3 years ago |
iliana etaoin | 95b7a7b684 | 3 years ago |
@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# focus-send - Trivial Focus testing tool
|
||||||
|
# Copyright (C) 2018-2022 Keyboard.io, Inc.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
OS=$(uname -s)
|
||||||
|
|
||||||
|
# igncr absorbs CR from Focus CRLF line endings
|
||||||
|
# -echo is needed because raw doesn't turn it off on Linux
|
||||||
|
STTY_ARGS="9600 raw igncr -echo"
|
||||||
|
|
||||||
|
case ${OS} in
|
||||||
|
Linux)
|
||||||
|
DEVICE="${DEVICE:-/dev/ttyACM0}"
|
||||||
|
;;
|
||||||
|
Darwin)
|
||||||
|
# bash on macOS has a bug that randomly drops serial input
|
||||||
|
if [ -n "$BASH_VERSION" ] && [ -x /bin/dash ]; then
|
||||||
|
# Prevent loop in case someone exported it
|
||||||
|
export -n BASH_VERSION
|
||||||
|
exec /bin/dash "$0" "$@"
|
||||||
|
fi
|
||||||
|
DEVICE="${DEVICE:-/dev/cu.usbmodemCkbio01E}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error Unknown OS : ${OS}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Redirect prior to running stty, because macOS sometimes resets termios
|
||||||
|
# state upon last close of a terminal device.
|
||||||
|
exec < "${DEVICE}"
|
||||||
|
# shellcheck disable=SC2086 # intentional word splitting
|
||||||
|
stty $STTY_ARGS
|
||||||
|
|
||||||
|
read_reply () {
|
||||||
|
while read -r line; do
|
||||||
|
if [ "${line}" = "." ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "${line}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Flush any invalid commands out of input buffer.
|
||||||
|
# This could happen after a failed upload.
|
||||||
|
echo ' ' > "${DEVICE}"
|
||||||
|
read_reply > /dev/null
|
||||||
|
echo "$@" >"${DEVICE}"
|
||||||
|
read_reply
|
@ -1,45 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# focus-test - Trivial Focus testing tool
|
|
||||||
# Copyright (C) 2018 Keyboard.io, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
OS=$(uname -s)
|
|
||||||
|
|
||||||
case ${OS} in
|
|
||||||
Linux)
|
|
||||||
DEVICE="${DEVICE:-/dev/ttyACM0}"
|
|
||||||
stty -F "${DEVICE}" 9600 raw -echo
|
|
||||||
;;
|
|
||||||
Darwin)
|
|
||||||
DEVICE="${DEVICE:-/dev/cu.usbmodemCkbio01E}"
|
|
||||||
stty -f "${DEVICE}" 9600 raw -echo
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error Unknown OS : ${OS}" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
exec 3<"${DEVICE}"
|
|
||||||
echo "$@" >"${DEVICE}"
|
|
||||||
|
|
||||||
while read -r line <&3; do
|
|
||||||
line="$(echo -n "${line}" | tr -d '\r')"
|
|
||||||
if [ "${line}" == "." ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo "${line}"
|
|
||||||
done
|
|
@ -0,0 +1,69 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
|
||||||
|
/* This example demonstrates the Model 01 / Model 100 butterfly logo key as a
|
||||||
|
* tmux prefix key. When the key is held, Ctrl-B is pressed prior to the key
|
||||||
|
* you pressed.
|
||||||
|
*
|
||||||
|
* This example also demonstrates the purpose of using an entire layer for this
|
||||||
|
* plugin: the h/j/k/l keys in the TMUX layer are swapped for arrow keys to
|
||||||
|
* make switching between panes easier.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Kaleidoscope.h>
|
||||||
|
#include <Kaleidoscope-PrefixLayer.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PRIMARY,
|
||||||
|
TMUX,
|
||||||
|
}; // layers
|
||||||
|
|
||||||
|
/* Used in setup() below. */
|
||||||
|
static const kaleidoscope::plugin::PrefixLayer::Entry prefix_layers[] PROGMEM = {
|
||||||
|
kaleidoscope::plugin::PrefixLayer::Entry(TMUX, LCTRL(Key_B)),
|
||||||
|
};
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
KEYMAPS(
|
||||||
|
[PRIMARY] = KEYMAP_STACKED
|
||||||
|
(XXX, Key_1, Key_2, Key_3, Key_4, Key_5, XXX,
|
||||||
|
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
|
||||||
|
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
|
||||||
|
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
|
||||||
|
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
|
||||||
|
XXX,
|
||||||
|
|
||||||
|
XXX, Key_6, Key_7, Key_8, Key_9, Key_0, XXX,
|
||||||
|
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
|
||||||
|
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
|
||||||
|
ShiftToLayer(TMUX), Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
|
||||||
|
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
|
||||||
|
XXX),
|
||||||
|
|
||||||
|
[TMUX] = KEYMAP_STACKED
|
||||||
|
(___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___,
|
||||||
|
___,
|
||||||
|
|
||||||
|
___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___, ___,
|
||||||
|
Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___,
|
||||||
|
___),
|
||||||
|
)
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
KALEIDOSCOPE_INIT_PLUGINS(PrefixLayer);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Kaleidoscope.setup();
|
||||||
|
/* Configure the previously-defined prefix layers. */
|
||||||
|
PrefixLayer.setPrefixLayers(prefix_layers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Kaleidoscope.loop();
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cpu": {
|
||||||
|
"fqbn": "keyboardio:avr:model01",
|
||||||
|
"port": ""
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope-Colormap -- Per-layer colormap effect
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kaleidoscope/plugin/Colormap.h" // for Colormap
|
||||||
|
#include "kaleidoscope/plugin/DefaultColormap.h"
|
||||||
|
|
||||||
|
#include <Arduino.h> // for F, PSTR, __FlashStringHelper
|
||||||
|
#include <Kaleidoscope-FocusSerial.h> // for Focus, FocusSerial
|
||||||
|
#include <Kaleidoscope-LEDControl.h> // for LEDControl
|
||||||
|
#include <Kaleidoscope-LED-Palette-Theme.h> // for LEDPaletteTheme
|
||||||
|
#include <stdint.h> // for uint8_t, uint16_t
|
||||||
|
|
||||||
|
#include "kaleidoscope/KeyAddr.h" // for KeyAddr
|
||||||
|
#include "kaleidoscope/Runtime.h" // for Runtime, Runtime_
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
namespace defaultcolormap {
|
||||||
|
__attribute__((weak)) extern const cRGB palette[] = {};
|
||||||
|
__attribute__((weak)) extern bool palette_defined = false;
|
||||||
|
__attribute__((weak)) extern const uint8_t colormaps[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] = {};
|
||||||
|
__attribute__((weak)) extern uint8_t colormap_layers = 0;
|
||||||
|
} // namespace defaultcolormap
|
||||||
|
|
||||||
|
void DefaultColormap::setup() {
|
||||||
|
// If the colormap is already initialized, return early.
|
||||||
|
if (!::ColormapEffect.isUninitialized())
|
||||||
|
return;
|
||||||
|
|
||||||
|
install();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultColormap::install() {
|
||||||
|
if (!defaultcolormap::palette_defined) return;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < 16; i++) {
|
||||||
|
cRGB color;
|
||||||
|
|
||||||
|
color.r = pgm_read_byte(&(defaultcolormap::palette[i].r));
|
||||||
|
color.g = pgm_read_byte(&(defaultcolormap::palette[i].g));
|
||||||
|
color.b = pgm_read_byte(&(defaultcolormap::palette[i].b));
|
||||||
|
|
||||||
|
::LEDPaletteTheme.updatePaletteColor(i, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultcolormap::colormap_layers == 0) return;
|
||||||
|
|
||||||
|
for (uint8_t layer = 0; layer < defaultcolormap::colormap_layers; layer++) {
|
||||||
|
for (int8_t i = 0; i < Runtime.device().numKeys(); i++) {
|
||||||
|
const int8_t post = Runtime.device().ledDriver().getLedIndex(i);
|
||||||
|
const uint8_t idx = pgm_read_byte(&(defaultcolormap::colormaps[layer][i]));
|
||||||
|
::ColormapEffect.updateColorIndexAtPosition(layer, post, idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Runtime.storage().commit();
|
||||||
|
|
||||||
|
::LEDControl.refreshAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHandlerResult DefaultColormap::onFocusEvent(const char *input) {
|
||||||
|
if (!Runtime.has_leds)
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
|
||||||
|
const char *cmd = PSTR("colormap.install");
|
||||||
|
|
||||||
|
if (::Focus.inputMatchesHelp(input))
|
||||||
|
return ::Focus.printHelp(cmd);
|
||||||
|
|
||||||
|
if (!::Focus.inputMatchesCommand(input, cmd))
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
|
||||||
|
install();
|
||||||
|
return EventHandlerResult::EVENT_CONSUMED;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
kaleidoscope::plugin::DefaultColormap DefaultColormap;
|
@ -0,0 +1,96 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope-Colormap -- Per-layer colormap effect
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* 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 <Arduino.h> // for PROGMEM
|
||||||
|
#include <stdint.h> // for uint8_t
|
||||||
|
|
||||||
|
#include "kaleidoscope_internal/device.h" // for device
|
||||||
|
#include "kaleidoscope/device/device.h" // for cRGB
|
||||||
|
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult
|
||||||
|
#include "kaleidoscope/plugin.h" // for Plugin
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
|
#define COLORMAPS(layers...) \
|
||||||
|
namespace kaleidoscope { \
|
||||||
|
namespace plugin { \
|
||||||
|
namespace defaultcolormap { \
|
||||||
|
const uint8_t colormaps[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] PROGMEM = { \
|
||||||
|
layers \
|
||||||
|
}; \
|
||||||
|
uint8_t colormap_layers = \
|
||||||
|
sizeof(colormaps) / sizeof(*colormaps); \
|
||||||
|
} /* defaultcolormap */ \
|
||||||
|
} /* plugin */ \
|
||||||
|
} /* kaleidoscope */
|
||||||
|
|
||||||
|
#define __IDENTITY__(X) X
|
||||||
|
|
||||||
|
#ifdef PER_KEY_DATA_STACKED
|
||||||
|
#define COLORMAP_STACKED(...) \
|
||||||
|
{ \
|
||||||
|
MAP_LIST(__IDENTITY__, PER_KEY_DATA_STACKED(0, __VA_ARGS__)) \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PER_KEY_DATA
|
||||||
|
#define COLORMAP(...) \
|
||||||
|
{ \
|
||||||
|
MAP_LIST(__IDENTITY__, PER_KEY_DATA(0, __VA_ARGS__)) \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PALETTE(p0, p1, p2, p3, p4, p5, p6, p7, \
|
||||||
|
p8, p9, pa, pb, pc, pd, pe, pf) \
|
||||||
|
namespace kaleidoscope { \
|
||||||
|
namespace plugin { \
|
||||||
|
namespace defaultcolormap { \
|
||||||
|
const cRGB palette[] PROGMEM = { \
|
||||||
|
p0, p1, p2, p3, p4, p5, p6, p7, \
|
||||||
|
p8, p9, pa, pb, pc, pd, pe, pf \
|
||||||
|
}; \
|
||||||
|
bool palette_defined = true; \
|
||||||
|
} /* defaultcolormap */ \
|
||||||
|
} /* plugin */ \
|
||||||
|
} /* kaleidoscope */
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
namespace defaultcolormap {
|
||||||
|
extern bool palette_defined;
|
||||||
|
extern const cRGB palette[];
|
||||||
|
extern const uint8_t colormaps[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns];
|
||||||
|
extern uint8_t colormap_layers;
|
||||||
|
} // namespace defaultcolormap
|
||||||
|
|
||||||
|
class DefaultColormap : public Plugin {
|
||||||
|
public:
|
||||||
|
static void setup();
|
||||||
|
static void install();
|
||||||
|
|
||||||
|
EventHandlerResult onFocusEvent(const char *input);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
extern kaleidoscope::plugin::DefaultColormap DefaultColormap;
|
@ -0,0 +1,62 @@
|
|||||||
|
# DefaultLEDModeConfig
|
||||||
|
|
||||||
|
The `DefaultLEDModeConfig` plugin provides a way to set a default LED mode, the
|
||||||
|
LED mode the device starts up with active, via Focus.
|
||||||
|
|
||||||
|
By default the first LED mode enabled will be the active one, unless set
|
||||||
|
otherwise in `setup()`. To make this configurable, without having to reorder the
|
||||||
|
LED modes, this plugin provides the necessary tools to accomplish that.
|
||||||
|
|
||||||
|
## Using the plugin
|
||||||
|
|
||||||
|
The example below shows how to use the plugin, including setting up a LED mode
|
||||||
|
other than the first to use as a default in case EEPROM is uninitialized.
|
||||||
|
|
||||||
|
```c++
|
||||||
|
#include <Kaleidoscope.h>
|
||||||
|
#include <Kaleidoscope-EEPROM-Settings.h>
|
||||||
|
#include <Kaleidoscope-LEDControl.h>
|
||||||
|
#include <Kaleidoscope-DefaultLEDModeConfig.h>
|
||||||
|
#include <Kaleidoscope-LEDEffect-Rainbow.h>
|
||||||
|
#include <Kaleidoscope-FocusSerial.h>
|
||||||
|
|
||||||
|
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings,
|
||||||
|
LEDControl,
|
||||||
|
LEDOff,
|
||||||
|
LEDRainbowEffect,
|
||||||
|
LEDRainbowWaveEffect,
|
||||||
|
Focus,
|
||||||
|
DefaultLEDModeConfig);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Kaleidoscope.setup();
|
||||||
|
|
||||||
|
DefaultLEDModeConfig.activateLEDModeIfUnconfigured(
|
||||||
|
&LEDRainbowWaveEffect
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin methods
|
||||||
|
|
||||||
|
The plugin provides a singleton object called `DefaultLEDModeConfig`, with a single method:
|
||||||
|
|
||||||
|
### `.activateLEDModeIfUnconfigured(&LEDModePlugin)`
|
||||||
|
|
||||||
|
> Activates the LED mode pointed to by `&LEDModePlugin` if and only if the
|
||||||
|
> EEPROM slice of the plugin is unconfigured. This lets us set a default LED
|
||||||
|
> mode without persisting it into storage, or hard-coding it.
|
||||||
|
|
||||||
|
## Focus commands
|
||||||
|
|
||||||
|
### `led_mode.default`
|
||||||
|
|
||||||
|
> Without arguments, prints the default LED mode's index.
|
||||||
|
>
|
||||||
|
> If an argument is given, it must be the index of the LED mode we wish to set
|
||||||
|
> as the default.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
* [Kaleidoscope-EEPROM-Settings](Kaleidoscope-EEPROM-Settings.md)
|
||||||
|
* [Kaleidoscope-FocusSerial](Kaleidoscope-FocusSerial.md)
|
@ -0,0 +1,7 @@
|
|||||||
|
name=Kaleidoscope-DefaultLEDModeConfig
|
||||||
|
version=0.0.0
|
||||||
|
sentence=Save & restore the default LED mode
|
||||||
|
maintainer=Kaleidoscope's Developers <jesse@keyboard.io>
|
||||||
|
url=https://github.com/keyboardio/Kaleidoscope
|
||||||
|
author=Keyboardio
|
||||||
|
paragraph=
|
@ -0,0 +1,20 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "kaleidoscope/plugin/DefaultLEDModeConfig.h" // IWYU pragma: export
|
@ -0,0 +1,89 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kaleidoscope/plugin/DefaultLEDModeConfig.h"
|
||||||
|
|
||||||
|
#include <Arduino.h> // for PSTR, F, __FlashStringHelper
|
||||||
|
#include <Kaleidoscope-EEPROM-Settings.h> // for EEPROMSettings
|
||||||
|
#include <Kaleidoscope-FocusSerial.h> // for Focus, FocusSerial
|
||||||
|
#include <stdint.h> // for uint8_t, uint16_t
|
||||||
|
|
||||||
|
#include "kaleidoscope/Runtime.h" // for Runtime, Runtime_
|
||||||
|
#include "kaleidoscope/device/device.h" // for VirtualProps::Storage, Base<>::Storage
|
||||||
|
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult, EventHandlerResult::OK
|
||||||
|
#include "kaleidoscope/plugin/LEDControl.h" // for LEDControl
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
uint16_t DefaultLEDModeConfig::settings_base_;
|
||||||
|
struct DefaultLEDModeConfig::settings DefaultLEDModeConfig::settings_;
|
||||||
|
|
||||||
|
EventHandlerResult DefaultLEDModeConfig::onSetup() {
|
||||||
|
settings_base_ = ::EEPROMSettings.requestSlice(sizeof(settings_));
|
||||||
|
|
||||||
|
Runtime.storage().get(settings_base_, settings_);
|
||||||
|
|
||||||
|
// If our slice is uninitialized, then return early, without touching the
|
||||||
|
// current mode.
|
||||||
|
if (Runtime.storage().isSliceUninitialized(settings_base_, sizeof(settings_)))
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
|
||||||
|
::LEDControl.set_mode(settings_.default_mode_index);
|
||||||
|
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHandlerResult DefaultLEDModeConfig::onFocusEvent(const char *input) {
|
||||||
|
const char *cmd = PSTR("led_mode.default");
|
||||||
|
|
||||||
|
if (::Focus.inputMatchesHelp(input))
|
||||||
|
return ::Focus.printHelp(cmd);
|
||||||
|
|
||||||
|
if (!::Focus.inputMatchesCommand(input, cmd))
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
|
||||||
|
if (::Focus.isEOL()) {
|
||||||
|
::Focus.send(settings_.default_mode_index);
|
||||||
|
} else {
|
||||||
|
uint8_t idx;
|
||||||
|
::Focus.read(idx);
|
||||||
|
settings_.default_mode_index = idx;
|
||||||
|
|
||||||
|
::LEDControl.set_mode(idx);
|
||||||
|
Runtime.storage().put(settings_base_, settings_);
|
||||||
|
Runtime.storage().commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return EventHandlerResult::EVENT_CONSUMED;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHandlerResult DefaultLEDModeConfig::onNameQuery() {
|
||||||
|
return ::Focus.sendName(F("DefaultLEDModeConfig"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultLEDModeConfig::activateLEDModeIfUnconfigured(LEDModeInterface *plugin) {
|
||||||
|
if (!Runtime.storage().isSliceUninitialized(settings_base_, sizeof(settings_)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
plugin->activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
kaleidoscope::plugin::DefaultLEDModeConfig DefaultLEDModeConfig;
|
@ -0,0 +1,47 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include <stdint.h> // for uint8_t, uint16_t
|
||||||
|
|
||||||
|
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult
|
||||||
|
#include "kaleidoscope/plugin.h" // for Plugin
|
||||||
|
#include "kaleidoscope/plugin/LEDModeInterface.h" // for LEDModeInterface
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
class DefaultLEDModeConfig : public kaleidoscope::Plugin {
|
||||||
|
public:
|
||||||
|
EventHandlerResult onSetup();
|
||||||
|
EventHandlerResult onNameQuery();
|
||||||
|
EventHandlerResult onFocusEvent(const char *input);
|
||||||
|
|
||||||
|
void activateLEDModeIfUnconfigured(LEDModeInterface *plugin);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static uint16_t settings_base_;
|
||||||
|
static struct settings {
|
||||||
|
uint8_t default_mode_index;
|
||||||
|
} settings_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
extern kaleidoscope::plugin::DefaultLEDModeConfig DefaultLEDModeConfig;
|
@ -0,0 +1,36 @@
|
|||||||
|
# FirmwareVersion
|
||||||
|
|
||||||
|
Implements a new focus command - version - that simply prints the version set up
|
||||||
|
at compile time.
|
||||||
|
|
||||||
|
## Using the plugin
|
||||||
|
|
||||||
|
To use the plugin, first define the version to be printed, then include the
|
||||||
|
header, and activate the plugin.
|
||||||
|
|
||||||
|
```c++
|
||||||
|
#define KALEIDOSCOPE_FIRMWARE_VERSION "0.1.2"
|
||||||
|
|
||||||
|
#include <Kaleidoscope.h>
|
||||||
|
#include <Kaleidoscope-FirmwareVersion.h>
|
||||||
|
#include <Kaleidoscope-FocusSerial.h>
|
||||||
|
|
||||||
|
KALEIDOSCOPE_INIT_PLUGINS(Focus,
|
||||||
|
FirmwareVersion);
|
||||||
|
|
||||||
|
void setup () {
|
||||||
|
Kaleidoscope.setup ();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Focus commands
|
||||||
|
|
||||||
|
The plugin provides a single Focus command: `version`.
|
||||||
|
|
||||||
|
### `version`
|
||||||
|
|
||||||
|
> Prints the version configured at build time.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
* [Kaleidoscope-FocusSerial](Kaleidoscope-FocusSerial.md)
|
@ -0,0 +1,7 @@
|
|||||||
|
name=Kaleidoscope-FirmwareVersion
|
||||||
|
version=0.0.0
|
||||||
|
sentence=Provides a Focus command to print a preconfigured version
|
||||||
|
maintainer=Kaleidoscope's Developers <jesse@keyboard.io>
|
||||||
|
url=https://github.com/keyboardio/Kaleidoscope
|
||||||
|
author=Keyboardio
|
||||||
|
paragraph=
|
@ -0,0 +1,20 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope-FirmwareVersion -- Provides a Focus command to print a version
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "kaleidoscope/plugin/FirmwareVersion.h" // IWYU pragma: export
|
@ -0,0 +1,56 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope-FirmwareVersion -- Provides a Focus command to print a version
|
||||||
|
* Copyright (C) 2022 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#ifndef KALEIDOSCOPE_FIRMWARE_VERSION
|
||||||
|
#define KALEIDOSCOPE_FIRMWARE_VERSION "0.0.0"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Arduino.h> // for PSTR, F, __FlashStringHelper
|
||||||
|
#include "Kaleidoscope-FocusSerial.h" // for Focus, FocusSerial
|
||||||
|
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult
|
||||||
|
#include "kaleidoscope/plugin.h" // for Plugin
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
class FirmwareVersion : public Plugin {
|
||||||
|
public:
|
||||||
|
EventHandlerResult onFocusEvent(const char *input) {
|
||||||
|
const char *cmd_version = PSTR("version");
|
||||||
|
|
||||||
|
if (::Focus.inputMatchesHelp(input))
|
||||||
|
return ::Focus.printHelp(cmd_version);
|
||||||
|
|
||||||
|
if (!::Focus.inputMatchesCommand(input, cmd_version))
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
|
||||||
|
#ifdef KALEIDOSCOPE_FIRMWARE_VERSION
|
||||||
|
::Focus.send(F(KALEIDOSCOPE_FIRMWARE_VERSION));
|
||||||
|
#else
|
||||||
|
::Focus.send(F("0.0.0"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
kaleidoscope::plugin::FirmwareVersion FirmwareVersion;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue