Merge pull request #1143 from gedankenexperimenter/clang-format

Switch from `astyle` to `clang-format` for code formatting
pull/1149/head
Jesse Vincent 3 years ago committed by GitHub
commit aba8c9ee66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,47 @@
# -*- mode: yaml -*-
---
BasedOnStyle: Google
---
Language: Cpp
AlignConsecutiveAssignments: Consecutive
## clang-format-15
# AlignConsecutiveAssignments:
# Enabled: true
# AlignCompound: true
# PadOperators: true
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: AcrossEmptyLines
AlignEscapedNewlines: Right
AllowShortBlocksOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortFunctionsOnASingleLine: Inline
AllowShortLoopsOnASingleLine: true
AttributeMacros:
- __attribute__((weak))
- __attribute__((always_inline))
- __attribute__((noinline))
- __attribute__((packed))
- __attribute__((optimize(3)))
- __attribute__((unused))
BinPackArguments: false
BinPackParameters: false
# BraceWrapping:
# SplitEmptyFunction: false
# SplitEmptyRecord: true
# SplitEmptyNamespace: true
# BreakBeforeBraces: Custom
ColumnLimit: 0
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
DerivePointerAlignment: false
FixNamespaceComments: true
IndentCaseLabels: false
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
# PackConstructorInitializers: CurrentLine
PointerAlignment: Right
# ReferenceAlignment: Right
ReflowComments: false
SortIncludes: false
SpaceAfterTemplateKeyword: false

@ -6,6 +6,7 @@ env:
LC_ALL: C LC_ALL: C
KALEIDOSCOPE_CCACHE: 1 KALEIDOSCOPE_CCACHE: 1
ARDUINO_DIRECTORIES_USER: ${{ github.workspace }}/.arduino/user ARDUINO_DIRECTORIES_USER: ${{ github.workspace }}/.arduino/user
CLANG_FORMAT_CMD: clang-format-12
jobs: jobs:
smoke-sketches: smoke-sketches:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -25,12 +26,11 @@ jobs:
- run: sudo apt-get install ccache - run: sudo apt-get install ccache
- run: make setup - run: make setup
- run: make -j $(nproc) simulator-tests - run: make -j $(nproc) simulator-tests
check-astyle: check-formatting:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- run: sudo apt-get install astyle
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: make check-astyle - run: make check-formatting
check-shellcheck: check-shellcheck:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

