FunctionalColor Plugin - Automatically label keys with colors

plugin
release

(Abdenour bachir) #21
// -*- mode: c++ -*-

// Copyright 2016 Keyboardio, inc. jesse@keyboard.io
// See “LICENSE” for license details

#ifndef BUILD_INFORMATION
#define BUILD_INFORMATION “locally built”
#endif

/**

  • These #include directives pull in the Kaleidoscope firmware core,
  • as well as the Kaleidoscope plugins we use in the Model 01’s firmware
    */

// The Kaleidoscope core
#include “Kaleidoscope.h”

// Support for keys that move the mouse
#include “Kaleidoscope-MouseKeys.h”

// Support for macros
#include “Kaleidoscope-Macros.h”

// Support for controlling the keyboard’s LEDs
#include “Kaleidoscope-LEDControl.h”

// Support for “Numpad” mode, which is mostly just the Numpad specific LED mode
#include “Kaleidoscope-NumPad.h”

// Support for an “LED off mode”
#include “LED-Off.h”

// Support for the “Boot greeting” effect, which pulses the ‘LED’ button for 10s
// when the keyboard is connected to a computer (or that computer is powered on)
#include “Kaleidoscope-LEDEffect-BootGreeting.h”

// Support for LED modes that set all LEDs to a single color
#include “Kaleidoscope-LEDEffect-SolidColor.h”

// Support for an LED mode that makes all the LEDs ‘breathe’
#include “Kaleidoscope-LEDEffect-Breathe.h”

// Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard
#include “Kaleidoscope-LEDEffect-Chase.h”

// Support for LED modes that pulse the keyboard’s LED in a rainbow pattern
#include “Kaleidoscope-LEDEffect-Rainbow.h”

// Support for an LED mode that lights up the keys as you press them
#include “Kaleidoscope-LED-Stalker.h”

// Support for an LED mode that prints the keys you press in letters 4px high
#include “Kaleidoscope-LED-AlphaSquare.h”

// Support for Keyboardio’s internal keyboard testing mode
#include “Kaleidoscope-Model01-TestMode.h”

// Automatically sets key LEDs on active layer based on the function of the key
#include “Kaleidoscope-LEDEffect-FunctionalColor.h”

//test abe

// You can make multiple variations of the theme.
// Warning: having several versions consumes a lot of memory!
kaleidoscope::LEDFunctionalColor FunColor;
kaleidoscope::LEDFunctionalColor FunColorMedium;
kaleidoscope::LEDFunctionalColor FunColorLow;

/** This ‘enum’ is a list of all the macros used by the Model 01’s firmware

  • The names aren’t particularly important. What is important is that each
  • is unique.
  • These are the names of your macros. They’ll be used in two places.
  • The first is in your keymap definitions. There, you’ll use the syntax
  • M(MACRO_NAME) to mark a specific keymap position as triggering MACRO_NAME
  • The second usage is in the ‘switch’ statement in the macroAction function.
  • That switch statement actually runs the code associated with a macro when
  • a macro key is pressed.
    */

enum { MACRO_VERSION_INFO,
MACRO_ANY
};

/** The Model 01’s key layouts are defined as ‘keymaps’. By default, there are three

  • keymaps: The standard QWERTY keymap, the “Function layer” keymap and the “Numpad”

  • keymap.

  • Each keymap is defined as a list using the ‘KEYMAP_STAdswCKED’ macro, built

  • of first the left hand’s layout, followed by the right hand’s layout.

  • Keymaps typically consist mostly of Key_ definitions. There are many, many keys

  • defined as part of the USB HID Keyboard specification. You can find the names

  • (if not yet the explanations) for all the standard Key_ defintions offered by

  • Kaleidoscope in these files:

  • https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keyboard.h

  • https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_consumerctl.h

  • https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_sysctl.h

  • https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keymaps.h

  • Additional things that should be documented here include

  • using ___ to let keypresses fall through to the previously active layer

  • using XXX to mark a keyswitch as ‘blocked’ on this layer

  • using ShiftToLayer() and LockLayer() keys to change the active keymap.

  • the special nature of the PROG key

  • keeping NUM and FN consistent and accessible on all layers

  • The “keymaps” data structure is a list of the keymaps compiled into the firmware.

  • The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#)

  • macros switch to key layers based on this list.

  • A key defined as ‘ShiftToLayer(FUNCTION)’ will switch to FUNCTION while held.

  • Similarly, a key defined as ‘LockLayer(NUMPAD)’ will switch to NUMPAD when tapped.
    */

/**

  • Layers are “0-indexed” – That is the first one is layer 0. The second one is layer 1.
  • The third one is layer 2.
  • This ‘enum’ lets us use names like QWERTY, FUNCTION, and NUMPAD in place of
  • the numbers 0, 1 and 2.

*/

enum { QWERTY, NUMPAD, FUNCTION }; // layers

/* This comment temporarily turns off astyle’s indent enforcement

  • so we can make the keymaps actually resemble the physical key layout better
    */
    // INDENT-OFF

const Key keymaps[][ROWS][COLS] PROGMEM = {

[QWERTY] = KEYMAP_STACKED
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
ShiftToLayer(FUNCTION),

M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
ShiftToLayer(FUNCTION)),

[NUMPAD] = KEYMAP_STACKED
(___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___,

M(MACRO_VERSION_INFO), ___, Key_Keypad7, Key_Keypad8, Key_Keypad9, Key_KeypadSubtract, ___,
___, ___, Key_Keypad4, Key_Keypad5, Key_Keypad6, Key_KeypadAdd, ___,
___, Key_Keypad1, Key_Keypad2, Key_Keypad3, Key_Equals, Key_Quote,
___, ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
___, ___, ___, ___,
___),

[FUNCTION] = KEYMAP_STACKED
(___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, XXX,
Key_Tab, ___, Key_mouseUp, ___, Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
Key_End, Key_PrintScreen, Key_Insert, ___, Key_mouseBtnM, Key_mouseWarpSW, Key_mouseWarpSE,
___, Key_Delete, ___, ___,
___,

Consumer_ScanPreviousTrack, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
Consumer_PlaySlashPause, Consumer_ScanNextTrack, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, Key_F12,
Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___,
Key_PcApplication, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe,
___, ___, Key_Enter, ___,
___)

};

/* Re-enable astyle’s indent enforcement */
// INDENT-ON

/** versionInfoMacro handles the ‘firmware version info’ macro

  • When a key bound to the macro is pressed, this macro
  • prints out the firmware build information as virtual keystrokes
    */

static void versionInfoMacro(uint8_t keyState) {
if (keyToggledOn(keyState)) {
Macros.type(PSTR("Keyboardio Model 01 - Kaleidoscope "));
Macros.type(PSTR(BUILD_INFORMATION));
}
}

/** anyKeyMacro is used to provide the functionality of the ‘Any’ key.
*

  • When the ‘any key’ macro is toggled on, a random alphanumeric key is
  • selected. While the key is held, the function generates a synthetic
  • keypress event repeating that randomly selected key.

*/

static void anyKeyMacro(uint8_t keyState) {
static Key lastKey;
if (keyToggledOn(keyState))
lastKey.keyCode = Key_A.keyCode + (uint8_t)(millis() % 36);

if (keyIsPressed(keyState))
kaleidoscope::hid::pressKey(lastKey);
}

