Make the ParserRunDry global. Separate TestConfig() and ApplyConfig()

This commit is contained in:
László Monda
2017-08-08 19:20:01 +02:00
parent 0f2c7d53c9
commit 079988146d
4 changed files with 28 additions and 24 deletions

View File

@@ -3,11 +3,13 @@
static uint8_t hardwareConfig[HARDWARE_CONFIG_SIZE];
config_buffer_t HardwareConfigBuffer = {hardwareConfig};
static uint8_t userConfig1[USER_CONFIG_SIZE];
static uint8_t __attribute__((section (".m_data_2"))) userConfig2[USER_CONFIG_SIZE];
static uint8_t userConfig[USER_CONFIG_SIZE];
static uint8_t __attribute__((section (".m_data_2"))) stagingUserConfig[USER_CONFIG_SIZE];
config_buffer_t UserConfigBuffer = { userConfig1 };
config_buffer_t NewUserConfigBuffer = { userConfig2 };
config_buffer_t UserConfigBuffer = { userConfig };
config_buffer_t StagingUserConfigBuffer = { stagingUserConfig };
bool ParserRunDry;
uint8_t readUInt8(config_buffer_t *buffer) {
return buffer->buffer[buffer->offset++];

View File

@@ -21,9 +21,10 @@
// Variables:
extern bool ParserRunDry;
extern config_buffer_t HardwareConfigBuffer;
extern config_buffer_t UserConfigBuffer;
extern config_buffer_t NewUserConfigBuffer;
extern config_buffer_t StagingUserConfigBuffer;
// Functions:

View File

@@ -3,8 +3,6 @@
#include "current_keymap.h"
#include "led_display.h"
static bool isDryRun;
static parser_error_t parseNoneAction(key_action_t *keyAction, config_buffer_t *buffer) {
keyAction->type = KeyActionType_None;
return ParserError_Success;
@@ -146,7 +144,7 @@ static parser_error_t parseKeyActions(uint8_t targetLayer, config_buffer_t *buff
return ParserError_InvalidActionCount;
}
for (uint16_t actionIdx = 0; actionIdx < actionCount; actionIdx++) {
errorCode = parseKeyAction(isDryRun ? &dummyKeyAction : &CurrentKeymap[targetLayer][moduleId][actionIdx], buffer);
errorCode = parseKeyAction(ParserRunDry ? &dummyKeyAction : &CurrentKeymap[targetLayer][moduleId][actionIdx], buffer);
if (errorCode != ParserError_Success) {
return errorCode;
}
@@ -193,8 +191,7 @@ parser_error_t ParseKeymap(config_buffer_t *buffer) {;
if (layerCount != LAYER_COUNT) {
return ParserError_InvalidLayerCount;
}
isDryRun = buffer == &NewUserConfigBuffer || !isDefault;
if (!isDryRun) {
if (!ParserRunDry) {
LedDisplay_SetText(abbreviationLen, abbreviation);
}
for (uint16_t layerIdx = 0; layerIdx < layerCount; layerIdx++) {