@ -88,17 +88,13 @@ adjust-git-timestamps:
find-filename-conflicts: find-filename-conflicts:
bin/find-filename-conflicts bin/find-filename-conflicts
.PHONY: astyle test cpplint cpplint-noisy shellcheck smoke-examples find-filename-conflicts prepare-virtual checkout-platform adjust-git-timestamps docker-bash docker-simulator-tests run-tests simulator-tests setup .PHONY: format check-formatting cpplint cpplint-noisy shellcheck smoke-examples find-filename-conflicts prepare-virtual checkout-platform adjust-git-timestamps docker-bash docker-simulator-tests run-tests simulator-tests setup
astyle: format:
find ./* -type f \( -name '*.h' -o -name '*.cpp' -o -name '*.ino' \) | grep -v "testing/googletest" | xargs -n 1 astyle --project bin/format-code.sh
check-astyle: astyle check-formatting:
if ! git diff --exit-code; then \ bin/format-code.sh --check
>&2 echo "'astyle' found code style differences. Please make astyle and commit your changes"; \
exit 1; \
fi; \
exit 0;
cpplint-noisy: cpplint-noisy:
-bin/cpplint.py --filter=-legal/copyright,-build/include,-readability/namespace,-whitespace/line_length,-runtime/references --recursive --extensions=cpp,h,ino src examples -bin/cpplint.py --filter=-legal/copyright,-build/include,-readability/namespace,-whitespace/line_length,-runtime/references --recursive --extensions=cpp,h,ino src examples

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Allow the caller to specify a particular version of clang-format to use:
: "${CLANG_FORMAT_CMD:=clang-format}"
# Find all *.cpp and *.h files, except those in `testing/googletest/` and files
# generated by testcase scripts, and run `clang-format` on them:
find ./* -type f \( -name '*.h' -o -name '*.cpp' \) \
-not \( -path './testing/googletest/*' -o -name 'generated-testcase.cpp' \) \
-print0 | \
xargs -0 "${CLANG_FORMAT_CMD}" -i
# If we get the `--check` option, return an error if there are any changes to
# the git working tree after running `clang-format`:
if [[ $1 == '--check' ]]; then
if ! git diff --quiet; then
cat >&2 <<EOF
Differences found between git head and working tree. Either 'clang-format' made
formatting changes to your code, or you had uncommitted changes in your working
tree. Please remember to run 'bin/format-code.sh' before committing changes.
EOF
exit 1
fi
fi

@ -34,7 +34,6 @@ class AppSwitcher : public kaleidoscope::Plugin {
private: private:
KeyAddr active_addr_ = KeyAddr::none(); KeyAddr active_addr_ = KeyAddr::none();
}; };
} // namespace plugin } // namespace plugin

@ -62,8 +62,7 @@ void AutoShift::disable() {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Test for whether or not to apply AutoShift to a given `Key`. This function // Test for whether or not to apply AutoShift to a given `Key`. This function
// can be overridden from the user sketch. // can be overridden from the user sketch.
__attribute__((weak)) __attribute__((weak)) bool AutoShift::isAutoShiftable(Key key) {
bool AutoShift::isAutoShiftable(Key key) {
return enabledForKey(key); return enabledForKey(key);
} }

@ -72,7 +72,8 @@ class AutoShift : public Plugin {
public: public:
// Basic un-checked constructor // Basic un-checked constructor
constexpr Categories(uint8_t raw_bits) : raw_bits_(raw_bits) {} constexpr Categories(uint8_t raw_bits)
: raw_bits_(raw_bits) {}
static constexpr Categories letterKeys() { static constexpr Categories letterKeys() {
return Categories(LETTERS); return Categories(LETTERS);

@ -131,13 +131,15 @@ CharShift::KeyPair CharShift::decodeCharShiftKey(Key key) {
// This should be overridden if the KeyPairs array is stored in EEPROM // This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak)) __attribute__((weak))
uint8_t CharShift::numKeyPairs() { uint8_t
CharShift::numKeyPairs() {
return numProgmemKeyPairs(); return numProgmemKeyPairs();
} }
// This should be overridden if the KeyPairs array is stored in EEPROM // This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak)) __attribute__((weak))
CharShift::KeyPair CharShift::readKeyPair(uint8_t n) { CharShift::KeyPair
CharShift::readKeyPair(uint8_t n) {
return readKeyPairFromProgmem(n); return readKeyPairFromProgmem(n);
} }

@ -59,7 +59,8 @@ class CharShift : public Plugin {
/// ///
/// This constructor is used when defining an array of `KeyPair` objects in /// This constructor is used when defining an array of `KeyPair` objects in
/// PROGMEM (though it can also be used elsewhere). /// PROGMEM (though it can also be used elsewhere).
constexpr KeyPair(Key lower, Key upper) : lower(lower), upper(upper) {} constexpr KeyPair(Key lower, Key upper)
: lower(lower), upper(upper) {}
/// Constructor for reading from PROGMEM /// Constructor for reading from PROGMEM
/// ///
@ -125,10 +126,10 @@ extern kaleidoscope::plugin::CharShift CharShift;
/// defines them as an array in PROGMEM, and configures `CharShift` to use that /// defines them as an array in PROGMEM, and configures `CharShift` to use that
/// array, automatically setting the count correctly to prevent out-of-bounds /// array, automatically setting the count correctly to prevent out-of-bounds
/// lookups. /// lookups.
#define CS_KEYS(keypairs...) { \ #define CS_KEYS(keypairs...) \
{ \
static kaleidoscope::plugin::CharShift::KeyPair const kp_table[] PROGMEM = { \ static kaleidoscope::plugin::CharShift::KeyPair const kp_table[] PROGMEM = { \
keypairs \ keypairs}; \
}; \
CharShift.setProgmemKeyPairs(kp_table); \ CharShift.setProgmemKeyPairs(kp_table); \
} }

@ -68,8 +68,7 @@ EventHandlerResult ColormapEffect::onLayerChange() {
} }
EventHandlerResult ColormapEffect::onFocusEvent(const char *command) { EventHandlerResult ColormapEffect::onFocusEvent(const char *command) {
return ::LEDPaletteTheme.themeFocusEvent(command, PSTR("colormap.map"), return ::LEDPaletteTheme.themeFocusEvent(command, PSTR("colormap.map"), map_base_, max_layers_);
map_base_, max_layers_);
} }
} // namespace plugin } // namespace plugin

@ -44,21 +44,20 @@ class ColormapEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
// //
explicit TransientLEDMode(const ColormapEffect *parent) : parent_(parent) {} explicit TransientLEDMode(const ColormapEffect *parent)
: parent_(parent) {}
protected: protected:
friend class ColormapEffect; friend class ColormapEffect;
void onActivate(void) final; void onActivate(void) final;
void refreshAt(KeyAddr key_addr) final; void refreshAt(KeyAddr key_addr) final;
private:
private:
const ColormapEffect *parent_; const ColormapEffect *parent_;
}; };

@ -113,8 +113,7 @@ uint8_t Cycle::toModFlag(uint8_t keyCode) {
} // namespace plugin } // namespace plugin
} // namespace kaleidoscope } // namespace kaleidoscope
__attribute__((weak)) __attribute__((weak)) void cycleAction(Key previous_key, uint8_t cycle_count) {
void cycleAction(Key previous_key, uint8_t cycle_count) {
} }
kaleidoscope::plugin::Cycle Cycle; kaleidoscope::plugin::Cycle Cycle;

@ -62,8 +62,7 @@ EventHandlerResult CycleTimeReport::afterEachCycle() {
} // namespace kaleidoscope } // namespace kaleidoscope
__attribute__((weak)) void cycleTimeReport(void) { __attribute__((weak)) void cycleTimeReport(void) {
Focus.send(Focus.COMMENT, F("average loop time:"), CycleTimeReport.average_loop_time, Focus.send(Focus.COMMENT, F("average loop time:"), CycleTimeReport.average_loop_time, Focus.NEWLINE);
Focus.NEWLINE);
} }
kaleidoscope::plugin::CycleTimeReport CycleTimeReport; kaleidoscope::plugin::CycleTimeReport CycleTimeReport;

@ -72,24 +72,19 @@ struct string {
#endif #endif
}; };
template <typename TSourceString, size_t remainingLength, template<typename TSourceString, size_t remainingLength, char... collectedChars>
char... collectedChars>
struct string_maker { struct string_maker {
using result = using result =
typename string_maker < TSourceString, remainingLength - 1, typename string_maker<TSourceString, remainingLength - 1, TSourceString::data()[remainingLength - 1], collectedChars...>::result;
TSourceString::data()[remainingLength - 1],
collectedChars... >::result;
}; };
#if ARDUINOTRACE_ENABLE_FULLPATH == 0 #if ARDUINOTRACE_ENABLE_FULLPATH == 0
template <typename TSourceString, size_t remainingLength, template<typename TSourceString, size_t remainingLength, char... collectedChars>
char... collectedChars>
struct string_maker<TSourceString, remainingLength, '/', collectedChars...> { struct string_maker<TSourceString, remainingLength, '/', collectedChars...> {
using result = string<collectedChars..., '\0'>; using result = string<collectedChars..., '\0'>;
}; };
template <typename TSourceString, size_t remainingLength, template<typename TSourceString, size_t remainingLength, char... collectedChars>
char... collectedChars>
struct string_maker<TSourceString, remainingLength, '\\', collectedChars...> { struct string_maker<TSourceString, remainingLength, '\\', collectedChars...> {
using result = string<collectedChars..., '\0'>; using result = string<collectedChars..., '\0'>;
}; };
@ -173,9 +168,7 @@ struct Printer {
// However, if you use it at global scope, you need to call ARDUINOTRACE_INIT() // However, if you use it at global scope, you need to call ARDUINOTRACE_INIT()
// first, otherwise, the Serial port will not be ready. // first, otherwise, the Serial port will not be ready.
#define TRACE() \ #define TRACE() \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \ ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_TRACE_PREFIX(__LINE__), ARDUINOTRACE_FUNCTION_NAME)
ARDUINOTRACE_TRACE_PREFIX(__LINE__), \
ARDUINOTRACE_FUNCTION_NAME)
// Prints the value of a variable. // Prints the value of a variable.
// //
@ -183,8 +176,7 @@ struct Printer {
// Serial. If you use it at global scope, you need to call ARDUINOTRACE_INIT() // Serial. If you use it at global scope, you need to call ARDUINOTRACE_INIT()
// first, otherwise, the Serial port will not be ready. // first, otherwise, the Serial port will not be ready.
#define DUMP(variable) \ #define DUMP(variable) \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \ ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
#else // ie ARDUINOTRACE_ENABLE == 0 #else // ie ARDUINOTRACE_ENABLE == 0

@ -68,8 +68,7 @@ void DynamicTapDance::updateDynamicTapDanceCache() {
} }
} }
bool DynamicTapDance::dance(uint8_t tap_dance_index, KeyAddr key_addr, bool DynamicTapDance::dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, TapDance::ActionType tap_dance_action) {
uint8_t tap_count, TapDance::ActionType tap_dance_action) {
uint16_t pos = map_[tap_dance_index - offset_] + ((tap_count - 1) * 2); uint16_t pos = map_[tap_dance_index - offset_] + ((tap_count - 1) * 2);
uint16_t next_pos = map_[tap_dance_index - offset_ + 1]; uint16_t next_pos = map_[tap_dance_index - offset_ + 1];
if (next_pos <= pos || (tap_dance_index > offset_ + dance_count_)) if (next_pos <= pos || (tap_dance_index > offset_ + dance_count_))

@ -37,8 +37,7 @@ class DynamicTapDance: public kaleidoscope::Plugin {
static void setup(uint8_t dynamic_offset, uint16_t size); static void setup(uint8_t dynamic_offset, uint16_t size);
static bool dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, static bool dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, TapDance::ActionType tap_dance_action);
TapDance::ActionType tap_dance_action);
private: private:
static uint16_t storage_base_; static uint16_t storage_base_;

@ -28,8 +28,7 @@
#include "crc.h" #include "crc.h"
void void CRC_::reflect(uint8_t len) {
CRC_::reflect(uint8_t len) {
uint8_t i; uint8_t i;
uint16_t newCRC; uint16_t newCRC;
@ -42,8 +41,7 @@ CRC_::reflect(uint8_t len) {
crc = newCRC; crc = newCRC;
} }
void void CRC_::update(const void *data, uint8_t len) {
CRC_::update(const void *data, uint8_t len) {
const uint8_t *d = (const uint8_t *)data; const uint8_t *d = (const uint8_t *)data;
uint8_t i; uint8_t i;
bool bit; bool bit;

@ -28,8 +28,7 @@ namespace kaleidoscope {
namespace plugin { namespace plugin {
EscapeOneShot::Settings EscapeOneShot::settings_ = { EscapeOneShot::Settings EscapeOneShot::settings_ = {
.cancel_oneshot_key = Key_Escape .cancel_oneshot_key = Key_Escape};
};
EventHandlerResult EscapeOneShot::onKeyEvent(KeyEvent &event) { EventHandlerResult EscapeOneShot::onKeyEvent(KeyEvent &event) {
// We only act on an escape key (or `cancel_oneshot_key_`, if that has been // We only act on an escape key (or `cancel_oneshot_key_`, if that has been

@ -37,6 +37,7 @@ class FirmwareDump : public kaleidoscope::Plugin {
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
private: private:
uint16_t bootloader_size_; uint16_t bootloader_size_;
}; };

@ -44,10 +44,7 @@ EventHandlerResult FocusSerial::afterEachCycle() {
do { do {
command_[buf_cursor_++] = Runtime.serialPort().read(); command_[buf_cursor_++] = Runtime.serialPort().read();
} while (command_[buf_cursor_ - 1] != SEPARATOR } while (command_[buf_cursor_ - 1] != SEPARATOR && buf_cursor_ < sizeof(command_) && Runtime.serialPort().available() && (Runtime.serialPort().peek() != NEWLINE));
&& buf_cursor_ < sizeof(command_)
&& Runtime.serialPort().available()
&& (Runtime.serialPort().peek() != NEWLINE));
// If there was no command, there's nothing to do // If there was no command, there's nothing to do
@ -57,9 +54,7 @@ EventHandlerResult FocusSerial::afterEachCycle() {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
if ((command_[buf_cursor_ - 1] != SEPARATOR) && (Runtime.serialPort().peek() != NEWLINE) if ((command_[buf_cursor_ - 1] != SEPARATOR) && (Runtime.serialPort().peek() != NEWLINE) && buf_cursor_ < sizeof(command_)) {
&& buf_cursor_ < sizeof(command_)
) {
// We don't have enough command to work with yet. // We don't have enough command to work with yet.
// Let's leave the buffer around for another cycle // Let's leave the buffer around for another cycle
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -86,7 +81,6 @@ EventHandlerResult FocusSerial::afterEachCycle() {
buf_cursor_ = 0; buf_cursor_ = 0;
memset(command_, 0, sizeof(command_)); memset(command_, 0, sizeof(command_));
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
bool FocusSerial::handleHelp(const char *command, bool FocusSerial::handleHelp(const char *command,

@ -371,9 +371,11 @@ void RaiseKeyScanner::setKeyscanInterval(uint8_t interval) {
} }
void RaiseKeyScanner::setup() { void RaiseKeyScanner::setup() {
// clang-format off
static constexpr uint8_t keyscanner_pins[] = { static constexpr uint8_t keyscanner_pins[] = {
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, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 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, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
}; // clang-format on
for (int i = 0; i < sizeof(keyscanner_pins); i++) { for (int i = 0; i < sizeof(keyscanner_pins); i++) {
pinMode(keyscanner_pins[i], OUTPUT); pinMode(keyscanner_pins[i], OUTPUT);
digitalWrite(keyscanner_pins[i], LOW); digitalWrite(keyscanner_pins[i], LOW);

@ -23,7 +23,8 @@
#include "kaleidoscope/device/dygma/raise/RaiseSide.h" #include "kaleidoscope/device/dygma/raise/RaiseSide.h"
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#include "kaleidoscope/device/Base.h" #include "kaleidoscope/device/Base.h"
#include "kaleidoscope/driver/bootloader/samd/Bossac.h" #include "kaleidoscope/driver/bootloader/samd/Bossac.h"
@ -44,6 +45,7 @@ using kaleidoscope::driver::led::no_led;
struct RaiseLEDDriverProps : public kaleidoscope::driver::led::BaseProps { struct RaiseLEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 132; static constexpr uint8_t led_count = 132;
// clang-format off
static constexpr uint8_t key_led_map[] = { static constexpr uint8_t key_led_map[] = {
// ISO & ANSI (ANSI has no LED at 20, but this key can never be pressed so we can have just one map). // ISO & ANSI (ANSI has no LED at 20, but this key can never be pressed so we can have just one map).
0, 1, 2, 3, 4, 5, 6, no_led, no_led, 6 + LHK, 5 + LHK, 4 + LHK, 3 + LHK, 2 + LHK, 1 + LHK, 0 + LHK, 0, 1, 2, 3, 4, 5, 6, no_led, no_led, 6 + LHK, 5 + LHK, 4 + LHK, 3 + LHK, 2 + LHK, 1 + LHK, 0 + LHK,
@ -51,7 +53,7 @@ struct RaiseLEDDriverProps : public kaleidoscope::driver::led::BaseProps {
13, 14, 15, 16, 17, 18, no_led, no_led, no_led, 21 + LHK, 20 + LHK, 19 + LHK, 18 + LHK, 17 + LHK, 16 + LHK, 15 + LHK, 13, 14, 15, 16, 17, 18, no_led, no_led, no_led, 21 + LHK, 20 + LHK, 19 + LHK, 18 + LHK, 17 + LHK, 16 + LHK, 15 + LHK,
19, 20, 21, 22, 23, 24, 25, no_led, no_led, no_led, 27 + LHK, 26 + LHK, 25 + LHK, 24 + LHK, 23 + LHK, 22 + LHK, 19, 20, 21, 22, 23, 24, 25, no_led, no_led, no_led, 27 + LHK, 26 + LHK, 25 + LHK, 24 + LHK, 23 + LHK, 22 + LHK,
26, 27, 28, 29, 30, no_led, 31, 32, 35 + LHK, 34 + LHK, 33 + LHK, 32 + LHK, 31 + LHK, 30 + LHK, 29 + LHK, 28 + LHK 26, 27, 28, 29, 30, no_led, 31, 32, 35 + LHK, 34 + LHK, 33 + LHK, 32 + LHK, 31 + LHK, 30 + LHK, 29 + LHK, 28 + LHK
}; }; // clang-format on
}; };
#undef LHK #undef LHK
@ -66,6 +68,7 @@ class RaiseLEDDriver : public kaleidoscope::driver::led::Base<RaiseLEDDriverProp
static uint8_t getBrightness(); static uint8_t getBrightness();
static void updateNeuronLED(); static void updateNeuronLED();
private: private:
static bool isLEDChangedNeuron; static bool isLEDChangedNeuron;
static uint8_t isLEDChangedLeft[LED_BANKS]; static uint8_t isLEDChangedLeft[LED_BANKS];
@ -76,6 +79,7 @@ class RaiseLEDDriver : public kaleidoscope::driver::led::Base<RaiseLEDDriverProp
// led_count + 1, to account for the Neuron's LED. The last one is the // led_count + 1, to account for the Neuron's LED. The last one is the
// Neuron's LED, never send that to SLED. // Neuron's LED, never send that to SLED.
static constexpr uint8_t led_map[][RaiseLEDDriverProps::led_count + 1] = { static constexpr uint8_t led_map[][RaiseLEDDriverProps::led_count + 1] = {
// clang-format off
// ISO // ISO
{ {
// left side - 33 keys includes LP // left side - 33 keys includes LP
@ -108,7 +112,7 @@ class RaiseLEDDriver : public kaleidoscope::driver::led::Base<RaiseLEDDriverProp
34 + LPH, 35 + LPH, 36 + LPH, 37 + LPH, 38 + LPH, 39 + LPH, 40 + LPH, 41 + LPH, 42 + LPH, 43 + LPH, 44 + LPH, 45 + LPH, 46 + LPH, 47 + LPH, 48 + LPH, 49 + LPH, 50 + LPH, 51 + LPH, 34 + LPH, 35 + LPH, 36 + LPH, 37 + LPH, 38 + LPH, 39 + LPH, 40 + LPH, 41 + LPH, 42 + LPH, 43 + LPH, 44 + LPH, 45 + LPH, 46 + LPH, 47 + LPH, 48 + LPH, 49 + LPH, 50 + LPH, 51 + LPH,
52 + LPH, 53 + LPH, 54 + LPH, 55 + LPH, 56 + LPH, 57 + LPH, 58 + LPH, 59 + LPH, 60 + LPH, 61 + LPH, 62 + LPH, 63 + LPH, 64 + LPH, 65 + LPH, 0xff 52 + LPH, 53 + LPH, 54 + LPH, 55 + LPH, 56 + LPH, 57 + LPH, 58 + LPH, 59 + LPH, 60 + LPH, 61 + LPH, 62 + LPH, 63 + LPH, 64 + LPH, 65 + LPH, 0xff
} }
}; }; // clang-format on
}; };
struct RaiseKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps { struct RaiseKeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps {
@ -124,6 +128,7 @@ class RaiseKeyScanner : public kaleidoscope::driver::keyscanner::Base<RaiseKeySc
private: private:
typedef RaiseKeyScanner ThisType; typedef RaiseKeyScanner ThisType;
typedef RaiseKeyScannerProps Props_; typedef RaiseKeyScannerProps Props_;
public: public:
static void setup(); static void setup();
static void scanMatrix(); static void scanMatrix();
@ -175,6 +180,7 @@ struct RaiseProps : kaleidoscope::device::BaseProps {
class Raise : public kaleidoscope::device::Base<RaiseProps> { class Raise : public kaleidoscope::device::Base<RaiseProps> {
private: private:
static RaiseProps::SideFlasher SideFlasher; static RaiseProps::SideFlasher SideFlasher;
public: public:
static void setup(); static void setup();
@ -230,6 +236,8 @@ typedef kaleidoscope::device::dygma::Raise Device;
} // namespace kaleidoscope } // namespace kaleidoscope
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \ r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \ r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \

@ -57,7 +57,8 @@ typedef union {
class RaiseSide { class RaiseSide {
public: public:
explicit RaiseSide(uint8_t ad01) : ad01_(ad01), twi_(i2c_addr_base_ | ad01) {} explicit RaiseSide(uint8_t ad01)
: ad01_(ad01), twi_(i2c_addr_base_ | ad01) {}
int readVersion(); int readVersion();
int readSLEDVersion(); int readSLEDVersion();

@ -32,6 +32,7 @@ template <typename _Firmware>
class SideFlash : public kaleidoscope::Plugin { class SideFlash : public kaleidoscope::Plugin {
private: private:
_Firmware firmware; _Firmware firmware;
public: public:
EventHandlerResult onFocusEvent(const char *command) { EventHandlerResult onFocusEvent(const char *command) {
if (::Focus.handleHelp(command, PSTR("hardware.flash_left_side\nhardware.flash_right_side\nhardware.verify_left_side\nhardware.verify_right_side"))) if (::Focus.handleHelp(command, PSTR("hardware.flash_left_side\nhardware.flash_right_side\nhardware.verify_left_side\nhardware.verify_right_side")))

@ -29,7 +29,8 @@ namespace raise {
class TWI { class TWI {
public: public:
explicit TWI(int addr) : addr_(addr), crc_errors_(0) {} explicit TWI(int addr)
: addr_(addr), crc_errors_(0) {}
uint8_t writeTo(uint8_t *data, size_t length); uint8_t writeTo(uint8_t *data, size_t length);
uint8_t readFrom(uint8_t *data, size_t length); uint8_t readFrom(uint8_t *data, size_t length);

@ -148,9 +148,8 @@ void ErgoDox::setStatusLED(uint8_t led, bool state) {
} }
void ErgoDox::setStatusLEDBrightness(uint8_t led, uint8_t brightness) { void ErgoDox::setStatusLEDBrightness(uint8_t led, uint8_t brightness) {
(led == 1) ? (OCR1A = brightness) : (led == 1) ? (OCR1A = brightness) : (led == 2) ? (OCR1B = brightness)
(led == 2) ? (OCR1B = brightness) : : (OCR1C = brightness);
(OCR1C = brightness);
} }
uint8_t ErgoDox::debounceMaskForRow(uint8_t row) { uint8_t ErgoDox::debounceMaskForRow(uint8_t row) {

@ -33,7 +33,8 @@ struct cRGB {
uint8_t r, g, b; uint8_t r, g, b;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#include "kaleidoscope/device/ATmega32U4Keyboard.h" #include "kaleidoscope/device/ATmega32U4Keyboard.h"
#include "kaleidoscope/driver/bootloader/avr/HalfKay.h" #include "kaleidoscope/driver/bootloader/avr/HalfKay.h"
@ -51,7 +52,6 @@ struct ErgoDoxProps : public kaleidoscope::device::ATmega32U4KeyboardProps {
static constexpr uint8_t matrix_rows = 14; static constexpr uint8_t matrix_rows = 14;
static constexpr uint8_t matrix_columns = 6; static constexpr uint8_t matrix_columns = 6;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
}; };
typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader; typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader;
static constexpr const char *short_name = "ErgoDox-EZ"; static constexpr const char *short_name = "ErgoDox-EZ";
@ -96,6 +96,8 @@ class ErgoDox : public kaleidoscope::device::ATmega32U4Keyboard<ErgoDoxProps> {
class ErgoDox; class ErgoDox;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA_STACKED(dflt, \ #define PER_KEY_DATA_STACKED(dflt, \
/* left hand, spatial positions */ \ /* left hand, spatial positions */ \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \ r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \

@ -90,8 +90,7 @@ out:
return status; return status;
} }
void void ErgoDoxScanner::begin() {
ErgoDoxScanner::begin() {
expander_error_ = initExpander(); expander_error_ = initExpander();
// Init columns // Init columns
@ -156,8 +155,7 @@ out:
} }
} }
void void ErgoDoxScanner::reattachExpanderOnError() {
ErgoDoxScanner::reattachExpanderOnError() {
static uint32_t start_time = millis(); static uint32_t start_time = millis();
if (!expander_error_) if (!expander_error_)

@ -53,7 +53,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed // wait until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -64,7 +65,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
// wail until transmission completed and ACK/NACK has been received // wail until transmission completed and ACK/NACK has been received
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -90,7 +92,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed // wait until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -101,7 +104,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
// wail until transmission completed // wail until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -110,7 +114,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released // wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO)); while (TWCR & (1 << TWSTO))
;
continue; continue;
} }
@ -143,7 +148,8 @@ void i2c_stop(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released // wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO)); while (TWCR & (1 << TWSTO))
;
} /* i2c_stop */ } /* i2c_stop */
@ -163,7 +169,8 @@ unsigned char i2c_write(unsigned char data) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
// wait until transmission completed // wait until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits // check value of TWI Status Register. Mask prescaler bits
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -180,7 +187,8 @@ unsigned char i2c_write(unsigned char data) {
*************************************************************************/ *************************************************************************/
unsigned char i2c_readAck(void) { unsigned char i2c_readAck(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA); TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
return TWDR; return TWDR;
@ -194,7 +202,8 @@ unsigned char i2c_readAck(void) {
*************************************************************************/ *************************************************************************/
unsigned char i2c_readNak(void) { unsigned char i2c_readNak(void) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
return TWDR; return TWDR;

@ -43,10 +43,12 @@ struct EvalProps: kaleidoscope::device::BaseProps {
class Eval : public kaleidoscope::device::Base<EvalProps> {}; class Eval : public kaleidoscope::device::Base<EvalProps> {};
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1 \ R0C0, R0C1 \
) \ ) \
R0C0, R0C1 R0C0, R0C1
// clang-format on
} // namespace gd32 } // namespace gd32
} // namespace device } // namespace device

@ -42,6 +42,7 @@ class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps>
private: private:
typedef KeyScanner ThisType; typedef KeyScanner ThisType;
typedef KeyScannerProps Props_; typedef KeyScannerProps Props_;
public: public:
static bool do_scan; static bool do_scan;
@ -55,6 +56,7 @@ class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps>
static bool wasKeyswitchPressed(KeyAddr key_addr); static bool wasKeyswitchPressed(KeyAddr key_addr);
static uint8_t previousPressedKeyswitchCount(); static uint8_t previousPressedKeyswitchCount();
private: private:
/* /*
each of these variables are storing the state for a row of keys each of these variables are storing the state for a row of keys

@ -44,7 +44,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -63,6 +63,7 @@ class KBD4x;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
@ -73,6 +74,7 @@ class KBD4x;
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace kbdfans } // namespace kbdfans
} // namespace device } // namespace device

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -61,6 +61,7 @@ class Atreus;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \
@ -89,6 +90,8 @@ class Atreus;
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace keyboardio } // namespace keyboardio
} // namespace device } // namespace device

@ -71,7 +71,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.
@ -190,7 +191,6 @@ void ImagoLEDDriver::setAllPwmTo(uint8_t step) {
// PWM Register 0 is 0x00 to 0xB3 // PWM Register 0 is 0x00 to 0xB3
for (auto i = 1; i <= 0xB4; i++) { for (auto i = 1; i <= 0xB4; i++) {
data[i] = step; data[i] = step;
} }
twi_writeTo(LED_DRIVER_ADDR, data, 0xB5, 1, 0); twi_writeTo(LED_DRIVER_ADDR, data, 0xB5, 1, 0);
@ -198,7 +198,6 @@ void ImagoLEDDriver::setAllPwmTo(uint8_t step) {
// PWM Register 1 is 0x00 to 0xAA // PWM Register 1 is 0x00 to 0xAA
for (auto i = 1; i <= LED_REGISTER_PWM1_SIZE; i++) { for (auto i = 1; i <= LED_REGISTER_PWM1_SIZE; i++) {
data[i] = step; data[i] = step;
} }
twi_writeTo(LED_DRIVER_ADDR, data, 0xAC, 1, 0); twi_writeTo(LED_DRIVER_ADDR, data, 0xAC, 1, 0);
} }

@ -27,7 +27,8 @@ struct cRGB {
uint8_t r; uint8_t r;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#include "kaleidoscope/device/ATmega32U4Keyboard.h" #include "kaleidoscope/device/ATmega32U4Keyboard.h"
#include "kaleidoscope/driver/bootloader/avr/Caterina.h" #include "kaleidoscope/driver/bootloader/avr/Caterina.h"
@ -43,11 +44,13 @@ using kaleidoscope::driver::led::no_led;
struct ImagoLEDDriverProps : public kaleidoscope::driver::led::BaseProps { struct ImagoLEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 78; static constexpr uint8_t led_count = 78;
static constexpr uint8_t key_led_map[/* 5*16 */] PROGMEM = { static constexpr uint8_t key_led_map[/* 5*16 */] PROGMEM = {
// clang-format off
104, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 115, 12, 116, 104, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 115, 12, 116,
91, 13, no_led, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 102, 15, 103, 91, 13, no_led, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 102, 15, 103,
78, 26, 27, 28, 29, 30, 31, no_led, 33, 34, 35, 36, 37, 89, 38, no_led, 78, 26, 27, 28, 29, 30, 31, no_led, 33, 34, 35, 36, 37, 89, 38, no_led,
65, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, no_led, 90, 65, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, no_led, 90,
52, 66, 53, 54, no_led, 56, 57, 71, 59, no_led, 61, 62, 63, 64, no_led, 77 52, 66, 53, 54, no_led, 56, 57, 71, 59, no_led, 61, 62, 63, 64, no_led, 77
// clang-format on
}; };
}; };
@ -107,6 +110,7 @@ class Imago: public kaleidoscope::device::ATmega32U4Keyboard<ImagoProps> {
}; };
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, R0C12, R0C13, R0C14, R0C15, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, R0C12, R0C13, R0C14, R0C15, \
R1C0, R1C1, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, R1C12, R1C13, R1C14, R1C15, \ R1C0, R1C1, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, R1C12, R1C13, R1C14, R1C15, \
@ -119,6 +123,7 @@ class Imago: public kaleidoscope::device::ATmega32U4Keyboard<ImagoProps> {
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, XXX, R2C8, R2C9, R2C10, R2C11, R2C12, R2C13, R2C14, XXX , \ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, XXX, R2C8, R2C9, R2C10, R2C11, R2C12, R2C13, R2C14, XXX , \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11, R3C12, R3C13, XXX, R3C15, \ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11, R3C12, R3C13, XXX, R3C15, \
R4C0, R4C1, R4C2, R4C3, XXX, R4C5, R4C6, R4C7, R4C8, XXX, R4C10, R4C11, R4C12, R4C13, XXX, R4C15 R4C0, R4C1, R4C2, R4C3, XXX, R4C5, R4C6, R4C7, R4C8, XXX, R4C10, R4C11, R4C12, R4C13, XXX, R4C15
// clang-format on
} // namespace keyboardio } // namespace keyboardio
} // namespace device } // namespace device