/** macroAction dispatches keymap events that are tied to a macro
to that macro. It takes two uint8_t parameters.

The first is the macro being called (the entry in the 'enum' earlier in this file).
The second is the state of the keyswitch. You can use the keyswitch state to figure out
if the key has just been toggled on, is currently pressed or if it's just been released.

The 'switch' statement should have a 'case' for each entry of the macro enum.
Each 'case' statement should call out to a function to handle the macro in question.

*/

const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
switch (macroIndex) {

case MACRO_VERSION_INFO:
versionInfoMacro(keyState);
break;

case MACRO_ANY:
anyKeyMacro(keyState);
break;
}
return MACRO_NONE;
}

// These ‘solid’ color effect definitions define a rainbow of
// LED color modes calibrated to draw 500mA or less on the
// Keyboardio Model 01.

static kaleidoscope::LEDSolidColor solidRed(160, 0, 0);
static kaleidoscope::LEDSolidColor solidOrange(140, 70, 0);
static kaleidoscope::LEDSolidColor solidYellow(130, 100, 0);
static kaleidoscope::LEDSolidColor solidGreen(0, 160, 0);
static kaleidoscope::LEDSolidColor solidBlue(0, 70, 130);
static kaleidoscope::LEDSolidColor solidIndigo(0, 0, 170);
static kaleidoscope::LEDSolidColor solidViolet(130, 0, 120);
static kaleidoscope::LEDSolidColor solidOrange2(255, 127, 39);

//test abe

// Optionally Make things more human readable by naming your colors
cRGB antiquewhite = CRGB(250, 235, 215);
cRGB blue = CRGB(0, 0, 255);
cRGB cyan = CRGB(0, 255, 255);
cRGB green = CRGB(0, 128, 0);
cRGB lightskyblue = CRGB(135, 206, 250);
cRGB lime = CRGB(0, 255, 0);
cRGB mintcream = CRGB(245, 255, 250);
cRGB orange = CRGB(255, 165, 0);
cRGB orangered = CRGB(255, 100, 0);
cRGB palegreen = CRGB(152, 251, 152);
cRGB pink = CRGB(255, 192, 203);
cRGB red = CRGB(255, 0, 0);
cRGB skyblue = CRGB(135, 206, 235);
cRGB slateblue = CRGB(106, 90, 205);
cRGB violet = CRGB(238, 130, 238);
cRGB white = CRGB(255, 255, 255);
cRGB yellow = CRGB(255, 255, 0);
cRGB yellowgreen = CRGB(154, 205, 50);

// If your FUNCTION layer is not the default, you must set it here
FunColor.functionLayer = FUNCTION;

// Here we can set custom colors for your FunctionalColor instance.
// You can optionally specify a brightness value, 0-255 to dim your lights.

// Set this first to provide a "default" color for all keys, then override with the other settings.
FunColor.all(CRGB(250, 235, 215));

// Set this second to change all modifiers (non-alphabet/numeric/punctuation keys)
FunColor.allModifiers(CRGB(250, 235, 215));

// Set this before individual mouse settings to change all mouse-related keys
FunColor.allMouse(CRGB(0, 200, 200)); 

//Set individual groups of colors. You may delete any lines you don't need.
FunColor.escape(red, 170);
FunColor.numbers(white, 160);
FunColor.letters(antiquewhite, 100);
FunColor.punctuation(antiquewhite, 170);
FunColor.brackets(antiquewhite, 200);
FunColor.backslash(antiquewhite, 170);
FunColor.pipe(antiquewhite, 170);
FunColor.tab(white, 170);
FunColor.backspace(red, 170);
FunColor.del(red, 170);
FunColor.enter(white, 170);
FunColor.arrows(white, 170);
FunColor.nav(yellow, 170);
FunColor.insert(yellow, 170);
FunColor.shift(palegreen, 170);
FunColor.ctrl(skyblue, 170);
FunColor.alt(green, 170);
FunColor.cmd(CRGB(250, 235, 215));
FunColor.app(CRGB(250, 235, 215));
FunColor.printscreen(CRGB(250, 235, 215));
FunColor.pause(CRGB(250, 235, 215));
FunColor.scrolllock(CRGB(250, 235, 215));
FunColor.capslock(CRGB(250, 235, 215));
FunColor.fkeys(red, 170);
FunColor.fn(CRGB(250, 235, 215));
FunColor.media(CRGB(250, 235, 215));
FunColor.led(blue, 190);
FunColor.mousemove(cyan, 170);
FunColor.mousebuttons(lightskyblue, 170);
FunColor.mousewarp(cyan, 100);
FunColor.mousescroll(lightskyblue, 100);

//Copy new settings to the dimmed versions
FunColorMedium = FunColor;
FunColorLow = FunColor;

// You could make adjustments to your other versions' groups here, if desired.

// Adjust the brightness of dimmed versions here from 0-255
FunColorMedium.brightness(210);
FunColorLow.brightness(170);

);
}

/** The ‘setup’ function is one of the two standard Arduino sketch functions.

  • It’s called when your keyboard first powers up. This is where you set up
  • Kaleidoscope and any plugins.
    */

void setup() {
// First, call Kaleidoscope’s internal setup function
Kaleidoscope.setup();

// Next, tell Kaleidoscope which plugins you want to use.
// The order can be important. For example, LED effects are
// added in the order they’re listed here.
Kaleidoscope.use(
// The boot greeting effect pulses the LED button for 10 seconds after the keyboard is first connected
&BootGreetingEffect,

// The hardware test mode, which can be invoked by tapping Prog, LED and the left Fn button at the same time.
&TestMode,

// LEDControl provides support for other LED modes
&LEDControl,

// We start with the LED effect that turns off all the LEDs.
&LEDOff,

// The rainbow effect changes the color of all of the keyboard's keys at the same time
// running through all the colors of the rainbow.
&LEDRainbowEffect,

// The rainbow wave effect lights up your keyboard with all the colors of a rainbow
// and slowly moves the rainbow across your keyboard
&LEDRainbowWaveEffect,

// The chase effect follows the adventure of a blue pixel which chases a red pixel across
// your keyboard. Spoiler: the blue pixel never catches the red pixel
&LEDChaseEffect,

// These static effects turn your keyboard's LEDs a variety of colors
&solidRed, &solidOrange, &solidYellow, &solidGreen, &solidBlue, &solidIndigo, &solidViolet, &solidOrange2,

// The breathe effect slowly pulses all of the LEDs on your keyboard
&LEDBreatheEffect,

// The AlphaSquare effect prints each character you type, using your
// keyboard's LEDs as a display
&AlphaSquareEffect,

// The stalker effect lights up the keys you've pressed recently
&StalkerEffect,

// The numpad plugin is responsible for lighting up the 'numpad' mode
// with a custom LED effect
&NumPad,

// The macros plugin adds support for macros
&Macros,

// The MouseKeys plugin lets you add keys to your keymap which move the mouse.
&MouseKeys,

&FunColor,

&FunColorMedium,

&FunColorLow

);

// While we hope to improve this in the future, the NumPad plugin
// needs to be explicitly told which keymap layer is your numpad layer
NumPad.numPadLayer = NUMPAD;

// We configure the AlphaSquare effect to use RED letters
AlphaSquare.color = { 255, 0, 0 };

// We set the brightness of the rainbow effects to 150 (on a scale of 0-255)
// This draws more than 500mA, but looks much nicer than a dimmer effect
LEDRainbowEffect.brightness(150);
LEDRainbowWaveEffect.brightness(150);

// The LED Stalker mode has a few effects. The one we like is
// called ‘BlazingTrail’. For details on other options,
// see https://github.com/keyboardio/Kaleidoscope-LED-Stalker
StalkerEffect.variant = STALKER(BlazingTrail);

// We want to make sure that the firmware starts with LED effects off
// This avoids over-taxing devices that don’t have a lot of power to share
// with USB devices
LEDOff.activate();
}

