Added a "sketch-trailer.h" header file

This file is meant to be included in sketch files in order to make
data available to Kaleidoscope functions. In particular, the size of
the keymaps[] array (i.e. the number of defined layers), which is
needed in order to prevent reading uninitialized memory past the end
of that array due to Key_KeymapNext_Momentary.
pull/244/head
Michael Richters 7 years ago
parent 7ddc0249bb
commit 50ac31d0f5

@ -46,11 +46,6 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
};
/* *INDENT-ON* */
// Calculate the number of layers defined in the "keymaps[]" array
// above for use elsewhere in Kaleidoscope. Don't remove or modify
// this line; it's used to prevent reading past the end of the array!
const uint8_t LayerCount PROGMEM = sizeof(keymaps) / sizeof(*keymaps);
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
switch (macroIndex) {
@ -71,3 +66,6 @@ void setup() {
void loop() {
Kaleidoscope.loop();
}
// This line should always be at the end of the sketch file
#include <sketch-trailer.h>

@ -65,11 +65,6 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
};
// Calculate the number of layers defined in the "keymaps[]" array
// above for use elsewhere in Kaleidoscope. Don't remove or modify
// this line; it's used to prevent reading past the end of the array!
const uint8_t LayerCount PROGMEM = sizeof(keymaps) / sizeof(*keymaps);
static kaleidoscope::LEDSolidColor solidRed(60, 0, 0);
static kaleidoscope::LEDSolidColor solidOrange(60, 20, 0);
static kaleidoscope::LEDSolidColor solidYellow(40, 35, 0);
@ -109,3 +104,6 @@ void setup() {
void loop() {
Kaleidoscope.loop();
}
// This line should always be at the end of the sketch file
#include <sketch-trailer.h>

@ -0,0 +1,6 @@
#pragma once
// Calculate the number of layers defined in the "keymaps[]"
// array. This needs to be included in the sketch after "keymaps" is
// defined
const uint8_t LayerCount PROGMEM = sizeof(keymaps) / sizeof(*keymaps);
Loading…
Cancel
Save