@ -30,7 +30,8 @@
#include "kaleidoscope/MatrixAddr.h" // for MatrixAddr #include "kaleidoscope/MatrixAddr.h" // for MatrixAddr
#include "kaleidoscope/macro_helpers.h" // for RESTRICT_AR... #include "kaleidoscope/macro_helpers.h" // for RESTRICT_AR...
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
struct cRGB { struct cRGB {
uint8_t b; uint8_t b;
@ -53,10 +54,12 @@ namespace keyboardio {
struct Model01LEDDriverProps : public kaleidoscope::driver::led::BaseProps { struct Model01LEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 64; static constexpr uint8_t led_count = 64;
static constexpr uint8_t key_led_map[] PROGMEM = { static constexpr uint8_t key_led_map[] PROGMEM = {
// clang-format off
3, 4, 11, 12, 19, 20, 26, 27, 36, 37, 43, 44, 51, 52, 59, 60, 3, 4, 11, 12, 19, 20, 26, 27, 36, 37, 43, 44, 51, 52, 59, 60,
2, 5, 10, 13, 18, 21, 25, 28, 35, 38, 42, 45, 50, 53, 58, 61, 2, 5, 10, 13, 18, 21, 25, 28, 35, 38, 42, 45, 50, 53, 58, 61,
1, 6, 9, 14, 17, 22, 24, 29, 34, 39, 41, 46, 49, 54, 57, 62, 1, 6, 9, 14, 17, 22, 24, 29, 34, 39, 41, 46, 49, 54, 57, 62,
0, 7, 8, 15, 16, 23, 31, 30, 33, 32, 40, 47, 48, 55, 56, 63, 0, 7, 8, 15, 16, 23, 31, 30, 33, 32, 40, 47, 48, 55, 56, 63,
// clang-format on
}; };
}; };
@ -89,6 +92,7 @@ struct Model01KeyScannerProps : public kaleidoscope::driver::keyscanner::BasePro
class Model01KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model01KeyScannerProps> { class Model01KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model01KeyScannerProps> {
private: private:
typedef Model01KeyScanner ThisType; typedef Model01KeyScanner ThisType;
public: public:
static void setup(); static void setup();
static void scanMatrix(); static void scanMatrix();
@ -143,6 +147,8 @@ EXPORT_DEVICE(kaleidoscope::device::keyboardio::Model01)
} // namespace kaleidoscope } // namespace kaleidoscope
// clang-format off
#define PER_KEY_DATA_STACKED(dflt, \ #define PER_KEY_DATA_STACKED(dflt, \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \ r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, \ r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, \

@ -82,8 +82,6 @@ uint8_t Model01Side::setKeyscanInterval(uint8_t delay) {
} }
// returns -1 on error, otherwise returns the scanner version integer // returns -1 on error, otherwise returns the scanner version integer
int Model01Side::readVersion() { int Model01Side::readVersion() {
return readRegister(TWI_CMD_VERSION); return readRegister(TWI_CMD_VERSION);
@ -113,7 +111,6 @@ uint8_t Model01Side::setLEDSPIFrequency(uint8_t frequency) {
} }
int Model01Side::readRegister(uint8_t cmd) { int Model01Side::readRegister(uint8_t cmd) {
uint8_t return_value = 0; uint8_t return_value = 0;
@ -122,7 +119,6 @@ int Model01Side::readRegister(uint8_t cmd) {
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
delayMicroseconds(15); // We may be able to drop this in the future delayMicroseconds(15); // We may be able to drop this in the future
// but will need to verify with correctly // but will need to verify with correctly
// sized pull-ups on both the left and right // sized pull-ups on both the left and right
@ -137,7 +133,6 @@ int Model01Side::readRegister(uint8_t cmd) {
} else { } else {
return -1; return -1;
} }
} }
@ -195,8 +190,7 @@ void Model01Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO, uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
pgm_read_byte(&gamma8[color.b]), pgm_read_byte(&gamma8[color.b]),
pgm_read_byte(&gamma8[color.g]), pgm_read_byte(&gamma8[color.g]),
pgm_read_byte(&gamma8[color.r]) pgm_read_byte(&gamma8[color.r])};
};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }
@ -205,10 +199,8 @@ void Model01Side::setOneLEDTo(uint8_t led, cRGB color) {
led, led,
pgm_read_byte(&gamma8[color.b]), pgm_read_byte(&gamma8[color.b]),
pgm_read_byte(&gamma8[color.g]), pgm_read_byte(&gamma8[color.g]),
pgm_read_byte(&gamma8[color.r]) pgm_read_byte(&gamma8[color.r])};
};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }
} // namespace keyboardio } // namespace keyboardio