/** loop is the second of the standard Arduino sketch functions.

  • As you might expect, it runs in a loop, never exiting.
  • For Kaleidoscope-based keyboard firmware, you usually just want to
  • call Kaleidoscope.loop(); and not do anything custom here.
    */

void loop() {
Kaleidoscope.loop();
}


(Abdenour bachir) #22

seems it didnt go well lol


(JD Lien) #23

Oh, maybe try pasting it, then highlight it, and then click the “code” button.

But anyways, at a quick glance it looks like you’re following my instructions okay. I can’t tell from that if the library files are being found, though… What is the error you’re getting?


(Abdenour bachir) #24
// -*- mode: c++ -*-
// Copyright 2016 Keyboardio, inc. <jesse@keyboard.io>
// See "LICENSE" for license details

#ifndef BUILD_INFORMATION
#define BUILD_INFORMATION "locally built"
#endif


/**
 * These #include directives pull in the Kaleidoscope firmware core,
 * as well as the Kaleidoscope plugins we use in the Model 01's firmware
 */


// The Kaleidoscope core
#include "Kaleidoscope.h"

// Support for keys that move the mouse
#include "Kaleidoscope-MouseKeys.h"

// Support for macros
#include "Kaleidoscope-Macros.h"

// Support for controlling the keyboard's LEDs
#include "Kaleidoscope-LEDControl.h"

// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode
#include "Kaleidoscope-NumPad.h"

// Support for an "LED off mode"
#include "LED-Off.h"

// Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s
// when the keyboard is connected to a computer (or that computer is powered on)
#include "Kaleidoscope-LEDEffect-BootGreeting.h"

// Support for LED modes that set all LEDs to a single color
#include "Kaleidoscope-LEDEffect-SolidColor.h"

// Support for an LED mode that makes all the LEDs 'breathe'
#include "Kaleidoscope-LEDEffect-Breathe.h"

// Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard
#include "Kaleidoscope-LEDEffect-Chase.h"

// Support for LED modes that pulse the keyboard's LED in a rainbow pattern
#include "Kaleidoscope-LEDEffect-Rainbow.h"

// Support for an LED mode that lights up the keys as you press them
#include "Kaleidoscope-LED-Stalker.h"

// Support for an LED mode that prints the keys you press in letters 4px high
#include "Kaleidoscope-LED-AlphaSquare.h"

// Support for Keyboardio's internal keyboard testing mode
#include "Kaleidoscope-Model01-TestMode.h"


// Automatically sets key LEDs on active layer based on the function of the key
#include "Kaleidoscope-LEDEffect-FunctionalColor.h"



  //test abe

// You can make multiple variations of the theme.
// Warning: having several versions consumes a lot of memory!
kaleidoscope::LEDFunctionalColor FunColor;
kaleidoscope::LEDFunctionalColor FunColorMedium;
kaleidoscope::LEDFunctionalColor FunColorLow;
  
  



/** This 'enum' is a list of all the macros used by the Model 01's firmware
  * The names aren't particularly important. What is important is that each
  * is unique.
  *
  * These are the names of your macros. They'll be used in two places.
  * The first is in your keymap definitions. There, you'll use the syntax
  * `M(MACRO_NAME)` to mark a specific keymap position as triggering `MACRO_NAME`
  *
  * The second usage is in the 'switch' statement in the `macroAction` function.
  * That switch statement actually runs the code associated with a macro when
  * a macro key is pressed.
  */

enum { MACRO_VERSION_INFO,
       MACRO_ANY
     };



/** The Model 01's key layouts are defined as 'keymaps'. By default, there are three
  * keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad"
  * keymap.
  *
  * Each keymap is defined as a list using the 'KEYMAP_STAdswCKED' macro, built
  * of first the left hand's layout, followed by the right hand's layout.
  *
  * Keymaps typically consist mostly of `Key_` definitions. There are many, many keys
  * defined as part of the USB HID Keyboard specification. You can find the names
  * (if not yet the explanations) for all the standard `Key_` defintions offered by
  * Kaleidoscope in these files:
  *    https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keyboard.h
  *    https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_consumerctl.h
  *    https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_sysctl.h
  *    https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keymaps.h
  *
  * Additional things that should be documented here include
  *   using ___ to let keypresses fall through to the previously active layer
  *   using XXX to mark a keyswitch as 'blocked' on this layer
  *   using ShiftToLayer() and LockLayer() keys to change the active keymap.
  *   the special nature of the PROG key
  *   keeping NUM and FN consistent and accessible on all layers
  *
  *
  * The "keymaps" data structure is a list of the keymaps compiled into the firmware.
  * The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#)
  * macros switch to key layers based on this list.
  *
  *

  * A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held.
  * Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped.
  */

/**
  * Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1.
  * The third one is layer 2.
  * This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of
  * the numbers 0, 1 and 2.
  *
  */

enum { QWERTY, NUMPAD, FUNCTION }; // layers

/* This comment temporarily turns off astyle's indent enforcement
 *   so we can make the keymaps actually resemble the physical key layout better
 */
// *INDENT-OFF*

const Key keymaps[][ROWS][COLS] PROGMEM = {

  [QWERTY] = KEYMAP_STACKED
  (___,          Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
   Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
   Key_PageUp,   Key_A, Key_S, Key_D, Key_F, Key_G,
   Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
   Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
   ShiftToLayer(FUNCTION),

   M(MACRO_ANY),  Key_6, Key_7, Key_8,     Key_9,         Key_0,         LockLayer(NUMPAD),
   Key_Enter,     Key_Y, Key_U, Key_I,     Key_O,         Key_P,         Key_Equals,
                  Key_H, Key_J, Key_K,     Key_L,         Key_Semicolon, Key_Quote,
   Key_RightAlt,  Key_N, Key_M, Key_Comma, Key_Period,    Key_Slash,     Key_Minus,
   Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
   ShiftToLayer(FUNCTION)),


  [NUMPAD] =  KEYMAP_STACKED
  (___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___,
   ___,

   M(MACRO_VERSION_INFO),  ___, Key_Keypad7, Key_Keypad8,   Key_Keypad9,        Key_KeypadSubtract, ___,
   ___,                    ___, Key_Keypad4, Key_Keypad5,   Key_Keypad6,        Key_KeypadAdd,      ___,
                           ___, Key_Keypad1, Key_Keypad2,   Key_Keypad3,        Key_Equals,         Key_Quote,
   ___,                    ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide,   Key_Enter,
   ___, ___, ___, ___,
   ___),

  [FUNCTION] =  KEYMAP_STACKED
  (___,      Key_F1,           Key_F2,      Key_F3,     Key_F4,        Key_F5,           XXX,
   Key_Tab,  ___,              Key_mouseUp, ___,        Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
   Key_Home, Key_mouseL,       Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
   Key_End,  Key_PrintScreen,  Key_Insert,  ___,        Key_mouseBtnM, Key_mouseWarpSW,  Key_mouseWarpSE,
   ___, Key_Delete, ___, ___,
   ___,

   Consumer_ScanPreviousTrack, Key_F6,                 Key_F7,                   Key_F8,                   Key_F9,          Key_F10,          Key_F11,
   Consumer_PlaySlashPause,    Consumer_ScanNextTrack, Key_LeftCurlyBracket,     Key_RightCurlyBracket,    Key_LeftBracket, Key_RightBracket, Key_F12,
                               Key_LeftArrow,          Key_DownArrow,            Key_UpArrow,              Key_RightArrow,  ___,              ___,
   Key_PcApplication,          Consumer_Mute,          Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___,             Key_Backslash,    Key_Pipe,
   ___, ___, Key_Enter, ___,
   ___)

};

