Focus: Lift out keymap.transfer

The keymap.transfer command is only useful if we have both PROGMEM & EEPROM
keymaps, which will rarely be a case, and likely only temporarily, too. As such,
lift that out of the `focusKeymap` function, into its own. This makes the
command optional, and can save us some 140 bytes of program space (even more if
documentation is enabled).

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent 035c95a207
commit 0c387ce1c3

@ -50,6 +50,7 @@ void setup () {
Focus.addHook (FOCUS_HOOK_SETTINGS); Focus.addHook (FOCUS_HOOK_SETTINGS);
Focus.addHook (FOCUS_HOOK_KEYMAP); Focus.addHook (FOCUS_HOOK_KEYMAP);
Focus.addHook (FOCUS_HOOK_KEYMAP_TRANSFER);
Focus.addHook (FOCUS_HOOK_HELP); Focus.addHook (FOCUS_HOOK_HELP);
Focus.addHook (FOCUS_HOOK_VERSION); Focus.addHook (FOCUS_HOOK_VERSION);

@ -29,7 +29,10 @@
"-------------------------------\n" \ "-------------------------------\n" \
"Uploads a new keymap to EEPROM." \ "Uploads a new keymap to EEPROM." \
"Starts at layer 0, row 0, column 0, " \ "Starts at layer 0, row 0, column 0, " \
"and continues as long as there is data on the line.\n\n" \ "and continues as long as there is data on the line.")
"keymap.transfer layer\n" \
"---------------------\n" \
"Transfers the `layer` from PROGMEM to EEPROM.") #define FOCUS_HOOK_KEYMAP_TRANSFER FOCUS_HOOK(EEPROMKeymap.focusKeymapTransfer, \
"keymap.transfer layer\n" \
"---------------------\n" \
"Transfers the `layer` from PROGMEM to EEPROM.")

@ -86,7 +86,6 @@ namespace KaleidoscopePlugins {
enum { enum {
UPLOAD, UPLOAD,
DUMP, DUMP,
TRANSFER,
} subCommand; } subCommand;
if (strncmp_P (command, PSTR ("keymap."), 7) != 0) if (strncmp_P (command, PSTR ("keymap."), 7) != 0)
@ -96,8 +95,6 @@ namespace KaleidoscopePlugins {
subCommand = UPLOAD; subCommand = UPLOAD;
else if (strcmp_P (command + 7, PSTR ("dump")) == 0) else if (strcmp_P (command + 7, PSTR ("dump")) == 0)
subCommand = DUMP; subCommand = DUMP;
else if (strcmp_P (command + 7, PSTR ("transfer")) == 0)
subCommand = TRANSFER;
else else
return false; return false;
@ -131,22 +128,25 @@ namespace KaleidoscopePlugins {
break; break;
} }
case TRANSFER: }
{
uint8_t layer = Serial.parseInt ();
for (uint8_t row = 0; row < ROWS; row++) { return true;
for (uint8_t col = 0; col < COLS; col++) { }
Key k = Layer.getKeyFromPROGMEM (layer, row, col);
uint16_t pos = ((layer * ROWS * COLS) + (row * COLS) + col);
updateKey (pos, k); bool
} EEPROMKeymap::focusKeymapTransfer (const char *command) {
} if (strcmp_P (command, PSTR ("keymap.transfer")) != 0)
return false;
break; uint8_t layer = Serial.parseInt ();
}
for (uint8_t row = 0; row < ROWS; row++) {
for (uint8_t col = 0; col < COLS; col++) {
Key k = Layer.getKeyFromPROGMEM (layer, row, col);
uint16_t pos = ((layer * ROWS * COLS) + (row * COLS) + col);
updateKey (pos, k);
}
} }
return true; return true;

@ -34,6 +34,7 @@ namespace KaleidoscopePlugins {
static Key getKey (uint8_t layer, byte row, byte col); static Key getKey (uint8_t layer, byte row, byte col);
static bool focusKeymap (const char *command); static bool focusKeymap (const char *command);
static bool focusKeymapTransfer (const char *command);
private: private:
static uint16_t keymapBase; static uint16_t keymapBase;

Loading…
Cancel
Save