@ -34,7 +34,8 @@ struct cRGB {
uint8_t g; uint8_t g;
uint8_t r; uint8_t r;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif #endif
#define LED_BANKS 4 #define LED_BANKS 4

@ -48,7 +48,6 @@ void Model100Hands::setup(void) {
Model100KeyScanner::enableScannerPower(); Model100KeyScanner::enableScannerPower();
Wire.begin(); Wire.begin();
Wire.setClock(400000); Wire.setClock(400000);
} }
/********* LED Driver *********/ /********* LED Driver *********/
@ -141,7 +140,6 @@ void Model100KeyScanner::disableScannerPower(void) {
} }
void Model100KeyScanner::setup() { void Model100KeyScanner::setup() {
enableScannerPower(); enableScannerPower();
delay(250); delay(250);

@ -25,7 +25,8 @@
#include <Arduino.h> #include <Arduino.h>
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
struct cRGB { struct cRGB {
uint8_t b; uint8_t b;
@ -55,10 +56,12 @@ struct Model100StorageProps: public kaleidoscope::driver::storage::GD32FlashProp
struct Model100LEDDriverProps : public kaleidoscope::driver::led::BaseProps { struct Model100LEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 64; static constexpr uint8_t led_count = 64;
static constexpr uint8_t key_led_map[] PROGMEM = { static constexpr uint8_t key_led_map[] PROGMEM = {
// clang-format off
3, 4, 11, 12, 19, 20, 26, 27, 36, 37, 43, 44, 51, 52, 59, 60, 3, 4, 11, 12, 19, 20, 26, 27, 36, 37, 43, 44, 51, 52, 59, 60,
2, 5, 10, 13, 18, 21, 25, 28, 35, 38, 42, 45, 50, 53, 58, 61, 2, 5, 10, 13, 18, 21, 25, 28, 35, 38, 42, 45, 50, 53, 58, 61,
1, 6, 9, 14, 17, 22, 24, 29, 34, 39, 41, 46, 49, 54, 57, 62, 1, 6, 9, 14, 17, 22, 24, 29, 34, 39, 41, 46, 49, 54, 57, 62,
0, 7, 8, 15, 16, 23, 31, 30, 33, 32, 40, 47, 48, 55, 56, 63, 0, 7, 8, 15, 16, 23, 31, 30, 33, 32, 40, 47, 48, 55, 56, 63,
// clang-format on
}; };
}; };
@ -90,6 +93,7 @@ struct Model100KeyScannerProps : public kaleidoscope::driver::keyscanner::BasePr
class Model100KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model100KeyScannerProps> { class Model100KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model100KeyScannerProps> {
private: private:
typedef Model100KeyScanner ThisType; typedef Model100KeyScanner ThisType;
public: public:
static void setup(); static void setup();
static void scanMatrix(); static void scanMatrix();
@ -165,6 +169,8 @@ EXPORT_DEVICE(kaleidoscope::device::keyboardio::Model100)
} // namespace kaleidoscope } // namespace kaleidoscope
// clang-format off
#define PER_KEY_DATA_STACKED(dflt, \ #define PER_KEY_DATA_STACKED(dflt, \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \ r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, \ r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, \

@ -75,8 +75,6 @@ uint8_t Model100Side::setKeyscanInterval(uint8_t delay) {
} }
// returns -1 on error, otherwise returns the scanner version integer // returns -1 on error, otherwise returns the scanner version integer
int Model100Side::readVersion() { int Model100Side::readVersion() {
return readRegister(TWI_CMD_VERSION); return readRegister(TWI_CMD_VERSION);
@ -134,7 +132,6 @@ bool Model100Side::isDeviceAvailable() {
// we've decremented the counter, but it's not time to probe for the device yet. // we've decremented the counter, but it's not time to probe for the device yet.
return false; return false;
} }
} }
void Model100Side::markDeviceUnavailable() { void Model100Side::markDeviceUnavailable() {
@ -180,7 +177,6 @@ int Model100Side::readRegister(uint8_t cmd) {
markDeviceUnavailable(); markDeviceUnavailable();
return -1; return -1;
} }
} }
@ -245,8 +241,7 @@ void Model100Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO, uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
color.b, color.b,
color.g, color.g,
color.r color.r};
};
uint8_t result = writeData(data, ELEMENTS(data)); uint8_t result = writeData(data, ELEMENTS(data));
} }
@ -255,10 +250,8 @@ void Model100Side::setOneLEDTo(uint8_t led, cRGB color) {
led, led,
color.b, color.b,
color.g, color.g,
color.r color.r};
};
uint8_t result = writeData(data, ELEMENTS(data)); uint8_t result = writeData(data, ELEMENTS(data));
} }
} // namespace keyboardio } // namespace keyboardio

@ -34,7 +34,8 @@ struct cRGB {
uint8_t g; uint8_t g;
uint8_t r; uint8_t r;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif #endif
#define LED_BANKS 4 #define LED_BANKS 4

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -56,6 +56,7 @@ class Planck;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
@ -66,6 +67,7 @@ class Planck;
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace olkb } // namespace olkb
} // namespace device } // namespace device

@ -52,7 +52,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -68,6 +68,8 @@ class Splitography: public kaleidoscope::device::ATmega32U4Keyboard<Splitography
class Splitography; class Splitography;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 \ r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 \
,r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 ,r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11 \ ,r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 ,r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11 \
@ -96,6 +98,8 @@ class Splitography;
r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 ,r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11, \ r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 ,r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11, \
dflt ,dflt ,dflt ,dflt ,r3c4 ,r3c5 ,r3c6 ,r3c7 ,dflt ,dflt ,dflt ,dflt dflt ,dflt ,dflt ,dflt ,r3c4 ,r3c5 ,r3c6 ,r3c7 ,dflt ,dflt ,dflt ,dflt
// clang-format on
} // namespace softhruf } // namespace softhruf
} // namespace device } // namespace device

@ -55,7 +55,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -85,6 +85,8 @@ class Atreus: public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
class Atreus; class Atreus;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C7, R1C8, R1C9, R1C10, R1C11, \ R1C0, R1C1, R1C2, R1C3, R1C4, R1C7, R1C8, R1C9, R1C10, R1C11, \
@ -113,6 +115,8 @@ class Atreus;
R2C0, R2C1, R2C2, R2C3, R2C4, R3C5, R2C7, R2C8, R2C9, R2C10, R2C11, \ R2C0, R2C1, R2C2, R2C3, R2C4, R3C5, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace technomancy } // namespace technomancy
} // namespace device } // namespace device

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -58,12 +58,15 @@ class ButterStick;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9 \ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9 \
) \ ) \
R0C9, R0C8, R0C7, R0C6, R0C5, R0C4, R0C3, R0C2, R0C1, R0C0, \ R0C9, R0C8, R0C7, R0C6, R0C5, R0C4, R0C3, R0C2, R0C1, R0C0, \
R1C9, R1C8, R1C7, R1C6, R1C5, R1C4, R1C3, R1C2, R1C1, R1C0 R1C9, R1C8, R1C7, R1C6, R1C5, R1C4, R1C3, R1C2, R1C1, R1C0
// clang-format on
} // namespace gheavy } // namespace gheavy
} // namespace device } // namespace device

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -58,11 +58,14 @@ class FaunchPad;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7 \ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7 \
) \ ) \
R0C0, R0C1, R0C2, R0C3, \ R0C0, R0C1, R0C2, R0C3, \
R0C4, R0C5, R0C6, R0C7 R0C4, R0C5, R0C6, R0C7
// clang-format on
} // namespace gheavy } // namespace gheavy
} // namespace device } // namespace device

