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

@ -88,17 +88,13 @@ adjust-git-timestamps:
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:
find ./* -type f \( -name '*.h' -o -name '*.cpp' -o -name '*.ino' \) | grep -v "testing/googletest" | xargs -n 1 astyle --project
format:
bin/format-code.sh
check-astyle: astyle
if ! git diff --exit-code; then \
>&2 echo "'astyle' found code style differences. Please make astyle and commit your changes"; \
exit 1; \
fi; \
exit 0;
check-formatting:
bin/format-code.sh --check
cpplint-noisy:
-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:
KeyAddr active_addr_ = KeyAddr::none();
};
} // namespace plugin

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

@ -72,7 +72,8 @@ class AutoShift : public Plugin {
public:
// 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() {
return Categories(LETTERS);

@ -38,7 +38,7 @@ namespace plugin {
// =============================================================================
// CharShift class variables
CharShift::KeyPair const * CharShift::progmem_keypairs_{nullptr};
CharShift::KeyPair const *CharShift::progmem_keypairs_{nullptr};
uint8_t CharShift::num_keypairs_{0};
bool CharShift::reverse_shift_state_{false};
@ -131,13 +131,15 @@ CharShift::KeyPair CharShift::decodeCharShiftKey(Key key) {
// This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak))
uint8_t CharShift::numKeyPairs() {
uint8_t
CharShift::numKeyPairs() {
return numProgmemKeyPairs();
}
// This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak))
CharShift::KeyPair CharShift::readKeyPair(uint8_t n) {
CharShift::KeyPair
CharShift::readKeyPair(uint8_t n) {
return readKeyPairFromProgmem(n);
}

@ -59,7 +59,8 @@ class CharShift : public Plugin {
///
/// This constructor is used when defining an array of `KeyPair` objects in
/// 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
///
@ -75,15 +76,15 @@ class CharShift : public Plugin {
/// `keypairs` array given, which must be a fixed-sized array, not a pointer.
/// Generally, it will be called via the `KEYPAIRS()` preprocessor macro, not
/// directly by user code.
template <uint8_t _num_keypairs>
static void setProgmemKeyPairs(KeyPair const(&keypairs)[_num_keypairs]) {
template<uint8_t _num_keypairs>
static void setProgmemKeyPairs(KeyPair const (&keypairs)[_num_keypairs]) {
progmem_keypairs_ = keypairs;
num_keypairs_ = _num_keypairs;
}
private:
// A pointer to an array of `KeyPair` objects in PROGMEM
static KeyPair const * progmem_keypairs_;
static KeyPair const *progmem_keypairs_;
// The size of the PROGMEM array of `KeyPair` objects
static uint8_t num_keypairs_;
@ -125,12 +126,12 @@ extern kaleidoscope::plugin::CharShift CharShift;
/// defines them as an array in PROGMEM, and configures `CharShift` to use that
/// array, automatically setting the count correctly to prevent out-of-bounds
/// lookups.
#define CS_KEYS(keypairs...) { \
#define CS_KEYS(keypairs...) \
{ \
static kaleidoscope::plugin::CharShift::KeyPair const kp_table[] PROGMEM = { \
keypairs \
}; \
keypairs}; \
CharShift.setProgmemKeyPairs(kp_table); \
}
}
/// Define an `KeyPair` entry in a keymap
///

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

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

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

@ -30,9 +30,9 @@
constexpr Key Key_Cycle = Key(kaleidoscope::ranges::CYCLE);
#define cycleThrough(...) ({ \
static const Key __k[] PROGMEM = { __VA_ARGS__ }; \
static const Key __k[] PROGMEM = {__VA_ARGS__}; \
Cycle.replace(sizeof(__k) / sizeof(Key), &__k[0]); \
})
})
namespace kaleidoscope {
namespace plugin {

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

@ -57,7 +57,7 @@ constexpr size_t strlen(const char *str) {
return str[0] ? strlen(str + 1) + 1 : 0;
}
template <char... chars>
template<char... chars>
struct string {
#if ARDUINOTRACE_ENABLE_PROGMEM
const __FlashStringHelper *data() {
@ -72,52 +72,47 @@ struct string {
#endif
};
template <typename TSourceString, size_t remainingLength,
char... collectedChars>
template<typename TSourceString, size_t remainingLength, char... collectedChars>
struct string_maker {
using result =
typename string_maker < TSourceString, remainingLength - 1,
TSourceString::data()[remainingLength - 1],
collectedChars... >::result;
typename string_maker<TSourceString, remainingLength - 1, TSourceString::data()[remainingLength - 1], collectedChars...>::result;
};
#if ARDUINOTRACE_ENABLE_FULLPATH == 0
template <typename TSourceString, size_t remainingLength,
char... collectedChars>
template<typename TSourceString, size_t remainingLength, char... collectedChars>
struct string_maker<TSourceString, remainingLength, '/', collectedChars...> {
using result = string<collectedChars..., '\0'>;
};
template <typename TSourceString, size_t remainingLength,
char... collectedChars>
template<typename TSourceString, size_t remainingLength, char... collectedChars>
struct string_maker<TSourceString, remainingLength, '\\', collectedChars...> {
using result = string<collectedChars..., '\0'>;
};
#endif
template <typename TSourceString, char... collectedChars>
template<typename TSourceString, char... collectedChars>
struct string_maker<TSourceString, 0, collectedChars...> {
using result = string<collectedChars..., '\0'>;
};
template <typename TStringSource>
template<typename TStringSource>
using make_string =
typename string_maker<TStringSource, strlen(TStringSource::data())>::result;
struct Initializer {
template <typename TSerial>
template<typename TSerial>
Initializer(TSerial &serial, int bauds) {
serial.begin(bauds);
while (!serial) continue;
}
};
template <typename TFilename, typename TPrefix>
template<typename TFilename, typename TPrefix>
struct Printer {
template <typename TSerial, typename TValue>
template<typename TSerial, typename TValue>
Printer(TSerial &serial, const TValue &content) {
serial.print(make_string<TFilename> {}.data());
serial.print(make_string<TPrefix> {}.data());
serial.print(make_string<TFilename>{}.data());
serial.print(make_string<TPrefix>{}.data());
serial.println(content);
serial.flush();
}
@ -173,9 +168,7 @@ struct Printer {
// However, if you use it at global scope, you need to call ARDUINOTRACE_INIT()
// first, otherwise, the Serial port will not be ready.
#define TRACE() \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \
ARDUINOTRACE_TRACE_PREFIX(__LINE__), \
ARDUINOTRACE_FUNCTION_NAME)
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_TRACE_PREFIX(__LINE__), ARDUINOTRACE_FUNCTION_NAME)
// 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()
// first, otherwise, the Serial port will not be ready.
#define DUMP(variable) \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \
ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
#else // ie ARDUINOTRACE_ENABLE == 0

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

@ -28,7 +28,7 @@
namespace kaleidoscope {
namespace plugin {
class DynamicTapDance: public kaleidoscope::Plugin {
class DynamicTapDance : public kaleidoscope::Plugin {
public:
DynamicTapDance() {}
@ -37,8 +37,7 @@ class DynamicTapDance: public kaleidoscope::Plugin {
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,
TapDance::ActionType tap_dance_action);
static bool dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, TapDance::ActionType tap_dance_action);
private:
static uint16_t storage_base_;

@ -91,7 +91,7 @@ void EEPROMKeymap::updateKey(uint16_t base_pos, Key key) {
Runtime.storage().update(keymap_base_ + base_pos * 2 + 1, key.getKeyCode());
}
void EEPROMKeymap::dumpKeymap(uint8_t layers, Key(*getkey)(uint8_t, KeyAddr)) {
void EEPROMKeymap::dumpKeymap(uint8_t layers, Key (*getkey)(uint8_t, KeyAddr)) {
for (uint8_t layer = 0; layer < layers; layer++) {
for (auto key_addr : KeyAddr::all()) {
Key k = (*getkey)(layer, key_addr);
@ -134,7 +134,7 @@ EventHandlerResult EEPROMKeymap::onFocusEvent(const char *command) {
// we actully want.
//
dumpKeymap(progmem_layers_,
static_cast<Key(*)(uint8_t, KeyAddr)>(Layer_::getKeyFromPROGMEM));
static_cast<Key (*)(uint8_t, KeyAddr)>(Layer_::getKeyFromPROGMEM));
return EventHandlerResult::EVENT_CONSUMED;
}
@ -146,7 +146,7 @@ EventHandlerResult EEPROMKeymap::onFocusEvent(const char *command) {
// tell the compiler which overload of getKey
// we actually want.
//
dumpKeymap(max_layers_, static_cast<Key(*)(uint8_t, KeyAddr)>(getKey));
dumpKeymap(max_layers_, static_cast<Key (*)(uint8_t, KeyAddr)>(getKey));
} else {
uint16_t i = 0;

@ -57,7 +57,7 @@ class EEPROMKeymap : public kaleidoscope::Plugin {
static Key parseKey(void);
static void printKey(Key key);
static void dumpKeymap(uint8_t layers, Key(*getkey)(uint8_t, KeyAddr));
static void dumpKeymap(uint8_t layers, Key (*getkey)(uint8_t, KeyAddr));
};
} // namespace plugin

@ -74,8 +74,8 @@ class EEPROMSettings : public kaleidoscope::Plugin {
static bool sealed_;
static struct settings {
uint8_t default_layer: 7;
bool ignore_hardcoded_layers: 1;
uint8_t default_layer : 7;
bool ignore_hardcoded_layers : 1;
uint8_t version;
uint16_t crc;
} settings_;

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

@ -34,7 +34,7 @@ class CRC_ {
public:
uint16_t crc = 0;
CRC_(void) {};
CRC_(void){};
void update(const void *data, uint8_t len);
void finalize(void) {

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

@ -27,8 +27,8 @@
// DEPRECATED: `OneShotCancelKey` doesn't match our normal naming, and should
// eventually be removed.
constexpr Key OneShotCancelKey {kaleidoscope::ranges::OS_CANCEL};
constexpr Key Key_OneShotCancel {kaleidoscope::ranges::OS_CANCEL};
constexpr Key OneShotCancelKey{kaleidoscope::ranges::OS_CANCEL};
constexpr Key Key_OneShotCancel{kaleidoscope::ranges::OS_CANCEL};
namespace kaleidoscope {
namespace plugin {

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

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

@ -57,19 +57,19 @@ class FocusSerial : public kaleidoscope::Plugin {
printBool(b);
Runtime.serialPort().print(SEPARATOR);
}
template <typename V>
template<typename V>
void send(V v) {
Runtime.serialPort().print(v);
Runtime.serialPort().print(SEPARATOR);
}
template <typename Var, typename... Vars>
template<typename Var, typename... Vars>
void send(Var v, Vars... vars) {
send(v);
send(vars...);
}
void sendRaw() {}
template <typename Var, typename... Vars>
template<typename Var, typename... Vars>
void sendRaw(Var v, Vars... vars) {
Runtime.serialPort().print(v);
sendRaw(vars...);

@ -159,7 +159,7 @@ uint8_t RaiseLEDDriver::getBrightness() {
void RaiseLEDDriver::syncLeds() {
// left and right sides
for (uint8_t i = 0; i < LED_BANKS; i ++) {
for (uint8_t i = 0; i < LED_BANKS; i++) {
// only send the banks that have changed - try to improve jitter performance
if (isLEDChangedLeft[i]) {
RaiseHands::leftHand.sendLEDBank(i);
@ -180,7 +180,7 @@ void RaiseLEDDriver::syncLeds() {
void RaiseLEDDriver::updateNeuronLED() {
static constexpr struct {
uint8_t r, g, b;
} pins = { 3, 5, 4 };
} pins = {3, 5, 4};
auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction;
// invert as these are common anode, and make sure we reach 65535 to be able
@ -371,9 +371,11 @@ void RaiseKeyScanner::setKeyscanInterval(uint8_t interval) {
}
void RaiseKeyScanner::setup() {
// clang-format off
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++) {
pinMode(keyscanner_pins[i], OUTPUT);
digitalWrite(keyscanner_pins[i], LOW);

@ -23,7 +23,8 @@
#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/driver/bootloader/samd/Bossac.h"
@ -44,6 +45,7 @@ using kaleidoscope::driver::led::no_led;
struct RaiseLEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 132;
// clang-format off
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).
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,
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
};
}; // clang-format on
};
#undef LHK
@ -66,6 +68,7 @@ class RaiseLEDDriver : public kaleidoscope::driver::led::Base<RaiseLEDDriverProp
static uint8_t getBrightness();
static void updateNeuronLED();
private:
static bool isLEDChangedNeuron;
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
// Neuron's LED, never send that to SLED.
static constexpr uint8_t led_map[][RaiseLEDDriverProps::led_count + 1] = {
// clang-format off
// ISO
{
// 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,
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 {
@ -124,6 +128,7 @@ class RaiseKeyScanner : public kaleidoscope::driver::keyscanner::Base<RaiseKeySc
private:
typedef RaiseKeyScanner ThisType;
typedef RaiseKeyScannerProps Props_;
public:
static void setup();
static void scanMatrix();
@ -172,9 +177,10 @@ struct RaiseProps : kaleidoscope::device::BaseProps {
static constexpr const char *short_name = "raise";
};
class Raise: public kaleidoscope::device::Base<RaiseProps> {
class Raise : public kaleidoscope::device::Base<RaiseProps> {
private:
static RaiseProps::SideFlasher SideFlasher;
public:
static void setup();
@ -230,6 +236,8 @@ typedef kaleidoscope::device::dygma::Raise Device;
} // namespace kaleidoscope
// clang-format off
#define PER_KEY_DATA(dflt, \
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, \

@ -223,7 +223,7 @@ auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction;
void RaiseSide::sendLEDBank(uint8_t bank) {
uint8_t data[LED_BYTES_PER_BANK + 1]; // + 1 for the update LED command itself
data[0] = TWI_CMD_LED_BASE + bank;
for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) {
for (uint8_t i = 0; i < LED_BYTES_PER_BANK; i++) {
uint8_t c = led_data.bytes[bank][i];
if (c > brightness_adjustment_)
c -= brightness_adjustment_;

@ -57,7 +57,8 @@ typedef union {
class RaiseSide {
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 readSLEDVersion();

@ -28,10 +28,11 @@ namespace device {
namespace dygma {
namespace raise {
template <typename _Firmware>
template<typename _Firmware>
class SideFlash : public kaleidoscope::Plugin {
private:
_Firmware firmware;
public:
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")))

@ -50,7 +50,7 @@ uint8_t TWI::writeTo(uint8_t *data, size_t length) {
return 0;
}
uint8_t TWI::readFrom(uint8_t* data, size_t length) {
uint8_t TWI::readFrom(uint8_t *data, size_t length) {
uint8_t counter = 0;
uint32_t timeout;
uint8_t *buffer = data;

@ -29,10 +29,11 @@ namespace raise {
class TWI {
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 readFrom(uint8_t* data, size_t length);
uint8_t readFrom(uint8_t *data, size_t length);
void disable();
void init(uint16_t clock_khz);
uint8_t crc_errors() {

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

@ -33,7 +33,8 @@ struct cRGB {
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/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_columns = 6;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
};
typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader;
static constexpr const char *short_name = "ErgoDox-EZ";
@ -96,6 +96,8 @@ class ErgoDox : public kaleidoscope::device::ATmega32U4Keyboard<ErgoDoxProps> {
class ErgoDox;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA_STACKED(dflt, \
/* left hand, spatial positions */ \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \

@ -35,8 +35,8 @@
#include "kaleidoscope/device/ez/ErgoDox/i2cmaster.h"
#define I2C_ADDR 0b0100000
#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE )
#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ )
#define I2C_ADDR_WRITE ((I2C_ADDR << 1) | I2C_WRITE)
#define I2C_ADDR_READ ((I2C_ADDR << 1) | I2C_READ)
#define IODIRA 0x00
#define IODIRB 0x01
#define GPPUA 0x0C
@ -90,8 +90,7 @@ out:
return status;
}
void
ErgoDoxScanner::begin() {
void ErgoDoxScanner::begin() {
expander_error_ = initExpander();
// Init columns
@ -118,13 +117,13 @@ void __attribute__((optimize(3))) ErgoDoxScanner::selectExtenderRow(int row) {
expander_error_ = i2c_write(0xFF & ~(1 << row));
if (expander_error_)
goto out;
out:
out:
i2c_stop();
}
}
void __attribute__((optimize(3))) ErgoDoxScanner::toggleATMegaRow(int row) {
static uint8_t row_pins[] = { PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_D2, PIN_D3, PIN_C6 };
static uint8_t row_pins[] = {PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_D2, PIN_D3, PIN_C6};
OUTPUT_TOGGLE(row_pins[row]);
}
@ -148,7 +147,7 @@ ErgoDoxScanner::readCols(int row) {
data = i2c_readNak();
data = ~data;
out:
out:
i2c_stop();
return data;
} else {
@ -156,8 +155,7 @@ out:
}
}
void
ErgoDoxScanner::reattachExpanderOnError() {
void ErgoDoxScanner::reattachExpanderOnError() {
static uint32_t start_time = millis();
if (!expander_error_)

@ -39,7 +39,7 @@ void i2c_init(void) {
TWSR = 0; /* no prescaler */
TWBR = 10; /* must be >= 10 for stable operation */
}/* i2c_init */
} /* i2c_init */
/*************************************************************************
@ -53,7 +53,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
@ -64,7 +65,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN);
// 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.
twst = TW_STATUS & 0xF8;
@ -72,7 +74,7 @@ unsigned char i2c_start(unsigned char address) {
return 0;
}/* i2c_start */
} /* i2c_start */
/*************************************************************************
@ -90,7 +92,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
@ -101,7 +104,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN);
// wail until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
@ -110,7 +114,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO));
while (TWCR & (1 << TWSTO))
;
continue;
}
@ -118,7 +123,7 @@ void i2c_start_wait(unsigned char address) {
break;
}
}/* i2c_start_wait */
} /* i2c_start_wait */
/*************************************************************************
@ -132,7 +137,7 @@ void i2c_start_wait(unsigned char address) {
unsigned char i2c_rep_start(unsigned char address) {
return i2c_start(address);
}/* i2c_rep_start */
} /* i2c_rep_start */
/*************************************************************************
@ -143,9 +148,10 @@ void i2c_stop(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO));
while (TWCR & (1 << TWSTO))
;
}/* i2c_stop */
} /* i2c_stop */
/*************************************************************************
@ -163,14 +169,15 @@ unsigned char i2c_write(unsigned char data) {
TWCR = (1 << TWINT) | (1 << TWEN);
// wait until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits
twst = TW_STATUS & 0xF8;
if (twst != TW_MT_DATA_ACK) return 1;
return 0;
}/* i2c_write */
} /* i2c_write */
/*************************************************************************
@ -180,11 +187,12 @@ unsigned char i2c_write(unsigned char data) {
*************************************************************************/
unsigned char i2c_readAck(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
return TWDR;
}/* i2c_readAck */
} /* i2c_readAck */
/*************************************************************************
@ -194,11 +202,12 @@ unsigned char i2c_readAck(void) {
*************************************************************************/
unsigned char i2c_readNak(void) {
TWCR = (1 << TWINT) | (1 << TWEN);
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
return TWDR;
}/* i2c_readNak */
} /* i2c_readNak */
#endif
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD

@ -30,9 +30,9 @@ namespace kaleidoscope {
namespace device {
namespace gd32 {
struct EvalStorageProps: kaleidoscope::driver::storage::GD32FlashProps {};
struct EvalStorageProps : kaleidoscope::driver::storage::GD32FlashProps {};
struct EvalProps: kaleidoscope::device::BaseProps {
struct EvalProps : kaleidoscope::device::BaseProps {
typedef kaleidoscope::driver::bootloader::gd32::Base BootLoader;
typedef eval::KeyScannerProps KeyScannerProps;
typedef eval::KeyScanner KeyScanner;
@ -41,12 +41,14 @@ struct EvalProps: kaleidoscope::device::BaseProps {
static constexpr const char *short_name = "GD32Eval";
};
class Eval: public kaleidoscope::device::Base<EvalProps> {};
class Eval : public kaleidoscope::device::Base<EvalProps> {};
// clang-format off
#define PER_KEY_DATA(dflt, \
R0C0, R0C1 \
) \
R0C0, R0C1
// clang-format on
} // namespace gd32
} // namespace device

@ -32,16 +32,17 @@ struct KeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps {
static constexpr uint8_t matrix_rows = 1;
static constexpr uint8_t matrix_columns = 2;
static constexpr uint8_t matrix_row_pins[] = { PA3 };
static constexpr uint8_t matrix_col_pins[] = { PE4, PD12 };
static constexpr uint8_t matrix_row_pins[] = {PA3};
static constexpr uint8_t matrix_col_pins[] = {PE4, PD12};
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
};
class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps> {
class KeyScanner : public kaleidoscope::driver::keyscanner::Base<KeyScannerProps> {
private:
typedef KeyScanner ThisType;
typedef KeyScannerProps Props_;
public:
static bool do_scan;
@ -55,6 +56,7 @@ class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps>
static bool wasKeyswitchPressed(KeyAddr key_addr);
static uint8_t previousPressedKeyswitchCount();
private:
/*
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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -32,7 +32,7 @@ namespace device {
namespace kbdfans {
struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps {
struct MCUProps: public kaleidoscope::driver::mcu::ATmega32U4Props {
struct MCUProps : public kaleidoscope::driver::mcu::ATmega32U4Props {
static constexpr bool disable_jtag = true;
static constexpr bool disable_clock_division = true;
};
@ -43,7 +43,7 @@ struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps {
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_D0, PIN_D1, PIN_D2, PIN_D3};
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_B3, PIN_B1, PIN_B0, PIN_D5, PIN_B7, PIN_C7 };
static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_B3, PIN_B1, PIN_B0, PIN_D5, PIN_B7, PIN_C7};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD
};
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -52,7 +52,7 @@ struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class KBD4x: public kaleidoscope::device::ATmega32U4Keyboard<KBD4xProps> {};
class KBD4x : public kaleidoscope::device::ATmega32U4Keyboard<KBD4xProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are
@ -63,6 +63,7 @@ class KBD4x;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
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, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace kbdfans
} // 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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -50,7 +50,7 @@ struct AtreusProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Atreus: public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
class Atreus : public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are
@ -61,6 +61,7 @@ class Atreus;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
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, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace keyboardio
} // 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
// `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
// cannot be in a header-only driver, and must be placed here.
@ -97,7 +98,7 @@ void ImagoLEDDriver::setup() {
}
void ImagoLEDDriver::twiSend(uint8_t addr, uint8_t Reg_Add, uint8_t Reg_Dat) {
uint8_t data[] = {Reg_Add, Reg_Dat };
uint8_t data[] = {Reg_Add, Reg_Dat};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
}
@ -139,11 +140,11 @@ uint8_t ImagoLEDDriver::adjustBrightness(uint8_t value) {
}
void ImagoLEDDriver::syncLeds() {
// if (!isLEDChanged)
// return;
// if (!isLEDChanged)
// return;
uint8_t data[LED_REGISTER_DATA_LARGEST + 1];
data[0] = 0;// the address of the first byte to copy in
data[0] = 0; // the address of the first byte to copy in
uint8_t last_led = 0;
// Write the first LED bank
@ -190,7 +191,6 @@ void ImagoLEDDriver::setAllPwmTo(uint8_t step) {
// PWM Register 0 is 0x00 to 0xB3
for (auto i = 1; i <= 0xB4; i++) {
data[i] = step;
}
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
for (auto i = 1; i <= LED_REGISTER_PWM1_SIZE; i++) {
data[i] = step;
}
twi_writeTo(LED_DRIVER_ADDR, data, 0xAC, 1, 0);
}

@ -27,7 +27,8 @@ struct cRGB {
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/driver/bootloader/avr/Caterina.h"
@ -40,14 +41,16 @@ namespace keyboardio {
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 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,
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,
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
// clang-format on
};
};
@ -101,12 +104,13 @@ struct ImagoProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Imago: public kaleidoscope::device::ATmega32U4Keyboard<ImagoProps> {
class Imago : public kaleidoscope::device::ATmega32U4Keyboard<ImagoProps> {
public:
void setup();
};
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
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, \
@ -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 , \
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
// clang-format on
} // namespace keyboardio
} // namespace device

@ -44,10 +44,10 @@ void twi_init(void);
void twi_disable(void);
void twi_setAddress(uint8_t);
void twi_setFrequency(uint32_t);
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
uint8_t twi_transmit(const uint8_t*, uint8_t);
void twi_attachSlaveRxEvent(void (*)(uint8_t*, int));
uint8_t twi_readFrom(uint8_t, uint8_t *, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t *, uint8_t, uint8_t, uint8_t);
uint8_t twi_transmit(const uint8_t *, uint8_t);
void twi_attachSlaveRxEvent(void (*)(uint8_t *, int));
void twi_attachSlaveTxEvent(void (*)(void));
void twi_reply(uint8_t);
void twi_stop(void);

@ -30,7 +30,8 @@
#include "kaleidoscope/MatrixAddr.h" // for MatrixAddr
#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 {
uint8_t b;
@ -53,10 +54,12 @@ namespace keyboardio {
struct Model01LEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 64;
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,
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,
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> {
private:
typedef Model01KeyScanner ThisType;
public:
static void setup();
static void scanMatrix();
@ -143,6 +147,8 @@ EXPORT_DEVICE(kaleidoscope::device::keyboardio::Model01)
} // namespace kaleidoscope
// clang-format off
#define PER_KEY_DATA_STACKED(dflt, \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, \

@ -44,10 +44,10 @@ void twi_init(void);
void twi_disable(void);
void twi_setAddress(uint8_t);
void twi_setFrequency(uint32_t);
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
uint8_t twi_transmit(const uint8_t*, uint8_t);
void twi_attachSlaveRxEvent(void (*)(uint8_t*, int));
uint8_t twi_readFrom(uint8_t, uint8_t *, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t *, uint8_t, uint8_t, uint8_t);
uint8_t twi_transmit(const uint8_t *, uint8_t);
void twi_attachSlaveRxEvent(void (*)(uint8_t *, int));
void twi_attachSlaveTxEvent(void (*)(void));
void twi_reply(uint8_t);
void twi_stop(void);

@ -82,8 +82,6 @@ uint8_t Model01Side::setKeyscanInterval(uint8_t delay) {
}
// returns -1 on error, otherwise returns the scanner version integer
int Model01Side::readVersion() {
return readRegister(TWI_CMD_VERSION);
@ -113,7 +111,6 @@ uint8_t Model01Side::setLEDSPIFrequency(uint8_t frequency) {
}
int Model01Side::readRegister(uint8_t cmd) {
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);
delayMicroseconds(15); // We may be able to drop this in the future
// but will need to verify with correctly
// sized pull-ups on both the left and right
@ -137,7 +133,6 @@ int Model01Side::readRegister(uint8_t cmd) {
} else {
return -1;
}
}
@ -175,7 +170,7 @@ auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction;
void Model01Side::sendLEDBank(uint8_t bank) {
uint8_t data[LED_BYTES_PER_BANK + 1];
data[0] = TWI_CMD_LED_BASE + bank;
for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) {
for (uint8_t i = 0; i < LED_BYTES_PER_BANK; i++) {
/* While the ATTiny controller does have a global brightness command, it is
* limited to 32 levels, and those aren't nicely spread out either. For this
* reason, we're doing our own brightness adjustment on this side, because
@ -195,8 +190,7 @@ void Model01Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
pgm_read_byte(&gamma8[color.b]),
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);
}
@ -205,10 +199,8 @@ void Model01Side::setOneLEDTo(uint8_t led, cRGB color) {
led,
pgm_read_byte(&gamma8[color.b]),
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);
}
} // namespace keyboardio

@ -34,13 +34,14 @@ struct cRGB {
uint8_t g;
uint8_t r;
};
#define CRGB(r,g,b) (cRGB){b, g, r}
#define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif
#define LED_BANKS 4
#define LEDS_PER_HAND 32
#define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND/LED_BANKS
#define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND / LED_BANKS
namespace kaleidoscope {
namespace driver {

@ -48,7 +48,6 @@ void Model100Hands::setup(void) {
Model100KeyScanner::enableScannerPower();
Wire.begin();
Wire.setClock(400000);
}
/********* LED Driver *********/
@ -125,9 +124,9 @@ driver::keyboardio::keydata_t Model100KeyScanner::previousLeftHandState;
driver::keyboardio::keydata_t Model100KeyScanner::previousRightHandState;
void Model100KeyScanner::enableScannerPower(void) {
// Turn on the switched 5V network.
// make sure this happens at least 100ms after USB connect
// to satisfy inrush limits
// Turn on the switched 5V network.
// make sure this happens at least 100ms after USB connect
// to satisfy inrush limits
//
pinMode(PB9, OUTPUT_OPEN_DRAIN);
digitalWrite(PB9, LOW);
@ -141,7 +140,6 @@ void Model100KeyScanner::disableScannerPower(void) {
}
void Model100KeyScanner::setup() {
enableScannerPower();
delay(250);

@ -25,7 +25,8 @@
#include <Arduino.h>
#define CRGB(r,g,b) (cRGB){b, g, r}
#define CRGB(r, g, b) \
(cRGB) { b, g, r }
struct cRGB {
uint8_t b;
@ -47,7 +48,7 @@ namespace kaleidoscope {
namespace device {
namespace keyboardio {
struct Model100StorageProps: public kaleidoscope::driver::storage::GD32FlashProps {
struct Model100StorageProps : public kaleidoscope::driver::storage::GD32FlashProps {
static constexpr uint16_t length = EEPROM_EMULATION_SIZE;
};
@ -55,10 +56,12 @@ struct Model100StorageProps: public kaleidoscope::driver::storage::GD32FlashProp
struct Model100LEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 64;
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,
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,
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> {
private:
typedef Model100KeyScanner ThisType;
public:
static void setup();
static void scanMatrix();
@ -120,7 +124,7 @@ class Model100KeyScanner;
// If we need to override HID props:
struct Model100HIDProps: public kaleidoscope::driver::hid::KeyboardioProps {
struct Model100HIDProps : public kaleidoscope::driver::hid::KeyboardioProps {
//typedef kaleidoscope::driver::hid::base::AbsoluteMouseProps AbsoluteMouseProps;
//typedef kaleidoscope::driver::hid::base::AbsoluteMouse<AbsoluteMouseProps> AbsoluteMouse;
};
@ -165,6 +169,8 @@ EXPORT_DEVICE(kaleidoscope::device::keyboardio::Model100)
} // namespace kaleidoscope
// clang-format off
#define PER_KEY_DATA_STACKED(dflt, \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \
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
int Model100Side::readVersion() {
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.
return false;
}
}
void Model100Side::markDeviceUnavailable() {
@ -180,7 +177,6 @@ int Model100Side::readRegister(uint8_t cmd) {
markDeviceUnavailable();
return -1;
}
}
@ -225,7 +221,7 @@ void Model100Side::sendLEDData() {
void Model100Side::sendLEDBank(uint8_t bank) {
uint8_t data[LED_BYTES_PER_BANK + 1];
data[0] = TWI_CMD_LED_BASE + bank;
for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) {
for (uint8_t i = 0; i < LED_BYTES_PER_BANK; i++) {
/* While the ATTiny controller does have a global brightness command, it is
* limited to 32 levels, and those aren't nicely spread out either. For this
* reason, we're doing our own brightness adjustment on this side, because
@ -245,8 +241,7 @@ void Model100Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
color.b,
color.g,
color.r
};
color.r};
uint8_t result = writeData(data, ELEMENTS(data));
}
@ -255,10 +250,8 @@ void Model100Side::setOneLEDTo(uint8_t led, cRGB color) {
led,
color.b,
color.g,
color.r
};
color.r};
uint8_t result = writeData(data, ELEMENTS(data));
}
} // namespace keyboardio

@ -34,13 +34,14 @@ struct cRGB {
uint8_t g;
uint8_t r;
};
#define CRGB(r,g,b) (cRGB){b, g, r}
#define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif
#define LED_BANKS 4
#define LEDS_PER_HAND 32
#define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND/LED_BANKS
#define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND / LED_BANKS
namespace kaleidoscope {
namespace driver {
@ -103,7 +104,7 @@ class Model100Side {
byte nextLEDBank = 0;
void sendLEDBank(byte bank);
int readRegister(uint8_t cmd);
uint8_t writeData(uint8_t* data, uint8_t length);
uint8_t writeData(uint8_t *data, uint8_t length);
};
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -45,7 +45,7 @@ struct PlanckProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Planck: public kaleidoscope::device::ATmega32U4Keyboard<PlanckProps> {};
class Planck : public kaleidoscope::device::ATmega32U4Keyboard<PlanckProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are
@ -56,6 +56,7 @@ class Planck;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
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, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace olkb
} // 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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -39,7 +39,7 @@ namespace device {
namespace softhruf {
struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps {
struct MCUProps: kaleidoscope::driver::mcu::ATmega32U4Props {
struct MCUProps : kaleidoscope::driver::mcu::ATmega32U4Props {
static constexpr bool disable_jtag = true;
};
typedef kaleidoscope::driver::mcu::ATmega32U4<MCUProps> MCU;
@ -49,7 +49,7 @@ struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps {
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_D0, PIN_D1, PIN_D2, PIN_D3};
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_C7, PIN_C6, PIN_B6, PIN_B5, PIN_B4, PIN_D7 };
static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_C7, PIN_C6, PIN_B6, PIN_B5, PIN_B4, PIN_D7};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD
};
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -58,7 +58,7 @@ struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Splitography: public kaleidoscope::device::ATmega32U4Keyboard<SplitographyProps> {};
class Splitography : public kaleidoscope::device::ATmega32U4Keyboard<SplitographyProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are
@ -68,6 +68,8 @@ class Splitography: public kaleidoscope::device::ATmega32U4Keyboard<Splitography
class Splitography;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 \
,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, \
dflt ,dflt ,dflt ,dflt ,r3c4 ,r3c5 ,r3c6 ,r3c7 ,dflt ,dflt ,dflt ,dflt
// clang-format on
} // namespace softhruf
} // 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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -75,7 +75,7 @@ struct AtreusProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Atreus: public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
class Atreus : public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are
@ -85,6 +85,8 @@ class Atreus: public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
class Atreus;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \
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, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
// clang-format on
} // namespace technomancy
} // 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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -37,8 +37,8 @@ struct ButterStickProps : kaleidoscope::device::ATmega32U4KeyboardProps {
static constexpr uint8_t matrix_columns = 10;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = { PIN_F4, PIN_F5 };
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_B4, PIN_B5, PIN_B6, PIN_B7, PIN_C6, PIN_C7 };
static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_F4, PIN_F5};
static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_B4, PIN_B5, PIN_B6, PIN_B7, PIN_C6, PIN_C7};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD
};
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -47,7 +47,7 @@ struct ButterStickProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class ButterStick: public kaleidoscope::device::ATmega32U4Keyboard<ButterStickProps> {};
class ButterStick : public kaleidoscope::device::ATmega32U4Keyboard<ButterStickProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are
@ -58,12 +58,15 @@ class ButterStick;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9 \
) \
R0C9, R0C8, R0C7, R0C6, R0C5, R0C4, R0C3, R0C2, R0C1, R0C0, \
R1C9, R1C8, R1C7, R1C6, R1C5, R1C4, R1C3, R1C2, R1C1, R1C0
// clang-format on
} // namespace gheavy
} // 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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -37,8 +37,8 @@ struct FaunchPadProps : kaleidoscope::device::ATmega32U4KeyboardProps {
static constexpr uint8_t matrix_columns = 4;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = { PIN_F4, PIN_F5 };
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_B3, PIN_B2, PIN_B1, PIN_B0 };
static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_F4, PIN_F5};
static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_B3, PIN_B2, PIN_B1, PIN_B0};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD
};
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -47,7 +47,7 @@ struct FaunchPadProps : kaleidoscope::device::ATmega32U4KeyboardProps {
};
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class FaunchPad: public kaleidoscope::device::ATmega32U4Keyboard<FaunchPadProps> {};
class FaunchPad : public kaleidoscope::device::ATmega32U4Keyboard<FaunchPadProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are
@ -58,11 +58,14 @@ class FaunchPad;
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
// clang-format off
#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7 \
) \
R0C0, R0C1, R0C2, R0C3, \
R0C4, R0C5, R0C6, R0C7
// clang-format on
} // namespace gheavy
} // namespace device

@ -41,7 +41,7 @@ void HardwareTestMode::waitForKeypress() {
while (1) {
Runtime.device().readMatrix();
if (Runtime.device().isKeyswitchPressed(actionKey) &&
! Runtime.device().wasKeyswitchPressed(actionKey)) {
!Runtime.device().wasKeyswitchPressed(actionKey)) {
break;
}
}
@ -75,11 +75,9 @@ void HardwareTestMode::testLeds(void) {
setLeds(blue);
setLeds(green);
setLeds(red);
}
void HardwareTestMode::testMatrix() {
// Reset bad keys from previous tests.
chatter_data state[Runtime.device().numKeys()] = {{0, 0, 0}};
@ -95,7 +93,7 @@ void HardwareTestMode::testMatrix() {
uint8_t keynum = key_addr.toInt();
// If the key is toggled on
if (Runtime.device().isKeyswitchPressed(key_addr) && ! Runtime.device().wasKeyswitchPressed(key_addr)) {
if (Runtime.device().isKeyswitchPressed(key_addr) && !Runtime.device().wasKeyswitchPressed(key_addr)) {
// And it's too soon (in terms of cycles between changes)
state[keynum].tested = 1;
if (state[keynum].cyclesSinceStateChange < CHATTER_CYCLE_LIMIT) {
@ -113,7 +111,7 @@ void HardwareTestMode::testMatrix() {
Runtime.device().setCrgbAt(key_addr, red);
} else if (state[keynum].tested == 0) {
Runtime.device().setCrgbAt(key_addr, yellow);
} else if (! Runtime.device().isKeyswitchPressed(key_addr)) {
} else if (!Runtime.device().isKeyswitchPressed(key_addr)) {
// If the key is not currently pressed and was not just released and is not marked bad
Runtime.device().setCrgbAt(key_addr, blue);
}

@ -26,11 +26,10 @@ namespace plugin {
class HardwareTestMode : public kaleidoscope::Plugin {
public:
typedef struct {
uint8_t bad : 1,
tested : 1,
cyclesSinceStateChange: 6;
cyclesSinceStateChange : 6;
} chatter_data;
static uint8_t actionKey;
@ -38,6 +37,7 @@ class HardwareTestMode : public kaleidoscope::Plugin {
static void runTests();
static void setActionKey(uint8_t key);
private:
static void testLeds();
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)
highest_(1),
// last heatmap computation time
last_heatmap_comp_time_(Runtime.millisAtCycleStart())
{}
last_heatmap_comp_time_(Runtime.millisAtCycleStart()) {}
cRGB Heatmap::TransientLEDMode::computeColor(float v) {
// compute the color corresponding to a value between 0 and 1

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

@ -40,7 +40,7 @@ EventHandlerResult FocusHostOSCommand::onFocusEvent(const char *command) {
} else {
uint8_t new_os;
::Focus.read(new_os);
::HostOS.os((hostos::Type) new_os);
::HostOS.os((hostos::Type)new_os);
}
return EventHandlerResult::EVENT_CONSUMED;

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

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

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

@ -44,7 +44,7 @@ cRGB ActiveModColorEffect::sticky_color_ = CRGB(160, 0, 0);
EventHandlerResult ActiveModColorEffect::onKeyEvent(KeyEvent &event) {
// If `event.addr` is not a physical key address, ignore it:
if (! event.addr.isValid()) {
if (!event.addr.isValid()) {
return EventHandlerResult::OK;
}

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

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

@ -35,10 +35,9 @@ namespace plugin {
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_right_(Key_NoKey)
{}
last_key_right_(Key_NoKey) {}
void AlphaSquareEffect::TransientLEDMode::update(void) {
if (!Runtime.has_leds)

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

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

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

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

@ -33,15 +33,13 @@ namespace plugin {
StalkerEffect::ColorComputer *StalkerEffect::variant;
uint16_t StalkerEffect::step_length = 50;
cRGB StalkerEffect::inactive_color = (cRGB) {
0, 0, 0
};
cRGB StalkerEffect::inactive_color = (cRGB){
0, 0, 0};
StalkerEffect::TransientLEDMode::TransientLEDMode(const StalkerEffect *parent)
: parent_(parent),
step_start_time_(0),
map_{}
{}
map_{} {}
EventHandlerResult StalkerEffect::onKeyEvent(KeyEvent &event) {
if (!Runtime.has_leds)
@ -130,7 +128,7 @@ cRGB BlazingTrail::compute(uint8_t *step) {
// Fade value from full following a 1-x^4 curve
uint8_t val =
0xff // Maximum brightness
- ((uint32_t) pos255 * pos255 * pos255 * pos255 // Animation position to 4th power
- ((uint32_t)pos255 * pos255 * pos255 * pos255 // Animation position to 4th power
>> 24) // ...pulled down to 8-bit range (but this has a maximum of 0xfc rather than 0xff)
- pos255 / (0x100 / 4); // Correction to bring the end result into a full 0 to 0xff range

@ -28,7 +28,7 @@
#include "kaleidoscope/plugin/LEDMode.h" // for LEDMode
#include "kaleidoscope/plugin/LEDModeInterface.h" // for LEDModeInter...
#define STALKER(v, ...) ({static kaleidoscope::plugin::stalker::v _effect __VA_ARGS__; &_effect;})
#define STALKER(v, ...) ({static kaleidoscope::plugin::stalker::v _effect __VA_ARGS__; &_effect; })
namespace kaleidoscope {
namespace plugin {
@ -53,7 +53,6 @@ class StalkerEffect : public Plugin,
//
class TransientLEDMode : public LEDMode {
public:
// Please note that storing the parent ptr is only required
// for those LED modes that require access to
// members of their parent class. Most LED modes can do without.
@ -61,11 +60,9 @@ class StalkerEffect : public Plugin,
explicit TransientLEDMode(const StalkerEffect *parent);
protected:
void update() final;
private:
const StalkerEffect *parent_;
uint16_t step_start_time_;
@ -80,9 +77,11 @@ namespace stalker {
class Haunt : public StalkerEffect::ColorComputer {
public:
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;
private:
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)
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,
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,
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)
: frames_since_event_(0),
surface_{},
page_(0)
{}
page_(0) {}
EventHandlerResult WavepoolEffect::onKeyEvent(KeyEvent &event) {
if (!event.addr.isValid())
@ -110,9 +111,9 @@ void WavepoolEffect::TransientLEDMode::update(void) {
// (side note: it's weird that this is a 16-bit int instead of 8-bit,
// but that's what the library function wants)
static uint8_t current_hue = 0;
current_hue ++;
current_hue++;
frames_since_event_ ++;
frames_since_event_++;
// needs two pages of height map to do the calculations
int8_t *newpg = &surface_[page_ ^ 1][0];
@ -135,9 +136,7 @@ void WavepoolEffect::TransientLEDMode::update(void) {
raindrop(prev_x, prev_y, oldpg);
prev_x = prev_y = -1;
}
if (frames_since_event_
>= (frames_till_next_drop
+ (idle_timeout / MS_PER_FRAME))) {
if (frames_since_event_ >= (frames_till_next_drop + (idle_timeout / MS_PER_FRAME))) {
frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP);
frames_since_event_ = idle_timeout / MS_PER_FRAME;
@ -162,10 +161,13 @@ void WavepoolEffect::TransientLEDMode::update(void) {
uint8_t offset = (y * WP_WID) + x;
int16_t value;
int8_t offsets[] = { -WP_WID, WP_WID,
int8_t offsets[] = {
// clang-format off
-WP_WID, WP_WID,
-1, 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
if (y == 0) {
@ -234,7 +236,6 @@ void WavepoolEffect::TransientLEDMode::update(void) {
// swap pages every frame
page_ ^= 1;
#endif
}
} // namespace plugin

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

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

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

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

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

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

@ -45,12 +45,12 @@ void TriColor::TransientLEDMode::update(void) {
cRGB color = parent_->mod_color_;
switch (k.getKeyCode()) {
case Key_A.getKeyCode() ... Key_0.getKeyCode():
case Key_A.getKeyCode()... Key_0.getKeyCode():
case Key_Spacebar.getKeyCode():
case Key_KeypadDivide.getKeyCode() ... Key_KeypadSubtract.getKeyCode():
case Key_Keypad1.getKeyCode() ... Key_KeypadDot.getKeyCode():
case Key_F1.getKeyCode() ... Key_F4.getKeyCode():
case Key_F9.getKeyCode() ... Key_F12.getKeyCode():
case Key_KeypadDivide.getKeyCode()... Key_KeypadSubtract.getKeyCode():
case Key_Keypad1.getKeyCode()... Key_KeypadDot.getKeyCode():
case Key_F1.getKeyCode()... Key_F4.getKeyCode():
case Key_F9.getKeyCode()... Key_F12.getKeyCode():
color = parent_->base_color_;
break;
case Key_Escape.getKeyCode():

@ -28,13 +28,13 @@ class TriColor : public Plugin,
public LEDModeInterface {
public:
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
//
class TransientLEDMode : public LEDMode {
public:
// Please note that storing the parent ptr is only required
// for those LED modes that require access to
// members of their parent class. Most LED modes can do without.
@ -43,11 +43,9 @@ class TriColor : public Plugin,
: parent_(parent) {}
protected:
void update(void) final;
private:
const TriColor *parent_;
};

@ -24,7 +24,7 @@
namespace kaleidoscope {
namespace plugin {
class LayerFocus: public kaleidoscope::Plugin {
class LayerFocus : public kaleidoscope::Plugin {
public:
LayerFocus() {}

@ -56,7 +56,7 @@ const Leader::dictionary_t *Leader::dictionary;
int8_t Leader::lookup(void) {
bool match;
for (uint8_t seq_index = 0; ; seq_index++) {
for (uint8_t seq_index = 0;; seq_index++) {
match = true;
if (dictionary[seq_index].sequence[0].readFromProgmem() == Key_NoKey)
@ -75,8 +75,7 @@ int8_t Leader::lookup(void) {
if (!match)
continue;
seq_key
= dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
seq_key = dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
if (seq_key == Key_NoKey) {
return seq_index;
} else {
@ -143,7 +142,7 @@ EventHandlerResult Leader::onKeyswitchEvent(KeyEvent &event) {
return EventHandlerResult::ABORT;
}
action_t leaderAction = (action_t) pgm_read_ptr((void const **) & (dictionary[action_index].action));
action_t leaderAction = (action_t)pgm_read_ptr((void const **)&(dictionary[action_index].action));
(*leaderAction)(action_index);
reset();

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

@ -32,7 +32,8 @@
// =============================================================================
// Default `macroAction()` function definitions
__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;
}
@ -300,7 +301,7 @@ EventHandlerResult Macros::onKeyEvent(KeyEvent &event) {
uint8_t macro_id = event.key.getRaw() - ranges::MACRO_FIRST;
// Call the new `macroAction(event)` function.
const macro_t* macro_ptr = macroAction(macro_id, event);
const macro_t *macro_ptr = macroAction(macro_id, event);
// Play back the macro pointed to by `macroAction()`
play(macro_ptr);

@ -27,7 +27,7 @@
// =============================================================================
// Define this function in a Kaleidoscope sketch in order to trigger Macros.
const macro_t* macroAction(uint8_t macro_id, KeyEvent &event);
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event);
// The number of simultaneously-active `Key` values that a macro can have
// running during a call to `Macros.play()`. I don't know if it's actually
@ -42,7 +42,6 @@ namespace plugin {
class Macros : public kaleidoscope::Plugin {
public:
/// Send a key press event from a Macro
///
/// Generates a new `KeyEvent` and calls `Runtime.handleKeyEvent()` with the
@ -71,17 +70,17 @@ class Macros : public kaleidoscope::Plugin {
void tap(Key key) const;
/// Play a macro sequence of key events
void play(const macro_t* macro_ptr);
void play(const macro_t *macro_ptr);
// Templates provide a `type()` function that takes a variable number of
// `char*` (string) arguments, in the form of a list of strings stored in
// PROGMEM, of the form `Macros.type(PSTR("Hello "), PSTR("world!"))`.
inline const macro_t* type() const {
inline const macro_t *type() const {
return MACRO_NONE;
}
const macro_t* type(const char* string) const;
template <typename... Strings>
const macro_t* type(const char* first, Strings&&... strings) const {
const macro_t *type(const char *string) const;
template<typename... Strings>
const macro_t *type(const char *first, Strings &&...strings) const {
type(first);
return type(strings...);
}
@ -105,7 +104,6 @@ class Macros : public kaleidoscope::Plugin {
return true;
return false;
}
};
} // namespace plugin

@ -49,8 +49,7 @@ typedef uint8_t macro_t;
{ \
static const macro_t __m[] PROGMEM = { \
__VA_ARGS__, \
MACRO_ACTION_END \
}; \
MACRO_ACTION_END}; \
&__m[0]; \
})
@ -58,15 +57,15 @@ typedef uint8_t macro_t;
#define W(n) MACRO_ACTION_STEP_WAIT, n
#define Kr(k) (k).getFlags(), (k).getKeyCode()
#define Kc(k) (Key_ ## k).getKeyCode()
#define K(k) Kr(Key_ ## k)
#define Kc(k) (Key_##k).getKeyCode()
#define K(k) Kr(Key_##k)
#define Dr(k) MACRO_ACTION_STEP_KEYDOWN, Kr(k)
#define D(k) Dr(Key_ ## k)
#define D(k) Dr(Key_##k)
#define Ur(k) MACRO_ACTION_STEP_KEYUP, Kr(k)
#define U(k) Ur(Key_ ## k)
#define U(k) Ur(Key_##k)
#define Tr(k) MACRO_ACTION_STEP_TAP, Kr(k)
#define T(k) Tr(Key_ ## k)
#define T(k) Tr(Key_##k)
#define Dc(k) MACRO_ACTION_STEP_KEYCODEDOWN, Kc(k)
#define Uc(k) MACRO_ACTION_STEP_KEYCODEUP, Kc(k)

@ -55,7 +55,7 @@ EventHandlerResult MagicCombo::afterEachCycle() {
match = false;
if (match && Runtime.hasTimeExpired(start_time_, min_interval)) {
ComboAction action = (ComboAction) pgm_read_ptr((void const **) & (magiccombo::combos[i].action));
ComboAction action = (ComboAction)pgm_read_ptr((void const **)&(magiccombo::combos[i].action));
(*action)(i);
start_time_ = Runtime.millisAtCycleStart();

@ -57,26 +57,26 @@ void MouseKeys::setSpeedLimit(uint8_t speed_limit) {
// =============================================================================
// Key variant tests
bool MouseKeys::isMouseKey(const Key& key) const {
bool MouseKeys::isMouseKey(const Key &key) const {
return (key.getFlags() == (SYNTHETIC | IS_MOUSE_KEY));
}
bool MouseKeys::isMouseButtonKey(const Key& key) const {
bool MouseKeys::isMouseButtonKey(const Key &key) const {
uint8_t variant = key.getKeyCode() & (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP);
return variant == KEY_MOUSE_BUTTON;
}
bool MouseKeys::isMouseMoveKey(const Key& key) const {
bool MouseKeys::isMouseMoveKey(const Key &key) const {
uint8_t mask = (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP | KEY_MOUSE_WHEEL);
uint8_t variant = key.getKeyCode() & mask;
return variant == 0;
}
bool MouseKeys::isMouseWarpKey(const Key& key) const {
bool MouseKeys::isMouseWarpKey(const Key &key) const {
return (key.getKeyCode() & KEY_MOUSE_WARP) != 0;
}
bool MouseKeys::isMouseWheelKey(const Key& key) const {
bool MouseKeys::isMouseWheelKey(const Key &key) const {
uint8_t mask = (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP | KEY_MOUSE_WHEEL);
uint8_t variant = key.getKeyCode() & mask;
return variant == KEY_MOUSE_WHEEL;

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

Loading…
Cancel
Save