/* Re-enable astyle's indent enforcement */
// *INDENT-ON*

/** versionInfoMacro handles the 'firmware version info' macro
 *  When a key bound to the macro is pressed, this macro
 *  prints out the firmware build information as virtual keystrokes
 */

static void versionInfoMacro(uint8_t keyState) {
  if (keyToggledOn(keyState)) {
    Macros.type(PSTR("Keyboardio Model 01 - Kaleidoscope "));
    Macros.type(PSTR(BUILD_INFORMATION));
  }
}

/** anyKeyMacro is used to provide the functionality of the 'Any' key.
 *
 * When the 'any key' macro is toggled on, a random alphanumeric key is
 * selected. While the key is held, the function generates a synthetic
 * keypress event repeating that randomly selected key.
 *
 */

static void anyKeyMacro(uint8_t keyState) {
  static Key lastKey;
  if (keyToggledOn(keyState))
    lastKey.keyCode = Key_A.keyCode + (uint8_t)(millis() % 36);

  if (keyIsPressed(keyState))
    kaleidoscope::hid::pressKey(lastKey);
}


/** macroAction dispatches keymap events that are tied to a macro
    to that macro. It takes two uint8_t parameters.

    The first is the macro being called (the entry in the 'enum' earlier in this file).
    The second is the state of the keyswitch. You can use the keyswitch state to figure out
    if the key has just been toggled on, is currently pressed or if it's just been released.

    The 'switch' statement should have a 'case' for each entry of the macro enum.
    Each 'case' statement should call out to a function to handle the macro in question.

 */

const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
  switch (macroIndex) {

  case MACRO_VERSION_INFO:
    versionInfoMacro(keyState);
    break;

  case MACRO_ANY:
    anyKeyMacro(keyState);
    break;
  }
  return MACRO_NONE;
}



// These 'solid' color effect definitions define a rainbow of
// LED color modes calibrated to draw 500mA or less on the
// Keyboardio Model 01.


static kaleidoscope::LEDSolidColor solidRed(160, 0, 0);
static kaleidoscope::LEDSolidColor solidOrange(140, 70, 0);
static kaleidoscope::LEDSolidColor solidYellow(130, 100, 0);
static kaleidoscope::LEDSolidColor solidGreen(0, 160, 0);
static kaleidoscope::LEDSolidColor solidBlue(0, 70, 130);
static kaleidoscope::LEDSolidColor solidIndigo(0, 0, 170);
static kaleidoscope::LEDSolidColor solidViolet(130, 0, 120);
static kaleidoscope::LEDSolidColor solidOrange2(255, 127, 39);

  //test abe
  

    // Optionally Make things more human readable by naming your colors
    cRGB antiquewhite = CRGB(250, 235, 215);
    cRGB blue = CRGB(0, 0, 255);
    cRGB cyan = CRGB(0, 255, 255);
    cRGB green = CRGB(0, 128, 0);
    cRGB lightskyblue = CRGB(135, 206, 250);
    cRGB lime = CRGB(0, 255, 0);
    cRGB mintcream = CRGB(245, 255, 250);
    cRGB orange = CRGB(255, 165, 0);
    cRGB orangered = CRGB(255, 100, 0);
    cRGB palegreen = CRGB(152, 251, 152);
    cRGB pink = CRGB(255, 192, 203);
    cRGB red = CRGB(255, 0, 0);
    cRGB skyblue = CRGB(135, 206, 235);
    cRGB slateblue = CRGB(106, 90, 205);
    cRGB violet = CRGB(238, 130, 238);
    cRGB white = CRGB(255, 255, 255);
    cRGB yellow = CRGB(255, 255, 0);
    cRGB yellowgreen = CRGB(154, 205, 50);

    // If your FUNCTION layer is not the default, you must set it here
    FunColor.functionLayer = FUNCTION;

    // Here we can set custom colors for your FunctionalColor instance.
    // You can optionally specify a brightness value, 0-255 to dim your lights.

    // Set this first to provide a "default" color for all keys, then override with the other settings.
    FunColor.all(CRGB(250, 235, 215));

    // Set this second to change all modifiers (non-alphabet/numeric/punctuation keys)
    FunColor.allModifiers(CRGB(250, 235, 215));

    // Set this before individual mouse settings to change all mouse-related keys
    FunColor.allMouse(CRGB(0, 200, 200)); 

    //Set individual groups of colors. You may delete any lines you don't need.
    FunColor.escape(red, 170);
    FunColor.numbers(white, 160);
    FunColor.letters(antiquewhite, 100);
    FunColor.punctuation(antiquewhite, 170);
    FunColor.brackets(antiquewhite, 200);
    FunColor.backslash(antiquewhite, 170);
    FunColor.pipe(antiquewhite, 170);
    FunColor.tab(white, 170);
    FunColor.backspace(red, 170);
    FunColor.del(red, 170);
    FunColor.enter(white, 170);
    FunColor.arrows(white, 170);
    FunColor.nav(yellow, 170);
    FunColor.insert(yellow, 170);
    FunColor.shift(palegreen, 170);
    FunColor.ctrl(skyblue, 170);
    FunColor.alt(green, 170);
    FunColor.cmd(CRGB(250, 235, 215));
    FunColor.app(CRGB(250, 235, 215));
    FunColor.printscreen(CRGB(250, 235, 215));
    FunColor.pause(CRGB(250, 235, 215));
    FunColor.scrolllock(CRGB(250, 235, 215));
    FunColor.capslock(CRGB(250, 235, 215));
    FunColor.fkeys(red, 170);
    FunColor.fn(CRGB(250, 235, 215));
    FunColor.media(CRGB(250, 235, 215));
    FunColor.led(blue, 190);
    FunColor.mousemove(cyan, 170);
    FunColor.mousebuttons(lightskyblue, 170);
    FunColor.mousewarp(cyan, 100);
    FunColor.mousescroll(lightskyblue, 100);

    //Copy new settings to the dimmed versions
    FunColorMedium = FunColor;
    FunColorLow = FunColor;

    // You could make adjustments to your other versions' groups here, if desired.

    // Adjust the brightness of dimmed versions here from 0-255
    FunColorMedium.brightness(210);
    FunColorLow.brightness(170);


  );
}



/** The 'setup' function is one of the two standard Arduino sketch functions.
  * It's called when your keyboard first powers up. This is where you set up
  * Kaleidoscope and any plugins.
  */