@ -75,11 +75,9 @@ void HardwareTestMode::testLeds(void) {
setLeds(blue); setLeds(blue);
setLeds(green); setLeds(green);
setLeds(red); setLeds(red);
} }
void HardwareTestMode::testMatrix() { void HardwareTestMode::testMatrix() {
// Reset bad keys from previous tests. // Reset bad keys from previous tests.
chatter_data state[Runtime.device().numKeys()] = {{0, 0, 0}}; chatter_data state[Runtime.device().numKeys()] = {{0, 0, 0}};

@ -26,7 +26,6 @@ namespace plugin {
class HardwareTestMode : public kaleidoscope::Plugin { class HardwareTestMode : public kaleidoscope::Plugin {
public: public:
typedef struct { typedef struct {
uint8_t bad : 1, uint8_t bad : 1,
tested : 1, tested : 1,
@ -38,6 +37,7 @@ class HardwareTestMode : public kaleidoscope::Plugin {
static void runTests(); static void runTests();
static void setActionKey(uint8_t key); static void setActionKey(uint8_t key);
private: private:
static void testLeds(); static void testLeds();
static void testMatrix(); static void testMatrix();

@ -47,8 +47,7 @@ Heatmap::TransientLEDMode::TransientLEDMode(const Heatmap *parent)
// max of heatmap_ (we divide by it so we start at 1) // max of heatmap_ (we divide by it so we start at 1)
highest_(1), highest_(1),
// last heatmap computation time // last heatmap computation time
last_heatmap_comp_time_(Runtime.millisAtCycleStart()) last_heatmap_comp_time_(Runtime.millisAtCycleStart()) {}
{}
cRGB Heatmap::TransientLEDMode::computeColor(float v) { cRGB Heatmap::TransientLEDMode::computeColor(float v) {
// compute the color corresponding to a value between 0 and 1 // compute the color corresponding to a value between 0 and 1

@ -48,7 +48,6 @@ class Heatmap : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -60,11 +59,9 @@ class Heatmap : public Plugin,
EventHandlerResult beforeEachCycle(); EventHandlerResult beforeEachCycle();
protected: protected:
void update() final; void update() final;
private: private:
uint16_t heatmap_[Runtime.device().numKeys()]; uint16_t heatmap_[Runtime.device().numKeys()];
uint16_t highest_; uint16_t highest_;
uint16_t last_heatmap_comp_time_; uint16_t last_heatmap_comp_time_;

@ -51,6 +51,7 @@ class PersistentIdleLEDs : public IdleLEDs {
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
static void setIdleTimeoutSeconds(uint32_t new_limit); static void setIdleTimeoutSeconds(uint32_t new_limit);
private: private:
static uint16_t settings_base_; static uint16_t settings_base_;
}; };

@ -34,8 +34,7 @@ const cRGB *LEDActiveLayerColorEffect::colormap_;
LEDActiveLayerColorEffect::TransientLEDMode::TransientLEDMode( LEDActiveLayerColorEffect::TransientLEDMode::TransientLEDMode(
const LEDActiveLayerColorEffect *parent) const LEDActiveLayerColorEffect *parent)
: parent_(parent), : parent_(parent),
active_color_{0, 0, 0} active_color_{0, 0, 0} {}
{}
void LEDActiveLayerColorEffect::setColormap(const cRGB colormap[]) { void LEDActiveLayerColorEffect::setColormap(const cRGB colormap[]) {
colormap_ = colormap; colormap_ = colormap;

@ -40,7 +40,6 @@ class LEDActiveLayerColorEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -48,12 +47,10 @@ class LEDActiveLayerColorEffect : public Plugin,
explicit TransientLEDMode(const LEDActiveLayerColorEffect *parent); explicit TransientLEDMode(const LEDActiveLayerColorEffect *parent);
protected: protected:
void onActivate(void) final; void onActivate(void) final;
void refreshAt(KeyAddr key_addr) final; void refreshAt(KeyAddr key_addr) final;
private: private:
const LEDActiveLayerColorEffect *parent_; const LEDActiveLayerColorEffect *parent_;
cRGB active_color_; cRGB active_color_;
@ -64,7 +61,6 @@ class LEDActiveLayerColorEffect : public Plugin,
}; };
private: private:
static const cRGB *colormap_; static const cRGB *colormap_;
}; };

@ -67,8 +67,7 @@ static const uint16_t alphabet[] PROGMEM = {
ALPHASQUARE_SYMBOL_7, ALPHASQUARE_SYMBOL_7,
ALPHASQUARE_SYMBOL_8, ALPHASQUARE_SYMBOL_8,
ALPHASQUARE_SYMBOL_9, ALPHASQUARE_SYMBOL_9,
ALPHASQUARE_SYMBOL_0 ALPHASQUARE_SYMBOL_0};
};
cRGB AlphaSquare::color = {0x80, 0x80, 0x80}; cRGB AlphaSquare::color = {0x80, 0x80, 0x80};

@ -25,6 +25,7 @@
struct cRGB; struct cRGB;
// clang-format off
#define SYM4x4( \ #define SYM4x4( \
p00, p01, p02, p03, \ p00, p01, p02, p03, \
p10, p11, p12, p13, \ p10, p11, p12, p13, \
@ -35,12 +36,12 @@ struct cRGB;
p10 << 4 | p11 << 5 | p12 << 6 | p13 << 7 | \ p10 << 4 | p11 << 5 | p12 << 6 | p13 << 7 | \
p20 << 8 | p21 << 9 | p22 << 10 | p23 << 11 | \ p20 << 8 | p21 << 9 | p22 << 10 | p23 << 11 | \
p30 << 12 | p31 << 13 | p32 << 14 | p33 << 15 ) p30 << 12 | p31 << 13 | p32 << 14 | p33 << 15 )
// clang-format on
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
class AlphaSquare : public kaleidoscope::Plugin { class AlphaSquare : public kaleidoscope::Plugin {
public: public:
AlphaSquare(void) {} AlphaSquare(void) {}
static void display(Key key, KeyAddr key_addr, cRGB key_color); static void display(Key key, KeyAddr key_addr, cRGB key_color);

@ -37,8 +37,7 @@ uint16_t AlphaSquareEffect::length = 1000;
AlphaSquareEffect::TransientLEDMode::TransientLEDMode(AlphaSquareEffect * /*parent*/) // NOLINT(readability/casting) AlphaSquareEffect::TransientLEDMode::TransientLEDMode(AlphaSquareEffect * /*parent*/) // NOLINT(readability/casting)
: last_key_left_(Key_NoKey), : last_key_left_(Key_NoKey),
last_key_right_(Key_NoKey) last_key_right_(Key_NoKey) {}
{}
void AlphaSquareEffect::TransientLEDMode::update(void) { void AlphaSquareEffect::TransientLEDMode::update(void) {
if (!Runtime.has_leds) if (!Runtime.has_leds)

@ -14,6 +14,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// clang-format off
#pragma once #pragma once

@ -14,6 +14,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// clang-format off
#pragma once #pragma once
#ifndef KALEIDOSCOPE_LED_FONT #ifndef KALEIDOSCOPE_LED_FONT

@ -26,11 +26,14 @@ namespace plugin {
namespace alpha_square { namespace alpha_square {
namespace symbols { namespace symbols {
// clang-format off
/* λ */ /* λ */
static constexpr uint16_t Lambda = SYM4x4(1, 0, 0, 0, static constexpr uint16_t Lambda = SYM4x4(1, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0,
0, 1, 1, 0, 0, 1, 1, 0,
1, 0, 0, 1); 1, 0, 0, 1);
// clang-format on
} // namespace symbols } // namespace symbols
} // namespace alpha_square } // namespace alpha_square

@ -44,7 +44,8 @@ class LEDPaletteTheme : public kaleidoscope::Plugin {
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
EventHandlerResult themeFocusEvent(const char *command, EventHandlerResult themeFocusEvent(const char *command,
const char *expected_command, const char *expected_command,
uint16_t theme_base, uint8_t max_themes); uint16_t theme_base,
uint8_t max_themes);
private: private:
static uint16_t palette_base_; static uint16_t palette_base_;

@ -34,14 +34,12 @@ namespace plugin {
StalkerEffect::ColorComputer *StalkerEffect::variant; StalkerEffect::ColorComputer *StalkerEffect::variant;
uint16_t StalkerEffect::step_length = 50; uint16_t StalkerEffect::step_length = 50;
cRGB StalkerEffect::inactive_color = (cRGB){ cRGB StalkerEffect::inactive_color = (cRGB){
0, 0, 0 0, 0, 0};
};
StalkerEffect::TransientLEDMode::TransientLEDMode(const StalkerEffect *parent) StalkerEffect::TransientLEDMode::TransientLEDMode(const StalkerEffect *parent)
: parent_(parent), : parent_(parent),
step_start_time_(0), step_start_time_(0),
map_{} map_{} {}
{}
EventHandlerResult StalkerEffect::onKeyEvent(KeyEvent &event) { EventHandlerResult StalkerEffect::onKeyEvent(KeyEvent &event) {
if (!Runtime.has_leds) if (!Runtime.has_leds)

@ -53,7 +53,6 @@ class StalkerEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -61,11 +60,9 @@ class StalkerEffect : public Plugin,
explicit TransientLEDMode(const StalkerEffect *parent); explicit TransientLEDMode(const StalkerEffect *parent);
protected: protected:
void update() final; void update() final;
private: private:
const StalkerEffect *parent_; const StalkerEffect *parent_;
uint16_t step_start_time_; uint16_t step_start_time_;
@ -80,9 +77,11 @@ namespace stalker {
class Haunt : public StalkerEffect::ColorComputer { class Haunt : public StalkerEffect::ColorComputer {
public: public:
explicit Haunt(const cRGB highlight_color); explicit Haunt(const cRGB highlight_color);
Haunt(void) : Haunt(CRGB(0x40, 0x80, 0x80)) {} Haunt(void)
: Haunt(CRGB(0x40, 0x80, 0x80)) {}
cRGB compute(uint8_t *step) final; cRGB compute(uint8_t *step) final;
private: private:
static cRGB highlight_color_; static cRGB highlight_color_;
}; };

@ -44,17 +44,18 @@ int16_t WavepoolEffect::ripple_hue = WavepoolEffect::rainbow_hue; // automatic h
// map native keyboard coordinates (16x4) into geometric space (14x5) // map native keyboard coordinates (16x4) into geometric space (14x5)
PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[Runtime.device().numKeys()] = { PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[Runtime.device().numKeys()] = {
// clang-format off
0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 59, 66, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27, 14, 15, 16, 17, 18, 19, 34, 60, 65, 35, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41, 28, 29, 30, 31, 32, 33, 48, 61, 64, 49, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 58, 62, 63, 67, 50, 51, 52, 53, 54, 55, 42, 43, 44, 45, 46, 47, 58, 62, 63, 67, 50, 51, 52, 53, 54, 55,
// clang-format on
}; };
WavepoolEffect::TransientLEDMode::TransientLEDMode(const WavepoolEffect *parent) WavepoolEffect::TransientLEDMode::TransientLEDMode(const WavepoolEffect *parent)
: frames_since_event_(0), : frames_since_event_(0),
surface_{}, surface_{},
page_(0) page_(0) {}
{}
EventHandlerResult WavepoolEffect::onKeyEvent(KeyEvent &event) { EventHandlerResult WavepoolEffect::onKeyEvent(KeyEvent &event) {
if (!event.addr.isValid()) if (!event.addr.isValid())
@ -135,9 +136,7 @@ void WavepoolEffect::TransientLEDMode::update(void) {
raindrop(prev_x, prev_y, oldpg); raindrop(prev_x, prev_y, oldpg);
prev_x = prev_y = -1; prev_x = prev_y = -1;
} }
if (frames_since_event_ if (frames_since_event_ >= (frames_till_next_drop + (idle_timeout / MS_PER_FRAME))) {
>= (frames_till_next_drop
+ (idle_timeout / MS_PER_FRAME))) {
frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP); frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP);
frames_since_event_ = idle_timeout / MS_PER_FRAME; frames_since_event_ = idle_timeout / MS_PER_FRAME;
@ -162,10 +161,13 @@ void WavepoolEffect::TransientLEDMode::update(void) {
uint8_t offset = (y * WP_WID) + x; uint8_t offset = (y * WP_WID) + x;
int16_t value; int16_t value;
int8_t offsets[] = { -WP_WID, WP_WID, int8_t offsets[] = {
// clang-format off
-WP_WID, WP_WID,
-1, 1, -1, 1,
-WP_WID - 1, -WP_WID + 1, -WP_WID - 1, -WP_WID + 1,
WP_WID - 1, WP_WID + 1 WP_WID - 1, WP_WID + 1
// clang-format on
}; };
// don't wrap around edges or go out of bounds // don't wrap around edges or go out of bounds
if (y == 0) { if (y == 0) {
@ -234,7 +236,6 @@ void WavepoolEffect::TransientLEDMode::update(void) {
// swap pages every frame // swap pages every frame
page_ ^= 1; page_ ^= 1;
#endif #endif
} }
} // namespace plugin } // namespace plugin

@ -55,7 +55,6 @@ class WavepoolEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -65,11 +64,9 @@ class WavepoolEffect : public Plugin,
EventHandlerResult onKeyEvent(KeyEvent &event); EventHandlerResult onKeyEvent(KeyEvent &event);
protected: protected:
void update() final; void update() final;
private: private:
uint8_t frames_since_event_; uint8_t frames_since_event_;
int8_t surface_[2][WP_WID * WP_HGT]; int8_t surface_[2][WP_WID * WP_HGT];
uint8_t page_; uint8_t page_;

@ -47,8 +47,7 @@ const uint8_t BootAnimationEffect::greeting_[11] PROGMEM = {
Key_D.getKeyCode(), Key_D.getKeyCode(),
Key_Period.getKeyCode(), Key_Period.getKeyCode(),
Key_I.getKeyCode(), Key_I.getKeyCode(),
Key_O.getKeyCode() Key_O.getKeyCode()};
};
EventHandlerResult BootAnimationEffect::onSetup() { EventHandlerResult BootAnimationEffect::onSetup() {
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -36,7 +36,6 @@ class LEDBreatheEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -48,7 +47,6 @@ class LEDBreatheEffect : public Plugin,
void update(void) final; void update(void) final;
private: private:
const LEDBreatheEffect *parent_; const LEDBreatheEffect *parent_;
static constexpr uint8_t update_interval_ = 50; static constexpr uint8_t update_interval_ = 50;

@ -47,7 +47,6 @@ class LEDChaseEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -56,11 +55,9 @@ class LEDChaseEffect : public Plugin,
: parent_(parent), last_update_(Runtime.millisAtCycleStart()) {} : parent_(parent), last_update_(Runtime.millisAtCycleStart()) {}
protected: protected:
void update() final; void update() final;
private: private:
const LEDChaseEffect *parent_; const LEDChaseEffect *parent_;
uint8_t pos_ = uint8_t(0); uint8_t pos_ = uint8_t(0);

@ -42,7 +42,6 @@ class LEDRainbowEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -53,7 +52,6 @@ class LEDRainbowEffect : public Plugin,
void update() final; void update() final;
private: private:
const LEDRainbowEffect *parent_; const LEDRainbowEffect *parent_;
uint16_t rainbow_hue = 0; // stores 0 to 614 uint16_t rainbow_hue = 0; // stores 0 to 614
@ -87,7 +85,6 @@ class LEDRainbowWaveEffect : public Plugin, public LEDModeInterface {
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -98,7 +95,6 @@ class LEDRainbowWaveEffect : public Plugin, public LEDModeInterface {
void update() final; void update() final;
private: private:
const LEDRainbowWaveEffect *parent_; const LEDRainbowWaveEffect *parent_;
uint16_t rainbow_hue = 0; // stores 0 to 614 uint16_t rainbow_hue = 0; // stores 0 to 614

@ -28,16 +28,13 @@ namespace plugin {
class LEDSolidColor : public Plugin, class LEDSolidColor : public Plugin,
public LEDModeInterface { public LEDModeInterface {
public: public:
LEDSolidColor(uint8_t r, uint8_t g, uint8_t b) LEDSolidColor(uint8_t r, uint8_t g, uint8_t b)
: r_(r), g_(g), b_(b) : r_(r), g_(g), b_(b) {}
{}
// This class' instance has dynamic lifetime // This class' instance has dynamic lifetime
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -50,12 +47,10 @@ class LEDSolidColor : public Plugin,
void refreshAt(KeyAddr key_addr) final; void refreshAt(KeyAddr key_addr) final;
private: private:
const LEDSolidColor *parent_; const LEDSolidColor *parent_;
}; };
private: private:
uint8_t r_, g_, b_; uint8_t r_, g_, b_;
}; };

@ -28,13 +28,13 @@ class TriColor : public Plugin,
public LEDModeInterface { public LEDModeInterface {
public: public:
TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color); TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color);
TriColor(cRGB base_color, cRGB mod_color) : TriColor(base_color, mod_color, mod_color) {} TriColor(cRGB base_color, cRGB mod_color)
: TriColor(base_color, mod_color, mod_color) {}
// This class' instance has dynamic lifetime // This class' instance has dynamic lifetime
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -43,11 +43,9 @@ class TriColor : public Plugin,
: parent_(parent) {} : parent_(parent) {}
protected: protected:
void update(void) final; void update(void) final;
private: private:
const TriColor *parent_; const TriColor *parent_;
}; };

@ -75,8 +75,7 @@ int8_t Leader::lookup(void) {
if (!match) if (!match)
continue; continue;
seq_key seq_key = dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
= dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
if (seq_key == Key_NoKey) { if (seq_key == Key_NoKey) {
return seq_index; return seq_index;
} else { } else {

@ -46,8 +46,12 @@
#define LEAD(n) kaleidoscope::plugin::LeaderKey(n) #define LEAD(n) kaleidoscope::plugin::LeaderKey(n)
#define LEADER_SEQ(...) { __VA_ARGS__, Key_NoKey } #define LEADER_SEQ(...) \
#define LEADER_DICT(...) { __VA_ARGS__, {{Key_NoKey}, NULL} } { __VA_ARGS__, Key_NoKey }
#define LEADER_DICT(...) \
{ \
__VA_ARGS__, { {Key_NoKey}, NULL } \
}
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {

@ -32,7 +32,8 @@
// ============================================================================= // =============================================================================
// Default `macroAction()` function definitions // Default `macroAction()` function definitions
__attribute__((weak)) __attribute__((weak))
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { const macro_t *
macroAction(uint8_t macro_id, KeyEvent &event) {
return MACRO_NONE; return MACRO_NONE;
} }

@ -42,7 +42,6 @@ namespace plugin {
class Macros : public kaleidoscope::Plugin { class Macros : public kaleidoscope::Plugin {
public: public:
/// Send a key press event from a Macro /// Send a key press event from a Macro
/// ///
/// Generates a new `KeyEvent` and calls `Runtime.handleKeyEvent()` with the /// Generates a new `KeyEvent` and calls `Runtime.handleKeyEvent()` with the
@ -105,7 +104,6 @@ class Macros : public kaleidoscope::Plugin {
return true; return true;
return false; return false;
} }
}; };
} // namespace plugin } // namespace plugin

@ -49,8 +49,7 @@ typedef uint8_t macro_t;
{ \ { \
static const macro_t __m[] PROGMEM = { \ static const macro_t __m[] PROGMEM = { \
__VA_ARGS__, \ __VA_ARGS__, \
MACRO_ACTION_END \ MACRO_ACTION_END}; \
}; \
&__m[0]; \ &__m[0]; \
}) })

@ -69,7 +69,6 @@ class MouseKeys : public kaleidoscope::Plugin {
void sendMouseWarpReport(const KeyEvent &event) const; void sendMouseWarpReport(const KeyEvent &event) const;
void sendMouseMoveReport(); void sendMouseMoveReport();
void sendMouseWheelReport(); void sendMouseWheelReport();
}; };
} // namespace plugin } // namespace plugin

@ -122,14 +122,18 @@ void MouseWrapper::move(int8_t x, int8_t y) {
if (x != 0) { if (x != 0) {
moveX = remainderX + (x * acceleration(accel_step)); moveX = remainderX + (x * acceleration(accel_step));
if (moveX > effectiveSpeedLimit) moveX = effectiveSpeedLimit; if (moveX > effectiveSpeedLimit)
else if (moveX < -effectiveSpeedLimit) moveX = -effectiveSpeedLimit; moveX = effectiveSpeedLimit;
else if (moveX < -effectiveSpeedLimit)
moveX = -effectiveSpeedLimit;
} }
if (y != 0) { if (y != 0) {
moveY = remainderY + (y * acceleration(accel_step)); moveY = remainderY + (y * acceleration(accel_step));
if (moveY > effectiveSpeedLimit) moveY = effectiveSpeedLimit; if (moveY > effectiveSpeedLimit)
else if (moveY < -effectiveSpeedLimit) moveY = -effectiveSpeedLimit; moveY = effectiveSpeedLimit;
else if (moveY < -effectiveSpeedLimit)
moveY = -effectiveSpeedLimit;
} }
endWarping(); endWarping();

@ -39,7 +39,6 @@ class NumPad : public kaleidoscope::Plugin {
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();
private: private:
void setKeyboardLEDColors(void); void setKeyboardLEDColors(void);
static KeyAddr numpadLayerToggleKeyAddr; static KeyAddr numpadLayerToggleKeyAddr;

@ -94,8 +94,7 @@ bool OneShot::isSticky() const {
// could potentially use three different color values for the three // could potentially use three different color values for the three
// states (sticky | active && !sticky | pressed && !active). // states (sticky | active && !sticky | pressed && !active).
__attribute__((weak)) __attribute__((weak)) bool OneShot::isStickable(Key key) const {
bool OneShot::isStickable(Key key) const {
return isStickableDefault(key); return isStickableDefault(key);
} }
@ -274,7 +273,6 @@ EventHandlerResult OneShot::onKeyEvent(KeyEvent& event) {
// event. This is handled in the `beforeReportingState()` hook below. // event. This is handled in the `beforeReportingState()` hook below.
return EventHandlerResult::ABORT; return EventHandlerResult::ABORT;
} }
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -379,8 +377,7 @@ void OneShot::holdKey(KeyAddr key_addr) const {
Runtime.handleKeyEvent(event); Runtime.handleKeyEvent(event);
} }
__attribute__((always_inline)) inline __attribute__((always_inline)) inline void OneShot::releaseKey(KeyAddr key_addr) {
void OneShot::releaseKey(KeyAddr key_addr) {
glue_addrs_.clear(key_addr); glue_addrs_.clear(key_addr);
temp_addrs_.clear(key_addr); temp_addrs_.clear(key_addr);

@ -191,7 +191,6 @@ class OneShot : public kaleidoscope::Plugin {
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();
private: private:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Constants // Constants
static constexpr uint8_t oneshot_key_count = 16; static constexpr uint8_t oneshot_key_count = 16;

@ -42,7 +42,6 @@ class OneShotMetaKeys : public kaleidoscope::Plugin {
private: private:
static bool isMetaStickyActive(); static bool isMetaStickyActive();
}; };
} // namespace plugin } // namespace plugin

@ -32,6 +32,7 @@ class PersistentLEDMode: public kaleidoscope::Plugin {
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onLEDModeChange(); EventHandlerResult onLEDModeChange();
private: private:
static uint16_t settings_base_; static uint16_t settings_base_;
static uint8_t cached_mode_index_; static uint8_t cached_mode_index_;

@ -66,7 +66,8 @@ EventHandlerResult Qukeys::onKeyswitchEvent(KeyEvent &event) {
// If we can't trivially ignore the event, just add it to the queue. // If we can't trivially ignore the event, just add it to the queue.
event_queue_.append(event); event_queue_.append(event);
// In order to prevent overflowing the queue, process it now. // In order to prevent overflowing the queue, process it now.
while (processQueue()); while (processQueue())
;
// Any event that gets added to the queue gets re-processed later, so we // Any event that gets added to the queue gets re-processed later, so we
// need to abort processing now. // need to abort processing now.
return EventHandlerResult::ABORT; return EventHandlerResult::ABORT;
@ -97,13 +98,13 @@ EventHandlerResult Qukeys::afterEachCycle() {
if (Runtime.hasTimeExpired(event_queue_.timestamp(0), hold_timeout_)) { if (Runtime.hasTimeExpired(event_queue_.timestamp(0), hold_timeout_)) {
// If it's a SpaceCadet-type key, it takes on its primary value, otherwise // If it's a SpaceCadet-type key, it takes on its primary value, otherwise
// it takes on its secondary value. // it takes on its secondary value.
Key event_key = isModifierKey(queue_head_.primary_key) ? Key event_key = isModifierKey(queue_head_.primary_key) ? queue_head_.primary_key : queue_head_.alternate_key;
queue_head_.primary_key : queue_head_.alternate_key;
flushEvent(event_key); flushEvent(event_key);
} }
// Process as many events as we can from the queue. // Process as many events as we can from the queue.
while (processQueue()); while (processQueue())
;
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
@ -205,8 +206,7 @@ bool Qukeys::processQueue() {
// flush it now. Its state depends on whether or not it's a // flush it now. Its state depends on whether or not it's a
// SpaceCadet-type key. // SpaceCadet-type key.
if (next_keypress_index == 0 || overlap_threshold_ == 0) { if (next_keypress_index == 0 || overlap_threshold_ == 0) {
Key event_key = qukey_is_spacecadet ? Key event_key = qukey_is_spacecadet ? queue_head_.alternate_key : queue_head_.primary_key;
queue_head_.alternate_key : queue_head_.primary_key;
// A qukey just got released in primary state; this might turn out to be // A qukey just got released in primary state; this might turn out to be
// the beginning of a tap-repeat sequence, so we set the tap-repeat // the beginning of a tap-repeat sequence, so we set the tap-repeat
// address and start time to the time of the initial press event before // address and start time to the time of the initial press event before

@ -66,13 +66,11 @@ struct Qukey {
// This is the constructor that should be used when creating a Qukey object in // This is the constructor that should be used when creating a Qukey object in
// the PROGMEM array that will be used by Qukeys (i.e. in the `QUKEYS()` // the PROGMEM array that will be used by Qukeys (i.e. in the `QUKEYS()`
// macro). // macro).
constexpr constexpr Qukey(int8_t layer, KeyAddr k, Key alternate_key)
Qukey(int8_t layer, KeyAddr k, Key alternate_key)
: layer(layer), addr(k), alternate_key(alternate_key) {} : layer(layer), addr(k), alternate_key(alternate_key) {}
// This constructor is here so that we can create an empty Qukey object in RAM // This constructor is here so that we can create an empty Qukey object in RAM
// into which we can copy the values from a PROGMEM Qukey object. // into which we can copy the values from a PROGMEM Qukey object.
Qukey() = default; Qukey() = default;
}; };
@ -239,9 +237,9 @@ extern kaleidoscope::plugin::Qukeys Qukeys;
// guarantee that the count is set correctly. This is considerably less // guarantee that the count is set correctly. This is considerably less
// important than it used to be, with the `configureQukeys()` function taking // important than it used to be, with the `configureQukeys()` function taking
// care of guaranteeing the correct count setting. // care of guaranteeing the correct count setting.
#define QUKEYS(qukey_defs...) { \ #define QUKEYS(qukey_defs...) \
{ \
static kaleidoscope::plugin::Qukey const qk_table[] PROGMEM = { \ static kaleidoscope::plugin::Qukey const qk_table[] PROGMEM = { \
qukey_defs \ qukey_defs}; \
}; \
Qukeys.configureQukeys(qk_table); \ Qukeys.configureQukeys(qk_table); \
} }

@ -80,8 +80,7 @@ SpaceCadet::SpaceCadet() {
{Key_LeftControl, Key_LeftBracket, 250}, {Key_LeftControl, Key_LeftBracket, 250},
{Key_RightControl, Key_RightBracket, 250}, {Key_RightControl, Key_RightBracket, 250},
*/ */
SPACECADET_MAP_END SPACECADET_MAP_END};
};
map = initialmap; map = initialmap;
} }

@ -29,7 +29,8 @@
#include "kaleidoscope/plugin.h" // for Plugin #include "kaleidoscope/plugin.h" // for Plugin
#ifndef SPACECADET_MAP_END #ifndef SPACECADET_MAP_END
#define SPACECADET_MAP_END (kaleidoscope::plugin::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 } #define SPACECADET_MAP_END \
(kaleidoscope::plugin::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 }
#endif #endif
constexpr Key Key_SpaceCadetEnable = Key(kaleidoscope::ranges::SC_FIRST); constexpr Key Key_SpaceCadetEnable = Key(kaleidoscope::ranges::SC_FIRST);

@ -170,8 +170,7 @@ EventHandlerResult TapDance::afterEachCycle() {
} // namespace plugin } // namespace plugin
} // namespace kaleidoscope } // namespace kaleidoscope
__attribute__((weak)) void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, __attribute__((weak)) void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
} }
kaleidoscope::plugin::TapDance TapDance; kaleidoscope::plugin::TapDance TapDance;

@ -33,8 +33,7 @@
#define tapDanceActionKeys(tap_count, tap_dance_action, ...) ({ \ #define tapDanceActionKeys(tap_count, tap_dance_action, ...) ({ \
static const Key __k[] PROGMEM = {__VA_ARGS__}; \ static const Key __k[] PROGMEM = {__VA_ARGS__}; \
TapDance.actionKeys(tap_count, tap_dance_action, \ TapDance.actionKeys(tap_count, tap_dance_action, sizeof(__k) / sizeof(Key), &__k[0]); \
sizeof (__k) / sizeof (Key), &__k[0]); \
}) })
namespace kaleidoscope { namespace kaleidoscope {
@ -82,13 +81,11 @@ class TapDance : public kaleidoscope::Plugin {
static uint8_t tap_count_; static uint8_t tap_count_;
void flushQueue(KeyAddr ignored_addr = KeyAddr::none()); void flushQueue(KeyAddr ignored_addr = KeyAddr::none());
}; };
} // namespace plugin } // namespace plugin
} // namespace kaleidoscope } // namespace kaleidoscope
void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, kaleidoscope::plugin::TapDance::ActionType tap_dance_action);
kaleidoscope::plugin::TapDance::ActionType tap_dance_action);
extern kaleidoscope::plugin::TapDance TapDance; extern kaleidoscope::plugin::TapDance TapDance;

@ -37,8 +37,7 @@ TypingBreaks::settings_t TypingBreaks::settings = {
.lock_time_out = 2700, // 45m .lock_time_out = 2700, // 45m
.lock_length = 300, // 5m .lock_length = 300, // 5m
.left_hand_max_keys = 0, .left_hand_max_keys = 0,
.right_hand_max_keys = 0 .right_hand_max_keys = 0};
};
bool TypingBreaks::keyboard_locked_{false}; bool TypingBreaks::keyboard_locked_{false};
uint32_t TypingBreaks::session_start_time_; uint32_t TypingBreaks::session_start_time_;

@ -48,6 +48,7 @@ class Unicode : public kaleidoscope::Plugin {
static Key getLinuxKey() { static Key getLinuxKey() {
return linux_key_; return linux_key_;
} }
private: private:
static Key linux_key_; static Key linux_key_;
static uint8_t input_delay_; static uint8_t input_delay_;

@ -31,6 +31,7 @@ class WinKeyToggle: public kaleidoscope::Plugin {
void toggle() { void toggle() {
enabled_ = !enabled_; enabled_ = !enabled_;
} }
private: private:
static bool enabled_; static bool enabled_;
}; };

@ -53,18 +53,15 @@ void setup();
struct { \ struct { \
static_assert(CONVERT_TO_KEY(KEY) != kaleidoscope::bad_keymap_key, \ static_assert(CONVERT_TO_KEY(KEY) != kaleidoscope::bad_keymap_key, \
"Bad key definition: \'" #KEY "\'"); \ "Bad key definition: \'" #KEY "\'"); \
} \ }){}, \
){}, \ CONVERT_TO_KEY(KEY))
CONVERT_TO_KEY(KEY) \
)
#ifdef PER_KEY_DATA_STACKED #ifdef PER_KEY_DATA_STACKED
#define KEYMAP_STACKED(...) \ #define KEYMAP_STACKED(...) \
{ \ { \
MAP_LIST( \ MAP_LIST( \
CONVERT_AND_CHECK_KEY, \ CONVERT_AND_CHECK_KEY, \
PER_KEY_DATA_STACKED(XXX, __VA_ARGS__) \ PER_KEY_DATA_STACKED(XXX, __VA_ARGS__)) \
) \
} }
#endif #endif
@ -74,8 +71,7 @@ void setup();
{ \ { \
MAP_LIST( \ MAP_LIST( \
CONVERT_AND_CHECK_KEY, \ CONVERT_AND_CHECK_KEY, \
PER_KEY_DATA(XXX, __VA_ARGS__) \ PER_KEY_DATA(XXX, __VA_ARGS__)) \
) \
} }
#endif #endif
@ -124,8 +120,7 @@ void setup();
#define xstr(a) str(a) #define xstr(a) str(a)
#define str(a) #a #define str(a) #a
static_assert(KALEIDOSCOPE_REQUIRED_API_VERSION == KALEIDOSCOPE_API_VERSION, static_assert(KALEIDOSCOPE_REQUIRED_API_VERSION == KALEIDOSCOPE_API_VERSION,
"Kaleidoscope API version mismatch! We have version " xstr(KALEIDOSCOPE_API_VERSION) "Kaleidoscope API version mismatch! We have version " xstr(KALEIDOSCOPE_API_VERSION) " available, but version " xstr(KALEIDOSCOPE_REQUIRED_API_VERSION) " is required.");
" available, but version " xstr(KALEIDOSCOPE_REQUIRED_API_VERSION) " is required.");
#endif #endif
// Use this function macro to register plugins with Kaleidoscope's // Use this function macro to register plugins with Kaleidoscope's

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save