void setup() {
  // First, call Kaleidoscope's internal setup function
  Kaleidoscope.setup();

  // Next, tell Kaleidoscope which plugins you want to use.
  // The order can be important. For example, LED effects are
  // added in the order they're listed here.
  Kaleidoscope.use(
    // The boot greeting effect pulses the LED button for 10 seconds after the keyboard is first connected
    &BootGreetingEffect,

    // The hardware test mode, which can be invoked by tapping Prog, LED and the left Fn button at the same time.
    &TestMode,

    // LEDControl provides support for other LED modes
    &LEDControl,

    // We start with the LED effect that turns off all the LEDs.
    &LEDOff,

    // The rainbow effect changes the color of all of the keyboard's keys at the same time
    // running through all the colors of the rainbow.
    &LEDRainbowEffect,

    // The rainbow wave effect lights up your keyboard with all the colors of a rainbow
    // and slowly moves the rainbow across your keyboard
    &LEDRainbowWaveEffect,

    // The chase effect follows the adventure of a blue pixel which chases a red pixel across
    // your keyboard. Spoiler: the blue pixel never catches the red pixel
    &LEDChaseEffect,

    // These static effects turn your keyboard's LEDs a variety of colors
    &solidRed, &solidOrange, &solidYellow, &solidGreen, &solidBlue, &solidIndigo, &solidViolet, &solidOrange2,

    // The breathe effect slowly pulses all of the LEDs on your keyboard
    &LEDBreatheEffect,

    // The AlphaSquare effect prints each character you type, using your
    // keyboard's LEDs as a display
    &AlphaSquareEffect,

    // The stalker effect lights up the keys you've pressed recently
    &StalkerEffect,

    // The numpad plugin is responsible for lighting up the 'numpad' mode
    // with a custom LED effect
    &NumPad,

    // The macros plugin adds support for macros
    &Macros,

    // The MouseKeys plugin lets you add keys to your keymap which move the mouse.
    &MouseKeys,

    &FunColor,
    
    &FunColorMedium,
    
    &FunColorLow

    
  );

  // While we hope to improve this in the future, the NumPad plugin
  // needs to be explicitly told which keymap layer is your numpad layer
  NumPad.numPadLayer = NUMPAD;

  // We configure the AlphaSquare effect to use RED letters
  AlphaSquare.color = { 255, 0, 0 };

  // We set the brightness of the rainbow effects to 150 (on a scale of 0-255)
  // This draws more than 500mA, but looks much nicer than a dimmer effect
  LEDRainbowEffect.brightness(150);
  LEDRainbowWaveEffect.brightness(150);

  // The LED Stalker mode has a few effects. The one we like is
  // called 'BlazingTrail'. For details on other options,
  // see https://github.com/keyboardio/Kaleidoscope-LED-Stalker
  StalkerEffect.variant = STALKER(BlazingTrail);

  // We want to make sure that the firmware starts with LED effects off
  // This avoids over-taxing devices that don't have a lot of power to share
  // with USB devices
  LEDOff.activate();
}

/** loop is the second of the standard Arduino sketch functions.
  * As you might expect, it runs in a loop, never exiting.
  *
  * For Kaleidoscope-based keyboard firmware, you usually just want to
  * call Kaleidoscope.loop(); and not do anything custom here.
  */

void loop() {
  Kaleidoscope.loop();
}

(Abdenour bachir) #25

and the error

Model01-Firmware_abe:294: error: 'FunColor' does not name a type

     FunColor.functionLayer = FUNCTION;

     ^

Model01-Firmware_abe:300: error: 'FunColor' does not name a type

     FunColor.all(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:300: error: expected unqualified-id before ')' token

     FunColor.all(CRGB(250, 235, 215));

                                     ^

Model01-Firmware_abe:303: error: 'FunColor' does not name a type

     FunColor.allModifiers(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:303: error: expected unqualified-id before ')' token

     FunColor.allModifiers(CRGB(250, 235, 215));

                                              ^

Model01-Firmware_abe:306: error: 'FunColor' does not name a type

     FunColor.allMouse(CRGB(0, 200, 200)); 

     ^

Model01-Firmware_abe:306: error: expected unqualified-id before ')' token

     FunColor.allMouse(CRGB(0, 200, 200)); 

                                        ^

Model01-Firmware_abe:309: error: 'FunColor' does not name a type

     FunColor.escape(red, 170);

     ^

Model01-Firmware_abe:310: error: 'FunColor' does not name a type

     FunColor.numbers(white, 160);

     ^

Model01-Firmware_abe:311: error: 'FunColor' does not name a type

     FunColor.letters(antiquewhite, 100);

     ^

Model01-Firmware_abe:312: error: 'FunColor' does not name a type

     FunColor.punctuation(antiquewhite, 170);

     ^

Model01-Firmware_abe:313: error: 'FunColor' does not name a type

     FunColor.brackets(antiquewhite, 200);

     ^

Model01-Firmware_abe:314: error: 'FunColor' does not name a type

     FunColor.backslash(antiquewhite, 170);

     ^

Model01-Firmware_abe:315: error: 'FunColor' does not name a type

     FunColor.pipe(antiquewhite, 170);

     ^

Model01-Firmware_abe:316: error: 'FunColor' does not name a type

     FunColor.tab(white, 170);

     ^

Model01-Firmware_abe:317: error: 'FunColor' does not name a type

     FunColor.backspace(red, 170);

     ^

Model01-Firmware_abe:318: error: 'FunColor' does not name a type

     FunColor.del(red, 170);

     ^

Model01-Firmware_abe:319: error: 'FunColor' does not name a type

     FunColor.enter(white, 170);

     ^

Model01-Firmware_abe:320: error: 'FunColor' does not name a type

     FunColor.arrows(white, 170);

     ^

Model01-Firmware_abe:321: error: 'FunColor' does not name a type

     FunColor.nav(yellow, 170);

     ^

Model01-Firmware_abe:322: error: 'FunColor' does not name a type

     FunColor.insert(yellow, 170);

     ^

Model01-Firmware_abe:323: error: 'FunColor' does not name a type

     FunColor.shift(palegreen, 170);

     ^

Model01-Firmware_abe:324: error: 'FunColor' does not name a type

     FunColor.ctrl(skyblue, 170);

     ^

Model01-Firmware_abe:325: error: 'FunColor' does not name a type

     FunColor.alt(green, 170);

     ^

Model01-Firmware_abe:326: error: 'FunColor' does not name a type

     FunColor.cmd(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:326: error: expected unqualified-id before ')' token

     FunColor.cmd(CRGB(250, 235, 215));

                                     ^

Model01-Firmware_abe:327: error: 'FunColor' does not name a type

     FunColor.app(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:327: error: expected unqualified-id before ')' token

     FunColor.app(CRGB(250, 235, 215));

                                     ^

Model01-Firmware_abe:328: error: 'FunColor' does not name a type

     FunColor.printscreen(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:328: error: expected unqualified-id before ')' token

     FunColor.printscreen(CRGB(250, 235, 215));

                                             ^

Model01-Firmware_abe:329: error: 'FunColor' does not name a type

     FunColor.pause(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:329: error: expected unqualified-id before ')' token

     FunColor.pause(CRGB(250, 235, 215));

                                       ^

Model01-Firmware_abe:330: error: 'FunColor' does not name a type

     FunColor.scrolllock(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:330: error: expected unqualified-id before ')' token

     FunColor.scrolllock(CRGB(250, 235, 215));

                                            ^

Model01-Firmware_abe:331: error: 'FunColor' does not name a type

     FunColor.capslock(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:331: error: expected unqualified-id before ')' token

     FunColor.capslock(CRGB(250, 235, 215));

                                          ^

Model01-Firmware_abe:332: error: 'FunColor' does not name a type

     FunColor.fkeys(red, 170);

     ^

Model01-Firmware_abe:333: error: 'FunColor' does not name a type

     FunColor.fn(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:333: error: expected unqualified-id before ')' token

     FunColor.fn(CRGB(250, 235, 215));

                                    ^

Model01-Firmware_abe:334: error: 'FunColor' does not name a type

     FunColor.media(CRGB(250, 235, 215));

     ^

Model01-Firmware_abe:334: error: expected unqualified-id before ')' token

     FunColor.media(CRGB(250, 235, 215));

                                       ^

Model01-Firmware_abe:335: error: 'FunColor' does not name a type

     FunColor.led(blue, 190);

     ^

Model01-Firmware_abe:336: error: 'FunColor' does not name a type

     FunColor.mousemove(cyan, 170);

     ^

Model01-Firmware_abe:337: error: 'FunColor' does not name a type

     FunColor.mousebuttons(lightskyblue, 170);

     ^

Model01-Firmware_abe:338: error: 'FunColor' does not name a type

     FunColor.mousewarp(cyan, 100);

     ^

Model01-Firmware_abe:342: error: 'FunColorMedium' does not name a type

     FunColorMedium = FunColor;

     ^

Model01-Firmware_abe:343: error: 'FunColorLow' does not name a type

     FunColorLow = FunColor;

     ^

Multiple libraries were found for "HID.h"
Model01-Firmware_abe:348: error: 'FunColorMedium' does not name a type

     FunColorMedium.brightness(210);

 Used: C:\Users\ABE_H\Documents\ArduinoData\packages\keyboardio\hardware\avr\1.22.0\libraries\HID
     ^

Model01-Firmware_abe:349: error: 'FunColorLow' does not name a type

 Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\HID
     FunColorLow.brightness(170);

     ^

Model01-Firmware_abe:352: error: expected unqualified-id before ')' token

   );

   ^

Model01-Firmware_abe:353: error: expected declaration before '}' token

 }

 ^

exit status 1
'FunColor' does not name a type

(JD Lien) #26

Okay, here is what you need to change:

Define all your colors and call any FunColor methods in the definition of the setup() function near the end of the file, between LEDOff.activate but before the close curly bracket.

Remove any of that code from other places. Also, you had inserted a close parenthesis and curly bracket that wasn’t required after where you originally defined the colors, to be sure to remove that too.

I’ve taken your code and stripped out anything nonessential other than FunctionalColor code. This should help get anyone started and hopefully make what’s going on more easy to understand.

// -*- mode: c++ -*-
#include "Kaleidoscope.h"
#include "Kaleidoscope-MouseKeys.h"
#include "Kaleidoscope-LEDControl.h"
#include "Kaleidoscope-NumPad.h"

// Automatically sets key LEDs on active layer based on the function of the key
#include "Kaleidoscope-LEDEffect-FunctionalColor.h"

// You can make multiple variations of the theme.
// Warning: having several versions consumes a lot of memory!
kaleidoscope::LEDFunctionalColor FunColor;
kaleidoscope::LEDFunctionalColor FunColorMedium;
kaleidoscope::LEDFunctionalColor FunColorLow;
  

enum { QWERTY, NUMPAD, FUNCTION }; // layers

const Key keymaps[][ROWS][COLS] PROGMEM = {

  [QWERTY] = KEYMAP_STACKED
  (___,          Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
   Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
   Key_PageUp,   Key_A, Key_S, Key_D, Key_F, Key_G,
   Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
   Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
   ShiftToLayer(FUNCTION),

   ___,  Key_6, Key_7, Key_8,     Key_9,         Key_0,         LockLayer(NUMPAD),
   Key_Enter,     Key_Y, Key_U, Key_I,     Key_O,         Key_P,         Key_Equals,
                  Key_H, Key_J, Key_K,     Key_L,         Key_Semicolon, Key_Quote,
   Key_RightAlt,  Key_N, Key_M, Key_Comma, Key_Period,    Key_Slash,     Key_Minus,
   Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
   ShiftToLayer(FUNCTION)),


  [NUMPAD] =  KEYMAP_STACKED
  (___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___,
   ___,

   ___,  ___, Key_Keypad7, Key_Keypad8,   Key_Keypad9,        Key_KeypadSubtract, ___,
   ___,                    ___, Key_Keypad4, Key_Keypad5,   Key_Keypad6,        Key_KeypadAdd,      ___,
                           ___, Key_Keypad1, Key_Keypad2,   Key_Keypad3,        Key_Equals,         Key_Quote,
   ___,                    ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide,   Key_Enter,
   ___, ___, ___, ___,
   ___),

  [FUNCTION] =  KEYMAP_STACKED
  (___,      Key_F1,           Key_F2,      Key_F3,     Key_F4,        Key_F5,           XXX,
   Key_Tab,  ___,              Key_mouseUp, ___,        Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
   Key_Home, Key_mouseL,       Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
   Key_End,  Key_PrintScreen,  Key_Insert,  ___,        Key_mouseBtnM, Key_mouseWarpSW,  Key_mouseWarpSE,
   ___, Key_Delete, ___, ___,
   ___,

   Consumer_ScanPreviousTrack, Key_F6,                 Key_F7,                   Key_F8,                   Key_F9,          Key_F10,          Key_F11,
   Consumer_PlaySlashPause,    Consumer_ScanNextTrack, Key_LeftCurlyBracket,     Key_RightCurlyBracket,    Key_LeftBracket, Key_RightBracket, Key_F12,
                               Key_LeftArrow,          Key_DownArrow,            Key_UpArrow,              Key_RightArrow,  ___,              ___,
   Key_PcApplication,          Consumer_Mute,          Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___,             Key_Backslash,    Key_Pipe,
   ___, ___, Key_Enter, ___,
   ___)

};


/** The 'setup' function is one of the two standard Arduino sketch functions.
  * It's called when your keyboard first powers up. This is where you set up
  * Kaleidoscope and any plugins.
  */

void setup() {
  // First, call Kaleidoscope's internal setup function
  Kaleidoscope.setup();

  // Next, tell Kaleidoscope which plugins you want to use.
  // The order can be important. For example, LED effects are
  // added in the order they're listed here.
  Kaleidoscope.use(
    // The MouseKeys plugin lets you add keys to your keymap which move the mouse.
    &MouseKeys,
    &FunColor,&FunColorMedium,&FunColorLow 
  );

  // While we hope to improve this in the future, the NumPad plugin
  // needs to be explicitly told which keymap layer is your numpad layer
  NumPad.numPadLayer = NUMPAD;
  
  // Optionally Make things more human readable by naming your colors
  cRGB antiquewhite = CRGB(250, 235, 215);
  cRGB blue = CRGB(0, 0, 255);
  cRGB cyan = CRGB(0, 255, 255);
  cRGB green = CRGB(0, 128, 0);
  cRGB lightskyblue = CRGB(135, 206, 250);
  cRGB lime = CRGB(0, 255, 0);
  cRGB mintcream = CRGB(245, 255, 250);
  cRGB orange = CRGB(255, 165, 0);
  cRGB orangered = CRGB(255, 100, 0);
  cRGB palegreen = CRGB(152, 251, 152);
  cRGB pink = CRGB(255, 192, 203);
  cRGB red = CRGB(255, 0, 0);
  cRGB skyblue = CRGB(135, 206, 235);
  cRGB slateblue = CRGB(106, 90, 205);
  cRGB violet = CRGB(238, 130, 238);
  cRGB white = CRGB(255, 255, 255);
  cRGB yellow = CRGB(255, 255, 0);
  cRGB yellowgreen = CRGB(154, 205, 50);
  
  
  // If your FUNCTION layer is not the default, you must set it here
  FunColor.functionLayer = FUNCTION;
  
  // Here we can set custom colors for your FunctionalColor instance.
  // You can optionally specify a brightness value, 0-255 to dim your lights.
  
  // Set this first to provide a "default" color for all keys, then override with the other settings.
  FunColor.all(CRGB(250, 235, 215));
  
  // Set this second to change all modifiers (non-alphabet/numeric/punctuation keys)
  FunColor.allModifiers(CRGB(250, 235, 215));
  
  // Set this before individual mouse settings to change all mouse-related keys
  FunColor.allMouse(CRGB(0, 200, 200)); 
  
  //Set individual groups of colors. You may delete any lines you don't need.
  FunColor.escape(red, 170);
  FunColor.numbers(white, 160);
  FunColor.letters(antiquewhite, 100);
  FunColor.punctuation(antiquewhite, 170);
  FunColor.brackets(antiquewhite, 200);
  FunColor.backslash(antiquewhite, 170);
  FunColor.pipe(antiquewhite, 170);
  FunColor.tab(white, 170);
  FunColor.backspace(red, 170);
  FunColor.del(red, 170);
  FunColor.enter(white, 170);
  FunColor.arrows(white, 170);
  FunColor.nav(yellow, 170);
  FunColor.insert(yellow, 170);
  FunColor.shift(palegreen, 170);
  FunColor.ctrl(skyblue, 170);
  FunColor.alt(green, 170);
  FunColor.cmd(CRGB(250, 235, 215));
  FunColor.app(CRGB(250, 235, 215));
  FunColor.printscreen(CRGB(250, 235, 215));
  FunColor.pause(CRGB(250, 235, 215));
  FunColor.scrolllock(CRGB(250, 235, 215));
  FunColor.capslock(CRGB(250, 235, 215));
  FunColor.fkeys(red, 170);
  FunColor.fn(CRGB(250, 235, 215));
  FunColor.media(CRGB(250, 235, 215));
  FunColor.led(blue, 190);
  FunColor.mousemove(cyan, 170);
  FunColor.mousebuttons(lightskyblue, 170);
  FunColor.mousewarp(cyan, 100);
  FunColor.mousescroll(lightskyblue, 100);
  
  //Copy new settings to the dimmed versions
  FunColorMedium = FunColor;
  FunColorLow = FunColor;
  
  // You could make adjustments to your other versions' groups here, if desired.
  
  // Adjust the brightness of dimmed versions here from 0-255
  FunColorMedium.brightness(210);
  FunColorLow.brightness(170);

} //end setup - all FunctionalColor object methods must be called before this point


void loop() {
  Kaleidoscope.loop();
}

(Abdenour bachir) #27

it worked !
awesome
i’ll try adding it to the original firmware as an extra options qith the LED button.
not sure it will work but worht a try (the kids love swappign color modes :slight_smile:

thanks again!


(JD Lien) #28

I’m glad you figured it out! Enjoy and let me know how it works for you.


(Abdenour bachir) #29

now i get also where I couldn’t get it to work…I’m trying to add it to the default firmware, while you shared this plugin to replace the current firmware and be its own thing (right?)
So if i want it to be on another option, i need to somehow give it a button that calls it (LED swaps between a lot of mode already, it could load that mode without the brightness control?)
so now its how to do that haha
ill try a bit, and if i cant, ill just use different firmware as needed and go back to my art job hahaha


(Michael Richters) #30

Side note: You can insert a “code” block by typing three backticks on a line by themselves, then your code, followed by another line with just three backticks.

e.g. ```


(Abdenour bachir) #31

so much fun, i managed to change the colors, and add modes, now i have off/low brightness/mid / and high
:slight_smile:
for someone who never wrote a line of code, im pretty proud haha


(Abdenour bachir) #32

ok, sorry to bug you again, last question before i go play a bit more with the colors…
whats the command to specificlay apply a color to a key? im trying htis…
FunColor.Key_W(orangepastel, 255);

but it wont take it …
does it have a specific naming like for the mousekeys?


(JD Lien) #33

At the moment FunctionalColor doesn’t allow you to color each and every key individually… you can only do certain groups.

I might add the ability to be more specific in the future.

If you do want to do this, you can use a line like:

::LEDControl.setCrgbAt(r, c, color);

Where r is the row number, c is the column number and color is a color entity (or one of the variables).

It’s a pain in the butt to do it that way which is exactly why I made FunctionalColor, but unfortunately you’re kind of limited to the groups and keys I added thus far.


(Abdenour bachir) #34

ok, i tried, seems i need to add more than this line? as it cant find the function for it…
my take on it (works nicely if you take of the last line i added with the specific key control)

// -*- mode: c++ -*-

#include "Kaleidoscope.h"
#include "Kaleidoscope-MouseKeys.h"
#include "Kaleidoscope-LEDControl.h"
#include "Kaleidoscope-NumPad.h"
#include "LED-Off.h"

// Automatically sets key LEDs on active layer based on the function of the key
#include "Kaleidoscope-LEDEffect-FunctionalColor.h"

// You can make multiple variations of the theme.
// Warning: having several versions consumes a lot of memory!
kaleidoscope::LEDFunctionalColor FunColor;
kaleidoscope::LEDFunctionalColor FunColorHigh;
kaleidoscope::LEDFunctionalColor FunColorMedium;
kaleidoscope::LEDFunctionalColor FunColorLow;
  

enum { QWERTY, NUMPAD, FUNCTION }; // layers

const Key keymaps[][ROWS][COLS] PROGMEM = {

  [QWERTY] = KEYMAP_STACKED
  (___,          Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
   Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
   Key_PageUp,   Key_A, Key_S, Key_D, Key_F, Key_G,
   Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
   Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
   ShiftToLayer(FUNCTION),

   ___,  Key_6, Key_7, Key_8,     Key_9,         Key_0,         LockLayer(NUMPAD),
   Key_Enter,     Key_Y, Key_U, Key_I,     Key_O,         Key_P,         Key_Equals,
                  Key_H, Key_J, Key_K,     Key_L,         Key_Semicolon, Key_Quote,
   Key_RightAlt,  Key_N, Key_M, Key_Comma, Key_Period,    Key_Slash,     Key_Minus,
   Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
   ShiftToLayer(FUNCTION)),


  [NUMPAD] =  KEYMAP_STACKED
  (___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___, ___, ___, ___,
   ___, ___, ___, ___,
   ___,

   ___,  ___, Key_Keypad7, Key_Keypad8,   Key_Keypad9,        Key_KeypadSubtract, ___,
   ___,                    ___, Key_Keypad4, Key_Keypad5,   Key_Keypad6,        Key_KeypadAdd,      ___,
                           ___, Key_Keypad1, Key_Keypad2,   Key_Keypad3,        Key_Equals,         Key_Quote,
   ___,                    ___, Key_Keypad0, Key_KeypadDot, Key_KeypadMultiply, Key_KeypadDivide,   Key_Enter,
   ___, ___, ___, ___,
   ___),

  [FUNCTION] =  KEYMAP_STACKED
  (___,      Key_F1,           Key_F2,      Key_F3,     Key_F4,        Key_F5,           XXX,
   Key_Tab,  ___,              Key_mouseUp, ___,        Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
   Key_Home, Key_mouseL,       Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
   Key_End,  Key_PrintScreen,  Key_Insert,  ___,        Key_mouseBtnM, Key_mouseWarpSW,  Key_mouseWarpSE,
   ___, Key_Delete, ___, ___,
   ___,

   Consumer_ScanPreviousTrack, Key_F6,                 Key_F7,                   Key_F8,                   Key_F9,          Key_F10,          Key_F11,
   Consumer_PlaySlashPause,    Consumer_ScanNextTrack, Key_LeftCurlyBracket,     Key_RightCurlyBracket,    Key_LeftBracket, Key_RightBracket, Key_F12,
                               Key_LeftArrow,          Key_DownArrow,            Key_UpArrow,              Key_RightArrow,  ___,              ___,
   Key_PcApplication,          Consumer_Mute,          Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___,             Key_Backslash,    Key_Pipe,
   ___, ___, Key_Enter, ___,
   ___)

};



/** The 'setup' function is one of the two standard Arduino sketch functions.
  * It's called when your keyboard first powers up. This is where you set up
  * Kaleidoscope and any plugins.
  */

void setup() {
  // First, call Kaleidoscope's internal setup function
  Kaleidoscope.setup();

  // Next, tell Kaleidoscope which plugins you want to use.
  // The order can be important. For example, LED effects are
  // added in the order they're listed here.
  Kaleidoscope.use(
    // The MouseKeys plugin lets you add keys to your keymap which move the mouse.
    &MouseKeys,
    &NumPad,
    &FunColor,&FunColorLow,&FunColorMedium,&FunColorHigh
  );

  // While we hope to improve this in the future, the NumPad plugin
  // needs to be explicitly told which keymap layer is your numpad layer
  NumPad.numPadLayer = NUMPAD;
  
  // Optionally Make things more human readable by naming your colors
  cRGB antiquewhite = CRGB(250, 235, 215);
  cRGB blue = CRGB(0, 0, 255);
  cRGB cyan = CRGB(0, 255, 255);
  cRGB green = CRGB(0, 128, 0);
  cRGB lightskyblue = CRGB(135, 206, 250);
  cRGB lime = CRGB(0, 255, 0);
  cRGB mintcream = CRGB(245, 255, 250);
  cRGB orange = CRGB(255, 165, 0);
  cRGB orangered = CRGB(255, 100, 0);
  cRGB palegreen = CRGB(152, 251, 152);
  cRGB pink = CRGB(255, 192, 203);
  cRGB red = CRGB(255, 0, 0);
  cRGB skyblue = CRGB(135, 206, 235);
  cRGB slateblue = CRGB(106, 90, 205);
  cRGB violet = CRGB(238, 130, 238);
  cRGB white = CRGB(255, 255, 255);
  cRGB yellow = CRGB(255, 255, 0);
  cRGB yellowgreen = CRGB(154, 205, 50);
  cRGB orangepastel = CRGB(255, 128, 42);
  
  
  // If your FUNCTION layer is not the default, you must set it here
  FunColor.functionLayer = FUNCTION;
  
  // Here we can set custom colors for your FunctionalColor instance.
  // You can optionally specify a brightness value, 0-255 to dim your lights.
  
  // Set this first to provide a "default" color for all keys, then override with the other settings.
  FunColor.all(CRGB(0, 0, 0));
  
  // Set this second to change all modifiers (non-alphabet/numeric/punctuation keys)
  FunColor.allModifiers(slateblue,160);
  
  // Set this before individual mouse settings to change all mouse-related keys
  FunColor.allMouse(orangepastel, 255); 



  
  //Set individual groups of colors. You may delete any lines you don't need.
  FunColor.escape(red, 255);
  FunColor.numbers(violet, 255);
  FunColor.letters(antiquewhite, 64);
  FunColor.punctuation(antiquewhite, 130);
  FunColor.brackets(antiquewhite, 155);
  FunColor.backslash(antiquewhite, 255);
  FunColor.pipe(antiquewhite, 255);
  FunColor.tab(violet, 255);
  FunColor.backspace(red, 255);
  FunColor.del(red, 255);
  FunColor.enter(slateblue, 255);
  FunColor.arrows(skyblue, 255);
  FunColor.nav(yellow, 255);
  FunColor.insert(yellow, 255);
  FunColor.shift(palegreen, 255);
  FunColor.ctrl(skyblue, 255);
  FunColor.alt(green, 255);
  FunColor.cmd(CRGB(156, 22, 215));
  FunColor.app(CRGB(250, 235, 201));
  FunColor.printscreen(CRGB(250, 235, 215));
  FunColor.pause(CRGB(250, 235, 215));
  FunColor.scrolllock(CRGB(250, 235, 215));
  FunColor.capslock(blue, 255);
  FunColor.fkeys(red, 170);
  FunColor.fn(blue, 255);
  FunColor.media(CRGB(250, 235, 215));
  FunColor.led(blue, 255);
  FunColor.mousemove(orangepastel, 255);
  FunColor.mousebuttons(yellow, 255);
  FunColor.mousewarp(cyan, 255);
  FunColor.mousescroll(lightskyblue, 255);
  
  //Copy new settings to the dimmed versions
  FunColor = FunColor;
  FunColorLow = FunColor;
  FunColorMedium = FunColor;  
  FunColorHigh = FunColor;
  // You could make adjustments to your other versions' groups here, if desired.
  
  // Adjust the brightness of dimmed versions here from 0-255
  FunColor.brightness(0);
  FunColorLow.brightness(90);
  FunColorMedium.brightness(160);
  FunColorHigh.brightness(255);
  ::LEDControl.setCrgbAt(2,3, orangepastel, 255);
 

} //end setup - all FunctionalColor object methods must be called before this point


void loop() {
  Kaleidoscope.loop();
}

(JD Lien) #35

What are you trying to accomplish, more generally?
Do you just want control of each, individual key? Or just a few specific ones?

I could try to add that as a feature for when I got some time, but it’s a significant amount of tedious labor (unless I can think of a better way).


(Abdenour bachir) #36

i want to set up a few combination of keys (for 3dsmax, maya etc…) so each time i use a program, i can have its specific key setup …
Im thinking this chrysalis program might eventual do that but maybe i didn’t understand its intent…
it just doesnt seem it will be usable for noobs like me for a while


(JD Lien) #37

I see. Interesting idea.

I don’t think there’s any way for the keyboard to detect the current app and switch colors, so you’d be forced to manually switch the color scheme whenever you are using that app.

I’ll look at seeing how possible it is to extend my plugin to allow all keys to be individually customized at some point. I had a feeling people would ask for this eventually and kind of wish I had done that in the first place.


(Abdenour bachir) #38

fantastic! it would make a great difference in how you can customize the keys to your liking :slight_smile: even if its a lot of repetitive work, until a proper UI is done :slight_smile:


(JD Lien) #39

Well, I went in and set this up so that you can customize virtually every key on the keyboard now (and it was indeed very tedious… I got a lot of practice with sublimetext shortcuts and text pastry :stuck_out_tongue: ) … the problem is that FunctionalColors takes a lot more memory when I do this, mainly because I just need a ton more variables and there just is so little memory to go around on this keyboard.

If anyone wants to poke at my code or try it out, I’ve created an allkeys branch here:

If you want to use this, odds are good you’ll only be able to have one instance of FunctionalColors and you might have to remove almost every other plugin from your keyboardio firmware.

If anyone has ideas for how this can be improved or how I can drastically reduce the memory usage, I’m all ears!


(JD Lien) #40

I had one idea for those more proficient in C++… most of the memory usage is taken up with “color” variables… but I suspect in practice, someone isn’t going to use a huge variety of colors. Could I do something like, instead of using a color object, just set each color to an index in an array of colors or something like that? Surely that would take far less memory… then you just have to define a list of the colors you want to use and then specify which of those colors to use… so you’d have a short integer or byte value instead of a color value which is a struct containing three integers.

Plausible?